[antlr-interest] Setting return values
kevin_mitchell at agilent.com
kevin_mitchell at agilent.com
Tue Jul 24 05:55:09 PDT 2007
I've been trying to port my grammar from V2 to V3, which I'm beginning to regret... :-( I use a lot of arguments and values in my grammar, and I'm beginning to wonder whether I've misunderstood how V3 is supposed to work, because at first glance my grammar is becoming a lot more cumbersome than the V2 version. Here's a concrete example. In V2 I might have written something like
declaration returns [Declaration d] :
d=valueDeclaration
| d=simpleTypeDeclaration
| d=genericTypeDeclaration
;
But in V3 it looks like I now have to write something like
declaration returns [Declaration d]
@after { $d = dec; }
: dec=valueDeclaration
| dec=simpleTypeDeclaration
| dec=genericTypeDeclaration
;
I.e. I have to use an auxiliary name, dec in this case, and then assign to $d at the end. Is this correct, or have I misunderstood something?
Thanks, Kevin
More information about the antlr-interest
mailing list