[antlr-interest] Re: Anyone tried this ANTLR-inspired CC?

micheal_jor open.zone at virgin.net
Mon Nov 10 18:10:55 PST 2003


--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> 
> On Sunday, November 9, 2003, at 05:37 PM, leung13512c wrote:
> 
> > The thing that caused me to switch away from ANTLR syntax
> > is because I prefer the tree building syntax of JJTree that always
> > create imaginary nodes instead of a mix of both.  And it mostly
> > avoid having to create nodes within actions.
> 
> Howdy.  This is the old AST versus parse tree argument...Parse trees 
> are easy to generate (i.e., no cost to developer) but have way too much 
> noise for tree transformation and also are sensitive to grammar 
> construction whereas ASTs are the canonical repr for a particular 
> language.

Hmmm. If you are saying ANTLR generates a CST (aka. parse tree or
concrete syntax tree) by default and the JJTree way is to generate an
AST, you may be right Ter.

Now, generating an AST rather than a CST is easily done in ANTLR with
custom tree-building actions. This should be doable with
implementation language-agnostic syntax in ANTLR 3. That leaves
visitors...

Despite the elegance and utility of the treeparser-from-grammar
feature, it may be prudent to provide support for auto-visitor
generation *also* with ANTLR 3. One big issue is that, ANTLR's AST
interface isn't particularly custom, hetero-AST friendly and, getting
to play nice with the visitor model seems to need custom hetero-ASTs.
So we get into, attributed ANTLR grammars and {ANTLR-driven}
attributed grammar processors that read the grammar and generates AST
nodes classes and visitors in addition to the Lexer/Parser/TreeParsers.

Cheers,

Micheal



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list