Pascal-P: The portable Pascal compiler


Niklaus Wirth's team in Zurich produced two compilers for the original language Pascal. One was the CDC 6000 series compiler, which is documented here. The other was the Pascal-P compiler/interpreter. The difference was the CDC 6000 compiler produced object code for the CDC 6000 computers in a single step, single pass compiler, and was thus tied to that machine. The Pascal-P compiler was specifically designed to be portable to many machines, and to enable the creation of new Pascal implementations.

The trade off was that Pascal-P didn't generate object code for any real machine, but rather interpreted the output code. In addition, it was designed to both compile a subset of the full Pascal language, and also be written exclusively in that subset. The reason for the latter was primarily that the machines available in the 1970's were memory limited, and bootstrapping a new compiler, which often involved generating and using non-optimal code, required a lot of memory. Having a compiler that only processed a subset of the language allowed it to be bootstrapped on a memory limited machine, then brought up to full compliance after it was running.

Unfortunately, this also created a defacto language consisting of the Pascal-P subset of Pascal. Many implementers never added back the full Pascal language to their implementations, and the lack of an example of how to implement advanced features of Pascal in Pascal-P didn't help. The Pascal-P "language" persists today. Borland/Delphi retained most of the Pascal-P limitations because it started out based on the UCSD system (abet loosely).

Pascal-P occupies a special place here because, unlike the CDC 6000 compiler, it can be compiled and run on available machines today. Whereas the CDC 6000 compiler has only a past, the Pascal-P compiler/interpreter has a past, a present, and increasingly, a future.


Versions of Pascal-P


The Pascal-P compiler was created in 1973, then went through several versions, which so far have not been available. Ch. Jacobi gives an overview of the Pascal-P versions in PUG newsletter #4:

Pascal P1: Either of the early Pascal P systems (released in March and July 1973 respectively)..

Pascal P2: The Pascal P system released in. May 74.

Pascal P3: The new Pascal P system with the same hypothetical machine as the one underlying the Pascal P2 system.

Pascal P4: The new Pascal P system with a slightly modified hypothetical machine (allowing a more efficient implementation) .

The versions of P1 that existed have (so far) not been available. The revised version, P2, is available, and was used as the basis for the UCSD system. P3 was a "step" implementation used to bridge between P2 and P4, and is also not obtainable.

The last major version of Pascal-P was P4, and that was the most famous (or if you prefer infamous) version. This version would have been referred to as Pascal-P4.


P5 and beyond


Pascal-P4 left off as a subset of the full Pascal language, and it came about years before the ISO 7185 standard. The first step to get p4 running today was to upgrade P4 to ISO 7185 status. It is important to separate the language status of the source code from that of what the compiler generates. Having the source obey ISO 7185 conventions means that it can be compiled and run today. The result would still not compile for ISO 7185 conventions. Indeed, P4 in this form does not compile the language Pascal at all, but a subset of it, as per its design.

The update of P4 to ISO 7185 in this way was fairly simple. In fact, it mainly involved changing the segmented file handling methods of the CDC 6000 implementation to standard Pascal, and the segmented file handling was never part of the language Pascal.

The next obvious step was to have P4 handle the full language Pascal. The original reason for making P4 a subset compiler no longer exists. Memory is no longer in short supply, and even fairly inefficient versions of P4 can be made to run easily. The obvious name for such a version was the Pascal-P5 compiler/interpreter, and such a compiler was created after the ISO 7185 standard came about, on or before 1986.

The "Model Implementation of Standard Pascal" is an interesting compiler/interpreter, which mixes the full documentation for the system into the source as comments. It not only implements the full ISO 7185 Pascal language, but acts as a example implementation of all of the requirements of ISO 7185 Pascal (hence the "model implementation"). It is available only in book form:

A Model Implementation of Standard Pascal. Hardcover.

A Model Implementation of Standard Pascal. Paperback.

Unfortunately, the "Model Implementation" disappeared into the BSI or British Standards Institute, where many other important Pascal historical documents have gone. The books bear various vague threats of copyright protection from the BSI, enough to discourage scanning and entering the source of the compiler from the books (just the job of scanning and fixing the resulting source would be massive).

The next possibility for P5 is the most obvious. It is the straightforward improvement of the P4 compiler/interpreter to full Pascal language status. This was done by me in a few weeks, and the result is here. P5 shares the same documentation and virtual machine as P4, abet with improvements. It is perhaps %30 larger than the original P4 (and this includes adding the entire table of error messages).

While working on P5, it became obvious to me what the future version of the Pascal-P system would be, using the same step by step bootstrapping methods that the original Pascal-P implementers did.

Pascal-P6 will be an extended version of Pascal, written in unextended Pascal. Although it might seem odd to have a compiler that is written in a subset of the language it processes, it is a common theme in Wirth's compiler series, and forms the basis of the bootstrap method. Although there are many possible language extensions to use, Pascaline is the ideal language for P6. It is both current with programming trends (featuring objects, modules, namespace control and parallel programming constructs), and at the same time represents a minimal increment to original Pascal. P6 can be constructed for the most part without the use of any element outside of ISO 7185 Pascal (even objects can be interpreted using ISO 7185 Pascal), and the calls that cannot, such has for file handing, can be left to stub routines that are easily changed for a particular implementation. Thus, P6 will form an ideal extension basis that can be bootstrapped on any ISO 7185 compiler.

Lastly, P7 ends the series as an extended Pascal compiler that is also written in extended Pascal. I suspect that P7 will never be written, simply because it will not be needed. P6 will adequately fill the requirements.


Pascal-P Versions Available Here


Pascal-P2

Pascal-P4

Pascal-P5


For more information contact: Scott A. Moore samiam@moorecad.com