[antlr-interest] parse tree construction

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Aug 25 11:54:39 PDT 2009


Safiye Celik wrote:
> Hi
> I wanna ask one more question about parse tree construction..
> I have such a rule:
> 
> x: A B (C A B)* and I have to create such a tree for it:
> 
>                                         B
>                                      /  |  \
>                                    A    C    B
>                                           /  |  \
>                                         A    C    B
>                                                /  |  \
>                                              A..  C.   B......and
> continues like that. (The leftmost a B is in the rule, the closest it is to
> the root of the tree.This is true also for other tokens)

x : A B^ (C x)?;

(Martijn's solution as corrected by John Brodie also works, I think,
but this is much simpler.)

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the antlr-interest mailing list