[antlr-interest] Several different tokens for the same literal

Christian chwchw at gmx.de
Wed Oct 26 03:43:55 PDT 2011


Hi community,

I want to use, e.g., the MINUS and the POSITIVE token for the '-'
literal. Is there a way to write it shorter than with rewrite rules?

For example, I want to replace the following
    '-' unary_expression -> ^(NEGATIVE unary_expression);
by
    '-'<NEGATIVE> unary_expression;
or
    NEGATIVE['-'] unary_expression;

I know that and why the last two aproaches do not work. But perhaps
there is another way that I do not know so far.

Regards,
Christian


More information about the antlr-interest mailing list