[antlr-interest] Bug in ANTLR-3.1.2 with tree grammar wildcard list label x+= ?
Gavin Lambert
antlr at mirality.co.nz
Sun Mar 1 02:32:54 PST 2009
At 20:40 28/02/2009, Gary R. Van Sickle wrote:
>Bug or feature though? It seems inconsistent for what appear
>to be two semantically equivalent constructs to be totally
>fine in the one case and a silent failure in the other.
I consider it to be a bug in the ANTLR compiler, that it doesn't
actually tell you "you can't do that", but I don't think it's a
bug that you can't do that (if that makes sense) :)
Tokens are fairly simple beasts, and a label on a token is
invariably referring to the token itself, which you can then use
to insert into an AST, or get its text, or position, or whatever.
Rules are more complex, though, since rules consist of a
collection of tokens, which have their own positions, and can also
contain a subtree or a template fragment, as well as parameters
and return values. That's why the storage type of the label is
context-sensitive, and varies depending on which rule you use it
on. And that's why it's only safe to reuse a label name on a rule
of the same type as it was previously used on.
It's still an advance over ANTLR v2, which didn't let you reuse
label names at all :)
More information about the antlr-interest
mailing list