[antlr-interest] Why can't I use $stop in an @after action?

Chris DiGiano digi+antlr-interest at google.com
Fri Feb 5 11:36:32 PST 2010


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


More information about the antlr-interest mailing list