[antlr-interest] Problem getting all tokens in AST for GnuCPa rser.g

mzukowski at yci.com mzukowski at yci.com
Mon Mar 10 08:05:48 PST 2003


You are going to have a heck of a time preserving all tokens in the AST.
Writing the tree parser for that will make be difficult because you will be
introducing many many ambiguities.  

With the fragment below you will notice the for loop being built in an
action.  Removing the ! causes it to be build automatically and then again
in the action making some nodes children of themselves, introducing your
infinite loop.

Why are you trying to preserve all tokens in the AST?  I guarantee there is
a better way to accomplish your goal than that.

Monty

-----Original Message-----
From: edcjones [mailto:edcjones at yahoo.com]
Sent: Saturday, March 08, 2003 2:12 PM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Problem getting all tokens in AST for
GnuCParser.g


I want GnuCParser.g to send all tokens (except preprocessor directives
and comments) to the AST. I removed a number of "!"s from the grammar.
If I remove the "!" from

|!       "for"
         LPAREN ( e1:expr )? SEMI ( e2:expr )? SEMI ( e3:expr )? RPAREN
         s:statement
         ...

antlr appears to go into an infinite loop. How can I get the "(", ";",
";", and ")" included in the AST?



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list