------ Original Message (Tuesday, April 13, 2010 11:12:53 
AM) From: Sébastien Kirche ------
Subject: Re: [antlr-interest] CommonTree -> AST conversion ?
> Do you mean to generate the tree walker by writing a tree grammar on 
> top of my parser grammar, or am I missing an antlr feature ?
Yes, just write a simple tree pattern matcher and have Antlr generate 
the tree walker code.  Lots of examples and more explanation in Language 
Implementation Patterns 
<http://pragprog.com/titles/tpdsl/language-design-patterns>.  
http://www.antlr.org/wiki/display/ANTLR3/Tree+pattern+matching
>
> When I was talking about implementing a visitor, it was related to the 
> article « Manual Tree Walking Is Better Than Tree Grammars »[1]
There are valid points made in that article, but that is just not the 
best place to start.
> And it was also to see what is under the hood of the tree grammars, 
> like learning some assembly helps to understand the work of a C compiler.
Looking at the source of the C compiler would be far more sensible.
> And I also find quite ugly the mix of grammar code with java code : I 
> fear that when my grammar will grow the maintenance of the resulting 
> code will become hard.
Yes, best to minimize the mix.  You can either use the superclass option 
(http://www.antlr.org/wiki/display/ANTLR3/Grammar+options) or, better, 
set a helper class on the parser that can then be called from the actions.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to