[antlr-interest] Re: ANTLR for a compiler

lgcraymer lgc at mail1.jpl.nasa.gov
Thu Nov 4 21:45:18 PST 2004



--- In antlr-interest at yahoogroups.com, "Paul J. Lucas"
<pauljlucas at m...> wrote:
> On Thu, 4 Nov 2004, Bryan Ewbank wrote:
> 
> > I've been working on building a compiler - not a translator, but a
> > code-generating compiler - in ANTLR, and I'm getting frustrated.  I am
> > seriously thinking of abandoning ANTLR in favor of Bison simply
because of
> > the complexity of writing a tree parser
> 
> 	You don't *have* to write a tree parser at all in ANTLR.  In
> 	the action routines of your (non-tree) parser, you simply do
> 	what you would have done using yacc/bison.

Which is to build a parse tree manually, do a painful transformation
to a custom tree which is then converted to a graph for dataflow
analysis and optimization, transform the graph in one or more passes,
and generate code.

It is also worth noting that for ambiguous languages, the lex/yacc (or
flex/bison) approach often involves implementing feedback from the
parser to the lexer.  The resulting parser is pretty fragile from a
maintainability standpoint, but is tolerated because the language
grammar is pretty much fixed--the language being parsed is not subject
to reengineering except by a standards committee as a rule.  I should
note that lex/yacc is not commonly used in compiler construction--the
common approach is a manually constructed recursive descent recognizer.

> 
> 	Why do you want a tree parser?

Except for simple translation problems, trees and graphs are critical.
 Stallman's big achievement with GCC was RTL (Register Transfer
Language) for describing nodes, connections, and legal transformations
for GCC optimization.  That enables all of the GCC front ends (C/C++,
Fortran, Ada, ...) to share a common backend for each target processor
and for the GCC compiler suite to target a wide range of processors.

--Loring

> 
> 	- Paul





 
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