[antlr-interest] How to intersperse #line directives into expressions and statements?

pragmaik contact at maik-schmidt.de
Mon May 28 23:06:26 PDT 2012


Hi! 

I am trying to parse #line directives within expressions and statements, so
I can tag the nodes in the AST with the line numbers in the #line
directives. For example 

#line 10 
if ( 
#line 20 
x 
#line 30 
> 
#line 40 
0 
) 

would lead to an AST where the 'if' node is tagged with 10 and the 'x' node
is tagged with 20. 

First, I thought about writing a preprocessor, but this won't help, I think,
because the preprocessor has nothing to do with the AST. Adding this
behavior to the grammar isn't easy either, because the grammar had to accept
'#line INTLITERAL' nearly everywhere. 

Did anybody solve a similar problem and could offer any help? 

Cheers, 
Maik 

--
View this message in context: http://antlr.1301665.n2.nabble.com/How-to-intersperse-line-directives-into-expressions-and-statements-tp7578122.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list