[antlr-interest] Re: Simple Question

Tiller, Michael (M.M.) mtiller at ford.com
Tue Jun 17 05:47:32 PDT 2003


I am using C++ as my target language.

I'm quite busy working on this parser/treewalker and I don't really have the time right now to isolate some code that demonstrates this.  I'm pretty confident that this is a bug (or at least an undesirable feature) and I will try to put something together to demonstrate it in the future.

I should point out that several people have asked questions about whether my custom AST is a proper baseclass, whether I am properly initializing my AST factory (I know it has changed in 2.7.2), am I compiling things in the right order, etc.  Keep in mind that the bug manifests itself during the parser construction phase (by creating a bogus initializeASTFactory).  In other words, this is not a compile time or run time issue so none of my C++ code has any impact on this issue.  The issue is in the ANTLR code generation phase.

I'll try to provide a complete example when/if I can.

--
Mike

> -----Original Message-----
> From: micheal_jor [mailto:open.zone at virgin.net]
> Sent: Monday, June 16, 2003 8:38 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: Simple Question
> 
> 
> <SNIP>
> 
> > modelica_file
> >     : (within_clause)? (("final")? class_definition SEMI!)* EOF!
> >         { ## = #([FILE, "FILE"], ##); }
> >     ;
> > 
> >  
> > Note, specifically, the use of "#([FILE, "FILE"], ...)"
> 
> <SNIP>
> 
> > tokens {
> >     FILE<AST=FileNode>; DECLARATION; DEFINITION; FUNCTION_CALL; 
> TYPE;
> >    ...
> > }
> >  
> > Note the "File<AST=FileNode>..." part.
> 
> > So, is my assessment correct (i.e. this feature doesn't work with 
> synthetic nodes...of which I have *many*).  Or am I doing something 
> wrong?
> 
> Mike,
> 
> You didn't mention which language you are using so this is a rather 
> generic answer by neccesity:
> 
> In the scenario above, the ANTLR codegen *should* have created a node 
> for your imaginary FILE tokenID using an instance of the FileNode 
> class (I assume that this class correctly implements the AST 
> interface). IOW, you don't seem to be doing anything wrong...*
> 
> [* More access to your grammar might change this opinion however ;-)]
> 
> There is [at least?] another way to declare a custom class for an 
> imaginary AST node. You can use the [<TokenID>, <TokenText>, 
> <TokenClass>] form of the ANTLR node constructor syntax. E.g.
> 
>      {  ## = #([FILE, "FILE", "FileNode"], ##);  }
> 
> Cheers,
> 
> Micheal
> ANTLR/C# codegen
> 
> 
> 
>  
> 
> 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