[antlr-interest] CommonTree & Tree grammar versus DIY
Andy Tripp
antlr at jazillian.com
Fri Aug 15 08:12:15 PDT 2008
Marc,
This "writing by hand" article is referring to walking a tree-like data structure (the AST).
Pretty much every programmer already knows how to do this by hand:
void walk(Tree t) {
doSomething(t);
for (Tree child: t.children()) {
walk(child);
}
}
By contrast, there are only a handful of people who know how to do that same thing
with an ANTLR treewalker.
The "manipulating an AST" work of building a translator is quite a different
job than the "build a lexer/parser" part of it.
Andy
Marc Bischof wrote:
> Hello Andy,
>
> in your article you wrote:
>
>> I think the approach that you'll prefer depends on your background. If you're
>> already intimately familiar with the ":", "[". "]", "*" , "{", "}", and ";"
>> constructs in the first approach, you will prefer the terse approach. On
>> the other hand, if you don't want to be bothered with all that "extra
>> syntax", you'll prefer the more verbose "plain Java" approach.
>
> I think, if someone is not familiar with grammar stuff and has not the
> background for writing translators, the last thing he/she should do is
> writing it by hand.
> ...may be to get familiar with it, but not for a productive solution.
>
> Cheers Marc
>
More information about the antlr-interest
mailing list