Back COMPILER DESIGN
by Reinhard Wilhelm and Dieter Maurer

Addison-Wesley Publishing Co. -
0-201-42290-5 * Hardback * 608 pages * ©1995


PREFACE

Compilers for high-level programming languages are large, complex software systems. However, they have a number of special characteristics which distinguish them from most other software systems.

Their functionality is (almost) well defined. Ideally, there exist formal, or at least precise descriptions of the source language and the target language. Frequently, there also exist descriptions of the interfaces to the operating system, to the programming environment, to other compilers and to program libraries.

The decomposition of the compilation tasks into subtasks with well-defined interfaces is well understood. This results in a natural modular structure, which, incidentally, is also reflected in the usual structure of books on compiler design.

Some of the various subtasks of compilation have been very extensively studied. The corresponding theories were developed specifically or taken over from the theory of formal languages and automata. They provide a good basis for the implementation of modules for compiler subtasks. For some of the subtasks, there even exist mechanisms for their formal description and generation procedures that generate parts of compilers automatically from such formal descriptions. Many such generators are available and in use.

This book is not a cook book. You will not find recipes of the form "to construct a compiler from source language X into machine language Y, take . . .". The presentation reflects the special characteristics of compiler design listed above, including, in particular, the existence of the theory and the automatic generation methods.

This book is intended for advanced undergraduate and graduate students specializing in computer science. A knowledge of imperative programming languages is a prerequisite. While the chapters on the compilation of functional, logic and object-oriented programming languages each contain a long introduction to the concepts of these language classes, it is advisable to learn a modern functional language, Prolog and Smalltalk, Eiffel or C++, for a better understanding of the corresponding chapters. In addition, the reader will profit from a good grounding in the theory of formal languages and automata, although the theory needed is always presented in full.

Stucture of the book

Chapters 2 and 5 describe what a compiler does, in other words, the correspondence that it generates between a source program and an object program. For this, we introduce an appropriate abstract machine for an imperative, a functional and a logic programming language and give a precise description of the compilation of programs in each source language into the language of the associated abstract machine. Object-oriented languages developed from imperative languages by extending them by a number of new comcepts which essentially relate to the type system. Thus, only the compilation of these extensions is described in Chapter 5.

In each case, the starting point is an analysed source program which we shall later refer to as associated decorated abstract syntax.

In Chapters 6 to 12 we describe the how of compilation, namely how the compilation process is divided into individual phases, the tasks performed by these phases, the techniques used in them, how what they do can be formally described and how a compiler module can be generated (even automatically) from such a description.

Material for a two- or three-term lecture course can be selected from this book, depending on the time available. Chapter 2 and material from Chapters 6-9, 11 and 12 would su±ce for a conventional one-term lecture course on the compilation of imperative programming languages. A two-term lecture course would cover the compilation of functional, logic and object-oriented programming languages together with areas of current research such as abstract interpretation and code generation for parallel target architectures.

Acknowledgements

The book developed from a number of lecture courses given by both authors at the University of the Saarland in Saarbrücken, Germany. The (then) three-term course was first given in 1987/1988.

The number of those who have actively cooperated in this work and/or provided constructive criticism of it is so large that we are unable to thank them all personally here. We are particularly grateful to Martin Alt, Ingrid Biehl, Christian Fecht, Christian Ferdinand, Reinhold Heckmann, Adreas Hense, Stefan Kahrs, Peter Lipps, Gudula Rünger, Georg Sander and Helmut Seidl. The TeXnicians Christine Wentz and Patrik Zeimetz have patiently processed several revisions.

Reinhard Wilhelm, Dieter Maurer April 1992

Preface to the English edition

The major change from the German edition is that a chapter on the compilation of object-oriented languages has been added, in which we discuss the implementation of simple and multiple inheritance.

Since the German edition is apparently extensively used, we have received numerous suggestions for improvements, for which we are especially grateful to Reinhold Heckmann, Helmut Seidl and, in particular, Helmut Partsch. Material related to this book, for example, a specification of an accompanying compiler laboratory project, can be obtained by anonymous ftp from ftp.cs.uni-sb.de in /pub/compiler.

Back Top

Reinhard Wilhelm, Dieter Maurer Saarbrücken, St. Ingbert, April 1995