[antlr-interest] Difference between foo and #foo?
Michael Brade
brade at informatik.uni-muenchen.de
Wed Mar 15 05:34:49 PST 2006
On Wednesday 15 March 2006 13:39, Martin Probst wrote:
> > 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.
Yup. So far, so good. But since ANTLR generates both variables, i.e.
AST foo_AST = null;
AST foo = null;
in every method for every label, I thought it has to have a reason.
> 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).
Thanks for your answer, in the meantime I sat down and tried to understand the
generated code---successfully :-) So no, it's not the same: foo == #foo_in!
So no wonder I didn't understand my results, in case you forget the '#', what
you get is not the output tree but the input tree for that rule.... creepy ;)
Cheers,
--
Michael Brade; KDE Developer, Student of Computer Science
|-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
°--web: http://www.kde.org/people/michaelb.html
KDE 4: Beyond Your Expectations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060315/38368f11/attachment.bin
More information about the antlr-interest
mailing list