[antlr-interest] Tree construction in Antlr

Oliver Zeigermann oliver.zeigermann at gmail.com
Fri May 14 07:39:04 PDT 2010


Not quite sure if it has to be included in that secion, but it would
be good style in any case.

2010/5/14 Sergei Smolov <ssedai at gmail.com>:
> Thank you, Oliver, that helps me so much! FirstToken really not a token, but
> a name of rule.
>
> By the way, is it true, that FIRSTTOKEN must be included in "tokens {...}"
> block? Or I can avoid from that?
>
>
> 2010/5/14 Oliver Zeigermann <oliver.zeigermann at gmail.com>
>>
>> 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
>> >
>
>
>
> --
> Sergey Smolov
>


More information about the antlr-interest mailing list