Pascal Implementation: A Book and Sources

New: the complete online text of a new edition of the book.

Included here is the Pascal source of a public-domain Pascal compiler and interpreter, the P4 compiler and interpreter. It is coded entirely in Pascal, and produces a high-level so-called intermediate code as output. The program 'pint' is an assembler and interpreter for this language.

The entire compiler and interpreter is documented in the book:

Pascal Implementation: The P4 Compiler and Interpreter, by Steven Pemberton and Martin Daniels, Ellis Horwood, ISBN: 0-13-653-0311 (also available in Japanese).

It was distributed by John Wiley in other countries, but now that Prentice Hall has taken over Ellis Horwood, that will have changed.

Steven Pemberton is contactable by email as He did not write the compiler, only documented it in the book.

What you have to do to use this compiler

For instance, do this once:

and for each program:

You have to supply input to pint, even if the program doesn't read from it, for instance:

If you intend to compile pcom with itself, there are two lines that have to be commented out when you do; search for the word 'comment' in the pcom source. There is no reason why you should want to compile pint.p with pcom.

What If You Haven't Got a Pascal Compiler?

Differences with the Book

The code here is slightly different from that in the book, but the line numbers have been kept the same. The changes were to allow modern Pascal compilers to compile the source (there were some laxities in the original code).

The Compiler Source
The Interpreter Source
The Differences with the book

Last modified: Wed Apr 13 14:40:57 CEST 2011