[antlr-interest] Re: Modification of Node Attributes using Tree Grammar

lgcraymer lgc at mail1.jpl.nasa.gov
Fri Jun 14 14:03:18 PDT 2002

--- In antlr-interest at y..., Ric Klaren <klaren at c...> wrote: 
> This is what C++ codegen does in 2.7.2aX . Still waiting on 
Terence's go
> for porting this to java codegen.


> > --right now, the grammar processor passes class 
> > information to the AST factory for every AST creation, and 
> > in actions bypass the grammar processor's knowledge. 
> Indeed the astfactory is not the only pitfall in the current 
> ast implementation. If you decide to use heterogeneous AST's be sure 
> read the generated code for correctness. 
> Oh boy this stuff is *so* broken. C++ mode may currently do 
> better than java. But AFAIK hardly anyone is using this stuff, else 
> would see much more questions about it.


I've fixed the AST bugs in the Java version--the original 
implementation specifies variables as being of class CommonAST or 
<specialAST> or whatever; if your declare them as "AST" (generic) and 
fix the typecasting, you can avoid the type coercion problems (you 
don't have to read the code; the compiler complains and the 
corrections are pretty obvious).  I haven't looked at the C++ 
implementation, but I assume that you've got something equivalent to 
the AST interface (the code generator needs only generic AST 
functionality except for AST creation).  There are also a couple of 
bugs in the tree generation which I had to fix.  My version of ANTLR 
uses heterogeneous ASTs to generate tree grammars, so I had to make 
that work.  I'll be able to make my extensions (and bug fixes) 
available Real Soon Now--mostly the delay is that I haven't had time 
to take the last few steps in the release process.


> I'm repeating myself (probably :) ) that we either should implement 
> right (C++ and Java), or remove it altogether. Or put a big sign on 
it with
> big friendly fuzzy letters with *beware*. Interaction between action
> parsers (the stuff generating the #i #( .. )) and the real parser is 
> for an overhaul)
> In short... Use heterogeneous AST's if you feel lucky/adventourous.
> Cheers,
> Ric
> --
>     ---- Ric Klaren ----- klaren at c... ----- +31 53 4893722  ----
>   "I don't have anything against Java - it's the best damn 
>               of UCSD Pascal ever released..." --- Larry Smith


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

More information about the antlr-interest mailing list