[antlr-interest] Code Generation

Ric Klaren klaren at cs.utwente.nl
Tue Feb 10 04:31:52 PST 2004


Hi,

On Tue, Feb 10, 2004 at 03:17:03AM -0800, Shomi Mahima 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?

My first impression would be that with C++ as input language there's no
chance to support the full language in one pass. Instantiation of templates
and probably some other things with operator overloading will require a lot
of non-trivial processing.

C++ is very nasty to parse. Terence & David can probably give you more
advice on parsing C++.

> Will it be an effective approach? If it were a LALR parser , I'll generate
> the code when i make a reduce actions .In LL parser should i have to
> separate a module for codegeneration ?

I doubt wether that will work in one pass with a LALR parser as well. Again
it depends on how much of the C++ language you need to generate code for.

(Or am I misunderstanding you and you want to use antlr in C++ mode for
your project e.g. have antlr generate C++ files you compile and then
generate for you specific problem (not C++ as input) code)

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
     Innovation makes enemies of all those who prospered under the old
   regime, and only lukewarm support is forthcoming from those who would
               prosper under the new. --- Niccolò Machiavelli



 
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