The P5 compiler


The P5 compiler has existed for a long time as an idea. P4, the last of the Zurich series P-system compilers, left off before the ISO 7185 standard in 1982. It was not only not standard Pascal compliant, it also only a subset, abeit a substantial one, of full revised Pascal. As an example, or "model" implementation of Pascal, it would have made sense to update the compiler to ISO 7185 status, and that was basically done as "A Model Implementation of Standard Pascal" [Welsh&Hay] before 1986. In fact, the project was designed to support the ISO 7185 project.

However, there were a few reasons that a true P5, a straightforward update of the old p4, was a good idea. First, the source code of the "Model Implementation" is not generally available. Second, the "Model Implementation" is a complete scratch rewrite of the compiler, and shares virtually nothing in common with the original P4. This was important because several books, articles and online resources exist for the P4 compiler

What I wanted for p5 was a compiler that both accepted ISO 7185 standard Pascal, and was also written in it. The compiler is an extended version of P4 and uses the same intermediate codes where possible.

P5 is somewhat of a work in progress. It now accepts the full ISO 7185 language, and has passed a test suite based on that. However, the next major step is to overhaul the back end of the compiler so that it is reasonably efficient for today's machines. For example, I extended the string length to 80 characters to get reasonable programs to compile, but the back end really stores 80 characters for each string, regardless of if they are used. The goal is to make the system not just work, but be reasonably efficient.

The long term goal is also to be able to get P5 to self compile. Stay tuned.

Compiler source

Assembler/interpreter source

Compiler Windows binary

Assembler/interpreter Windows binary

P5.bat - A program to run both passes on the code.

I'll be publishing more details on the P5 system as time goes on.


Compiling and using P5


The P5 compiler/assembler is much easier than P4 in one respect. There are no limitations to remember verses ISO 7185 Pascal. If it is legal Standard Pascal, it will compile and run.

Unlike p4, P5 accepts all of its files as parameters. Use the following format:

pcom source.pas intermediate.int

pint intermediate.int program.out

All files must be specified. The compiler uses IP Pascals ability to connect program header files to command line filenames.


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