[antlr-interest] "become root" operator ^ sometimes fails
Jim Idle
jimi at temporal-wave.com
Tue Oct 14 08:36:47 PDT 2008
On Tue, 2008-10-14 at 14:59 +0200, Mark Langezaal wrote:
> Uhh, subtitles please...
> Do you mean this is a kind of a bug, but there is an easy workaround by
> removing the brackets?
>
> >> // Input: 1 + 2
> >> // Generated AST: ^(+ 1 2)
> >> okExpr
> >> : NUM (('+'|'-')^ NUM)*
basiaclly, I think you want:
NUM ((('+')^|('-')^) NUM)*
You can also do:
NUM (arithOp^ NUM)*;
arithOp : '+' | '-' ;
Though I personally would get rid of all the literals in the parser
grammar and replace them with lexer tokens.
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081014/46059aea/attachment.html
More information about the antlr-interest
mailing list