|Compiler construction in C++ and OOD firstname.lastname@example.org (1993-02-03)|
|Re: Compiler construction in C++ and OOD email@example.com (1993-02-04)|
|Re: Compiler construction... firstname.lastname@example.org (Todd Jonker) (1993-02-05)|
|From:||Todd Jonker <email@example.com>|
|Date:||Fri, 5 Feb 1993 20:27:46 GMT|
firstname.lastname@example.org (Vivek Buzruk) writes:
> [Is a] compiler.. a good application for O-O design?
Cliff Click writes:
> My research compiler is written entirely in C++ (except for the front-end
> parsing stuff). I find the O-O issues immensely helpful. I have class
> definitions for all the interesting internal data structures: hash tables,
> symbol tables, instructions, etc. The complexity control C++ gives me is
> a BIG win.
I too am writing a compiler in C++, including the frontend. Each AST node
is a class, with two main methods: Analyze and Emit. These correspond to
two `passes' of a traditional compiler architecture. I am often amazed at
how easily I can incrementally extend the language with new
syntax/semantics. Just define a new class and write a couple routines.
Once the framework is in place, adding constructs is a piece of cake.
I am using my own parser-generator which constructs an AST node when a
production is matched. Thus, the C-code that usually sits in the YACC
file is instead part of the class constructor methods. This in turn keeps
my grammar description code very clean, and MUCH easier to create and
maintain that LEX/YACC. Another big win.
> Obviously one can not go away from traditional phase structured design
> to define the functionality of a compiler.
As I indicated above, in my design the various phases are replaced with
tree-walks performed via virtual function calls.
. . . Todd V. Jonker . . . . . Carnegie Mellon University . . .
. . . email@example.com . . . Information Technology Center . . .
Return to the
Search the comp.compilers archives again.