[antlr-interest] rewrite rules

Shaun Bogan smbogan at gmail.com
Mon Jan 21 09:19:00 PST 2008


unaryright
:  operand seventhops? -> ^(UNARYRIGHT seventhops? operand)
;

I am trying to get my grammar to only make the UNARYRIGHT node when
both seventhops and operand are present, because seventhops is
optional.

Using:
unaryright options{backtrack = true;}
:  operand seventhops -> ^(UNARYRIGHT seventhops operand)
|  operand
;

works in the debugger, but not in the interpreter, and I'd prefer to
do this without backtracking if at all possible.

Any help is greatly appreciated,
S M Bogan


More information about the antlr-interest mailing list