[antlr-interest] CommonTree & Tree grammar versus DIY
Szczepan Hołyszewski
rulatir at wp.pl
Fri Aug 15 18:33:01 PDT 2008
Andy Tripp wrote:
> Right. Whoever writes the doSomething() method shown above is going to
> have to know what the AST looks like, regardless of whether the
> doSomething() call is embedded in a treewalker.g file or plain old code.
That's exactly the problem. Whoever writes the doSomething() for a processing
pass that is only interested in 3% of the language constructs, will have not
only to know, but also to painstakingly express with tree rules, what the AST
can possibly look like from the start symbol to wherever the relevant
constructs can appear in the grammar. This essentially duplicates a large
chunk of the parser grammar. There is no simple way to tell ANTLR to
doSomething() e.g. for each type definition, regardless of whether it occurs
at top level, in a class, in a function, in an anonymous code block buried
deep in a lambda expression, or in that fifth possible place where the draft
0.0.2 specification will allow type definitions to occur.
Szczepan Holyszewski
More information about the antlr-interest
mailing list