[antlr-interest] When does AST construction go through factory?

Terence Parr parrt at jguru.com
Thu Jan 16 23:31:02 PST 2003


Hi.  ANTLR 2.7.2 should be out tomorrow or over the weekend.  It fixes 
this so that all AST creation goes thru the factory. :)

Ter

On Thursday, January 16, 2003, at 10:18 PM, Daniel Gackle wrote:

> Apologies if this has been discussed before.  I know there was a 
> thread on
> this a couple of months ago, but I can't find answers to my questions 
> in the
> archives.  I'm seeing different behavior with heterogeneous AST 
> creation.
> Sometimes the AST factory gets called and sometimes it doesn't.  For
> example, suppose IDENT is a lexer token whereas TYPE is an imaginary 
> token
> used in an action statement like ## = #(#[TYPE,"TYPE"], ##).  I map 
> each of
> them to a specific AST type:
>
> tokens {
> 	IDENT<AST=MyIdentifierNode>;
> 	TYPE<AST=MyTypeNode>;
> }
>
> What I'm seeing is that in one case the AST is created via the AST 
> factory:
>
> astFactory.create(TYPE,"TYPE")
>
> while in the other it is not:
>
> tmp277_AST = new MyIdentifierNode(LT(1));
>
> This seems to be foiling my attempts to intercept the creation of each 
> AST
> node by means of a customized AST factory.  My questions are:
>
> (1) When exactly does the AST factory get used, and when does new get 
> used
> instead? (Does it have to do with lexer tokens vs. imaginary tokens, 
> or is
> there some other criterion?)
> (2) Is this the desired behavior?  If so, why?
> (3) Any suggestions on a workaround that would allow me to "get at" 
> the AST
> construction of those non-factory nodes?
>
> Many thanks,
> Daniel
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco


 

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



More information about the antlr-interest mailing list