[antlr-interest] Inserting a literal token in an AST rewrite rule
Victor Liu
victor.liu at gmail.com
Fri Feb 12 22:16:14 PST 2010
Hi,
I have an AST producing grammar with a desired rule like
expression_unary_minus
: '-' expression_power -> ^(TOK_TIMES '-1' expression_power)
| expression_power
;
This doesn't work because apparently I can't just insert a literal token
('-1') in the rewrite rule. How do I get the same effect? Also, is there
a way to simplify the rule into a one-liner? Ideally I would not need
the second line since I just need a rule like
expression_unary_minus
: '-'? expression_power
;
but allowing a rewrite.
Thanks in advance,
Victor
More information about the antlr-interest
mailing list