[antlr-interest] Why can't I use $stop in an @after action?
Terence Parr
parrt at cs.usfca.edu
Fri Feb 5 11:55:03 PST 2010
weird. wait. does $stop work for tree grammars? you might try input.LT(-1) or -2.
T
On Feb 5, 2010, at 11:36 AM, Chris DiGiano wrote:
> I've read and reread the documentation on the $stop attributes of
> rules, but I can't for the life of me figure out how to use it to get
> the last matched node. Here's what I want to do:
>
> impliedQualifiedName returns [Tree idNode]
> @after {
> $idNode = $stop; // I also tried $impliedQualifiedName.stop
> }
> : Identifier
> | ^( BYFIELD qn=impliedQualifiedName Identifier )
> ;
>
> But I get the error "attribute is not a token, parameter, or return
> value: stop".
>
> Instead I have to do:
>
> impliedQualifiedName returns [Tree idNode]
> : Identifier { $idNode = $Identifier; }
> | ^( BYFIELD qn=impliedQualifiedName Identifier )
> { $idNode = $Identifier; }
> ;
>
> What am I doing wrong?
>
> Chris
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list