Compiler Engineering Using Pascal

Peter Capon and Pete Jinks

Department of Computer Science, University of Manchester

Macmillan (now part of Palgrave) 1988; ISBN 0-333-47155-5

September 1998: Out of print. We hope to make the text available on-line - we are waiting to hear from Palgrave about the rights.


This book is aimed at anyone who is familiar with Pascal and wishes to discover how to construct a compiler. It emphasises a systematic, engineered and practical approach to compiler construction. It contains example compilers which can be used as a basis for experimentation and practical coursework.

In chapters 1 to 5 a complete compiler for a simple language is presented. The simple language is a small subset of Pascal. This compiler is written in standard Pascal and generates code for a simple hypothetical machine. An interpreter for the hypothetical machine code is also provided to allow compiled programs to be run. These chapters form a self contained introduction to compilers and can be read independently from the rest of the book.

In chapters 6 to 15 the organisation of, the algorithms used in, and the form of compiled code generated by a complete Pascal system are considered in some detail. The ideas introduced in the simple compiler are developed, extended and applied to the construction of a Pascal compiler. The use of compiler construction tools, such as LEX and YACC, is described with further examples. In considering the compiled code, sufficient detail is given to expose typical constraints imposed by real computers which can be overlooked in hypothetical examples. Examples are given for DEC PDP11 and Motorola MC68000 series processors.

The final chapter discusses the differences between a compiler for Pascal and one for Modula-2.

At the end of this text the hope is that the reader will have firstly, a thorough comprehension of the correspondence between high level programming language statements and machine instructions. Secondly, he or she should understand how high level language constructs are transformed or translated into machine instructions. Finally, the reader should be able to tackle a compiler construction project, should the need arise.

Course Material

You can download copies of the recursive (23K) and table-driven (lex & yacc) (30K) example P-to-M compilers Please email me to let me know if you do.

About the authors

Peter Capon is Senior Lecturer in Computer Science at Manchester University. His first major responsibility was the compiler target language and compiling system for the MU5 computer system. He subsequently took a leading part in the design of the MU6 system. He is currently concerned with the effective exploitation of parallelism in multi-computer systems and with the ParSiFal project which has constructed a reconfigurable system from Inmos transputers.

Peter Jinks is Lecturer in Computer Science at Manchester University. He designed the instruction set for MU6. He constructed code generators for MU6 and for the PDP11. He is a member of the ParSiFal project team researching the mapping of algorithms onto parallel hardware.