Crelier R. OP2: A Portable Oberon-2 Compiler

« Abstract

A portable compiler for the language Oberon–2 is presented. Most related works pay for portability with low compilation speed or poor code quality. Portability and efficiency have been given the same importance in our approach. Hence, an automated retargetable code generation has not been considered.

The compiler consists of a front–end and a back–end. The front–end does the lexical and syntactic analysis, including type checking. It builds a machine–independent structure representing the program. This structure is made up of a symbol table and an abstract syntax tree, rather than a stream of pseudo–instructions coded in an «intermediate language». If no errors are found, control is passed to the back–end which generates code from this intermediate structure. This structure clearly separates the front–end which is machine–independent from the back–end which is machine–dependent. While the front–end can remain unchanged, the back–end has to be reprogrammed, when the compiler is retargeted to a new machine.

This compiler has been successfully used to port the Oberon System onto different computers. Code generators have been implemented both for CISC and RISC processors. Differences in processor architectures are reflected in the complexity of the back–end, the generated code density and performance. The compiler is written in Oberon. New compilers have therefore to be first compiled on an already working Oberon System. If such a system is not available, a version of the compiler whose back–end produces C code may be used for the bootstrap.

The compilation techniques presented here are not restricted to Oberon compilers, but could be used for other programming languages too. Nevertheless, Oberon and OP2 tend to the same ideal: simplicity, flexibility, efficiency and elegance. »

© 2005-2024 OberonCore и коллектив авторов.