Previous: ‘#line’ and TeX, Up: External Macro Processors: Line Directives [Contents][Index]
Syntax details for the ‘#line’ directive: the ‘#’ character can be preceded or followed by whitespace, the word ‘line’ is optional, and the file name can be followed by a whitespace-separated list of integers (these are so-called “flags” output by CPP in some cases). For those who like to know the gory details, the actual (Perl) regular expression which is matched is this:
/^\s*#\s*(line)? (\d+)(( "([^"]+)")(\s+\d+)*)?\s*$/
As far as we’ve been able to tell, the trailing integer flags only occur in conjunction with a file name, so that is reflected in the regular expression.
As an example, the following is a syntactically valid ‘#line’ directive, meaning line 1 of /usr/include/stdio.h:
# 1 "/usr/include/stdio.h" 2 3 4
Unfortunately, the quoted file name (‘"..."’) has to be optional, because M4 (especially) can often generate ‘#line’ directives within a single file. Since the ‘line’ is also optional, the result is that lines might match which you wouldn’t expect, e.g.,
# 1
The possible solutions are described above (see ‘#line’ Directive).