Re: Compiler construction...

Todd Jonker <>
Fri, 5 Feb 1993 20:27:46 GMT

          From comp.compilers

Related articles
Compiler construction in C++ and OOD (1993-02-03)
Re: Compiler construction in C++ and OOD (1993-02-04)
Re: Compiler construction... (Todd Jonker) (1993-02-05)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Todd Jonker <>
Keywords: C++, OOP
Organization: Compilers Central
References: 93-02-032 93-02-048
Date: Fri, 5 Feb 1993 20:27:46 GMT (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 . . .
. . . . . . Information Technology Center . . .

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.