[antlr-interest] Ignoring with tree parser redux

Greg Smolyn smolyn at cs.ubc.ca
Tue Mar 12 14:25:01 PST 2002

Okay, thanks to Monty "what a guy" Zukowski, I have figured out my problem.

I am unsure whether or not this is a bug with ANTLR, but most likely 
it's because I'm not quite understanding something about tree parsing. :)

Anyways, I tried using the following to unparse only selected elements 
from my AST:

#(NAspectDeclaration  . /*that dot matches declarator*/
       (  (functionDef)=>functionDef
          | .

However, the code this generates will end up with an NPE.  On 
inspection, I looked at the loop it generates and saw that it _does not_ 
create the standard boilerplate for these kinds of loops:
    if (_t==null)  _t=ASTNULL;

when I added this line, the code worked.  However, at Monty's suggestion 
I tried removing the syntactic predicate to get:

#(NAspectDeclaration  . /*that dot matches declarator*/
       (  functionDef
          | .

which worked perfectly.

Technically speaking, the syntactic predicate was overkill.  But is that 
the expected behaviour?  I'm not sure.  Anyways, if you're running into 
a similar problem, try removing the synpreds and see what happens. :)

- greg
University of British Columbia
Software Practices Lab


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

More information about the antlr-interest mailing list