[antlr-interest] Intentional?: Can't label (tokens*)

Steve Bennett stevagewp at gmail.com
Wed Dec 5 04:09:37 PST 2007


On 12/5/07, Brendon McLean <antlr at twistedprotein.com> wrote:
> I was wondering whether the labelling of parenthesised tokens should
> be allowed?
>
> Currently, you can construct a grammar like this:
>
> postincdec      :       varref op=('++' | '--') -> (^POSTFIX_EXPR $op)

Looks like what I did wrong in my previous post. How should one write this?

postincdec      :       varref (op='++' | op='--') -> ^(POSTFIX_EXPR $op)

(I assume you meant ^ before the other parentheses).

Incidentally, I find it odd that it's illegal to parenthesise the AST structure:

... -> (foo);

seems to be illegal.  It's not particularly useful, but you expect it
to be ignored.

Steve


More information about the antlr-interest mailing list