[antlr-interest] Why cant += be used without an "output=" option (and other Q's)

Gavin Lambert antlr at mirality.co.nz
Mon Feb 18 11:09:47 PST 2008


At 07:19 19/02/2008, Benjamin Shropshire wrote:
 >What I'm having trouble with it using the += operator. If I set
 >output=AST then ANTLR adds the sub rules return to some sort of
 >list, however it also seems to expect me to generate an AST node 

 >in the sub rule for it to return. If I don't, I get a list of
 >nulls (and end up with seg-v's) I still haven't figured out how
 >to have a sub rule generate and return a specific type rather
 >than the default antlr type.

If you're using code fragments to construct your own data 
structures (and thus aren't generating an AST), there's no need to 
use += at all.

If you are generating an AST, then every rule needs to generate an 
AST, although you can also return additional information.



More information about the antlr-interest mailing list