[antlr-interest] manual AST construction: what am I doing wrong?

Jorge Scandaliaris j_scandaliaris at yahoo.es
Mon Jun 16 08:05:50 PDT 2003


Hi, 
Yes, I have a single AST type, but I was thinking in moving to
heterogeneous AST (I have defined my nodes to contain all info I could
possibly come across in the grammar, but they are 90% of the time left
empty). I guess for the moment I'll lose in efficiency until I get this
going, and more now that you point this out.
It seems it's no so common to use this approach, eh?

Jorge

> -----Original Message-----
> From: Tiller, Michael (M.M.) [mailto:mtiller at ford.com]
> Sent: Monday, June 16, 2003 4:59 PM
> To: 'antlr-interest at yahoogroups.com'
> Subject: RE: [antlr-interest] manual AST construction: what am I doing
> wrong?
> 
> I wanted to point something out about this response...
> 
> > -----Original Message-----
> > From: Ric Klaren [mailto:klaren at cs.utwente.nl]
> > Subject: Re: [antlr-interest] manual AST construction: what am I
doing
> wrong?
> >
> > On Sun, Jun 15, 2003 at 01:26:35PM +0200, Jorge Scandaliaris wrote:
> > > 	How can I generate for a rule a single AST node, using manual
> > > tree construction?
> >
> > In a nutshell:
> >
> > myrule ! : st:SOME_TOKEN
> > { ## = #([MY_IMAG_AST_NODE, st->getText()]);
> >   ##->setSomeAttrib( sumthin );
> > }
> > ;
> 
> I think you need to be careful here.  As I pointed out in a question
> posted to this list (but never responded to), this does not work in
> certain cases (at least I couldn't get it to work).  The idea of
having a
> line like:
> 
> ##->setSomeAttribu(sumthin);
> 
> is to invoke a method on the custom AST node.  BUT, ANTLR will not
> generate an appropriate initializeASTFactory in some cases (see my
> previous note titled "Simple Question") and this would then fail.
> 
> I'm not saying there is anything wrong with Ric's response, just that
it
> should come with some caveats about making sure that the
> "#([My_IMAG_AST_NODE...])" construct is truly generating the
appropriate
> node type.
> 
> Jorge seems to be using a single AST type so this wouldn't appear
trigger
> the issue I reported, but without a complete example of his grammar,
you
> never know.
> 
> --
> Mike
> 
> 
> 
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/



 

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




More information about the antlr-interest mailing list