[antlr-interest] Tree output syntax

Gavin Lambert antlr at mirality.co.nz
Wed Apr 4 13:49:42 PDT 2007


I can't quite work out how to do the tree output syntax for an 
optional case.

I've got a rule like this:

compoundString: STRING (PLUS^ STRING)*;

but that fails with "unexpected end of subtree" at compilation 
time.  What I'd like it to do is to output just a flat string when 
no PLUS is present, otherwise output trees like (PLUS string1 
string2) or either (PLUS string1 (PLUS string2 string3)) or (PLUS 
string1 string2 string3) -- don't really care which, as long as it 
only puts the PLUS in when it's actually present in the input.



More information about the antlr-interest mailing list