next up previous contents
Next: 5.1 Software interface Up: RFM Manual: Compiling RELFUN Previous: 4.7 EBNF syntax for

5 The code generator

  The basic idea of the code generator is to keep it as simple as possible to allow an easy replacement of the GWAM by another abstract machine. The classified clauses should be considered as a `machine-independent' representation of RELFUN procedures. It was not necessary to modify the code generator when proceeding from Nystrøm's WAM to our GWAM and C-based emulators.

The internal program structure of the code generator resembles the structure of the EBNF syntax. Therefore, in the following we give the EBNF syntax and the corresponding LISP functions.

The idea is to associate with each nonterminal symbol a function returning code for the corresponding construct; the returned code is appended to the already existing code. This ensures a (more or less) functional structure of the code generator. To avoid possible performance problems of the code generator, all calls to the expensive append are encapsulated in the macros doappend and addcode, where they could be replaced by cheaper nconc calls.

In this section the functions and macros of the code generator will be introduced. The descriptions of the function's parameters will not be given, so the reader should consult the source code, although the variable names should be self-explaining.

The source of the code generator has been written in a very functional style using only a small subset of COMMON LISP, having in mind a simple reimplementation of the code generator in RELFUN. Thus, we make extensive use of CONDs instead of using ecase, jump tables, and other specialities COMMON LISP is offering.





Harold Boley (boley@informatik.uni-kl.de)