[antlr-interest] rewrite rules

Jim Idle jimi at temporal-wave.com
Mon Jan 21 11:55:57 PST 2008


unaryright
:  operand st=seventhops? 

      -> {$st==null}? ^(UNARYRIGHT operand)
      ->              ^(UNARYRIGHT $st+ operand)
;



> -----Original Message-----
> From: Shaun Bogan [mailto:smbogan at gmail.com]
> Sent: Monday, January 21, 2008 9:19 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] rewrite rules
> 
> 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