Make your own free website on Tripod.com

In this article, a simple generic compiler is specified. A generic compiler is a compiler which outputs source code for a set of programming languages rather than just for a particular one. Each language is specified by a grammar.

Our compiler will operate in 4 phases:

  • Lexical Analysis Handles of the input stream and produces the tokens of the stream.
  • Parsing (in this case top-down, recursive descent parsing) Handles the tokens and produces a parse tree from them.
  • Syntax Analysis
  • Semantics Analysis
  • Code Generation

With the objectof of keeping this article short, the GenericCompiler will be not do any error recovery or code optimisation.

We define the package GenericCompiler like this:

All class diagrams, use cases can also be found here (visio format).