[antlr-interest] Re: Code Generation

lgcraymer lgc at mail1.jpl.nasa.gov
Tue Feb 10 14:42:43 PST 2004


--- In antlr-interest at yahoogroups.com, Shomi Mahima <shomi_mahima at y...> wrote:
> The grammar that iam using is that of C++. 
> What i meant was, instead of generating an AST and then walking the tree down to Emit the machine code(MSIL of dotNET, using 
the Reflection.Emit API) , can i straight away emit the instructions within the actions in the grammar file? 
>  
> Will it be  an effective approach?

As Ric and John point out, C++ is a difficult language and even the industrial-grade compilers don't always do the right thing.  Even if 
you want to do direct code generation, you are better off starting out building ASTs and going through multiple tree transformation 
steps to handle preprocessing, templates, and the function versus object initialization ambiguity.  Once you have developed a good 
understanding of the translation problem, then you might be able to rework or eliminate some of the transformation steps--but I would 
not bet that that will be possible.  Your biggest problem is going to be to get the translation working correctly.  That is a big enough 
problem that you probably cannot afford to worry about performance until you have a working translator.

--Loring



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list