[antlr-interest] CommonTree -> AST conversion ?

Sébastien Kirche sebastien.kirche at gmail.com
Tue Apr 13 02:12:53 PDT 2010


Le 12 avril 2010 21:40, Gerald Rosenberg <gerald at certiv.net> a écrit :

>  ------ Original Message (Monday, April 12, 2010 8:16:53
> PM) From: Sébastien Kirche ------
> Subject: [antlr-interest] CommonTree -> AST conversion ?
>
> Could someone correct my code or point me an example more complete that the
> code snippet that is mentioned in the wiki ?  And could you point me some code for a custom tree walker?
>
>  Just use Antlr to generate a sample tree walker.  The generated code is
> quite readable and will be an example specific to your AST.
>
> I have read some mentions about implementing a visitor pattern, it that the regular way ?
>
>
>  The regular way is to just use a generated tree walker.
>

Thanks for your feedback, but I am not sure to understand clearly :)
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 ?

When I was talking about implementing a visitor, it was related to the
article « Manual Tree Walking Is Better Than Tree Grammars »[1] and have
also seen a mention of it by Terence Parr in the mailing list archives. 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. 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.

Thanks for your support.

[1] http://antlr.org/article/1170602723163/treewalkers.html
-- 
Sébastien Kirche


More information about the antlr-interest mailing list