[antlr-interest] Code Generation

John D. Mitchell johnm-antlr at non.net
Tue Feb 10 10:16:49 PST 2004


'netiquette nanny says: Trim your post so that it only includes what's
necessary to preserve the context for the readers.

>>>>> "Shomi" == Shomi Mahima <shomi_mahima at yahoo.com> writes:
[...]

> 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?

FYI, the term for what you're talking about in terms of generating code
directly as you parse the file is called "syntax-directed translation".
[Personally, I consider it to be an "S.T.D." if used for any serious,
non-trivial languages. :-)]


Are you talking about a compiler *for* the C++ language or that you're
going to be writing the ANTLR actions for your compiler *using* C++ (or
both)?

> 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 ?

The complete C++ language cannot be fully compiled to e.g., object code in
a strictly syntax directed manner (using any kind of automated translator
generators be they LALR, LL, etc.). [Of course, you may be "compiling" it
to some sort of smart, C++ "interpreter" but that would just be pushing off
all of the hard stuff to the interpreter.]

If you're compiling a language which can be fully compiled in a syntax
direct manner than certainly you can do that via ANTLR.


In terms of SDT vs. Trees, is there any reason besides "performance" that
you think you should do this project using SDT?

Thanks,
	John




 
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