[antlr-interest] Difference between foo and #foo?

Martin Probst mail at martin-probst.com
Wed Mar 15 04:39:41 PST 2006

> what is the exact difference between the trees referenced by foo and #foo if 
> declared like this:
>   #( ... foo:children )

foo is just some Java text, and #foo is text that is supposed to be
handled by ANTLR. Meaning: if your action contains #something, ANTLR
will replace it with something, otherwise not. In your case in a
TreeParser (I assume) there is actually no difference because the AST
fragments are directly called "foo" and not "foo_AST" as in the parser
(where just using foo will give you a compile error).

I would think of this as a leaking in the abstraction, don't use 'foo'
as this behaviour might change in later versions.


More information about the antlr-interest mailing list