[antlr-interest] If BaseAST is derived from ASTNullType...? (Re: Does ANTLR *need* ASTNull?)

micheal_jor open.zone at virgin.net
Sat Mar 22 06:50:08 PST 2003


> > Hi,
> > 
> > I have run into an issue with ASTNULL and hetero-ASTs using Java 
as 
> > the target language (IIRC C# doesn't have ASTNULL and it isn't an 
> > issue with C++).
> 
> My comments about C# is inaccurate - it does have ASTNULL and hence 
> the same problem. 
> 
> In my limited analysis, ASTNULL seems to be used as a performance 
> optimization essentially. I guess my focus is now on ideas for 
> ensuring ASTNULL plays nice with hetero-AST usage.
> 
> Is anyone mixing TreeParsers and hetero-ASTs?. Any issues?.

The basic issue is related to the casting of the cursor variable _t 
of type AST to other variables of hetero-AST types. The problem is 
that this variable sometimes contain the value ASTNULL (of type 
ASTNullType). 

Hetero-ASTs are typically derived from the AST->BaseAST->CommonAST 
lineage which doesn't include ASTNullType. Hence the 
classCastException.

If the lineage is changed to:
AST->ASTNullType->BaseAST->CommonAST

...the problem might go away. Question is, what - if anything - does 
this break?

> > Specifically, there are a few situations where ASTNULL is 
assigned 
> as 
> > the value of a vriable then, an attempt is made to cast that 
> variable 
> > whose value is ASTNULL to an hetero-AST class ==> 
> classCastException! 
> > 
> > Why does ANTLR-Java need ASTNULL?. 

> This issue only arises with TreeParsers incidentally and I've 
> inherited a few I could do without ;-)
 
Cheers,
 
Michael



 

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



More information about the antlr-interest mailing list