[antlr-interest] Tree construction in Antlr

Oliver Zeigermann oliver.zeigermann at gmail.com
Fri May 14 07:29:16 PDT 2010


Hi Sergei!

The problem might be that in your grammar FirstToken is not a token,
but the name of a rule. You might want to create a new token, though?

FirstToken : Second Third
->
^( FIRSTTOKEN["firstToken"] Second Third)
;

Hope that helps!

- Oliver

2010/5/14 Sergei Smolov <ssedai at gmail.com>:
> Hello, everybody!
> I have a very simple question. For example, I have the following grammar
> rule:
>
> FirstToken : Second Third;
>
> And I want to generate the following tree from such rule (I mean Tree in
> Java terms):
>
>        FirstToken
>        /           \
>  Second      Third
>
> How should I rewrite my grammar rule? As far, as I understand, I can use '^'
> and '!' operators for it. But I don't understand how to make First Token a
> root of this tree.
>
> Thanks in advance
>
> --
> Sergey Smolov
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list