The XPL compiler generator system
Linux version Feb 15, 2015
This is a version of the XPL compiler generator System packaged to run on Linux.
History
The original code was developed in 1967 by William McKeeman and David B. Wortman at
University of California, Santa Cruz and James J. Horning and others at Stanford
University. Over the years it was ported to run on a variety of computer systems.
In 2000 David Bodenstab ported XPL to Intel x86 architecture with a FreeBSD version.
The current package is based on this version; only the XPL "submonitor" was rewritten.
In the process I did not include all of Bodenstab's extensions. The current version
is closer in spirit to the original. However, this would not have been possible without
Bodenstab's work In particular the C programs iAPX486.c iAPX486.h are all his original
work. Dave's package is at bodenstab.org.
Contents
- XPL.pdf is a PDFed version of the Wikipedia article on XPL
at http://en.wikipedia.org/wiki/XPL.
This provides a good overfiew of what XPL does.
- XPL_Language_Description.html contains a more
complete description of the XPL language (pages in "Language_Description). For the
definitive description of the language and how XPL is used see the book A Compiler
Generator by McKeeman, Horning, and Wortman.
- iAPX486.c and iAPX486.h are Dave Bodenstab's
x86 emulator code, used to trace execution of an XPL program.
- xcom.xpl is the XPL translator, as modified by Dave Bodenstab to
generate Intel x86 instructions; template.xpl is part of his
porting effort— an XPL program that generates instruction tables for
code generation. These programs are written in XPL.
- The PL/I programs xplsm.pli, hexdump.pli,
and xpl_trap_misc.pli represent my contribution to the package.
This is the XPL "submonitor". I have simplified Dave's version, removing some of his extensions
and restoring something close to the functionality of the original. These programs compile
with Iron Spring PL/I 0.9.8 and above. Most of the code is self-explanatory, however
"xpl_trap_misc" contains code to deal with the nonstandard use of the x86 register EBP
in generated XPL code. Normally EBP points to the current stack frame, which can be used
for debugging. XPL uses EBP to point to the current address in the XPL program, so
special code was required to reload the correct value in case of error.
- compactify.xpl, analyzer.xpl,
and alter.xpl are parts of the original XPL distribution.
hello.xpl is the ubiquitous sample program. These programs are
written in XPL.
- Compiled programs: alter, analyzer, and xcom are compiled versions of
alter.xpl, analyzer.xpl, and xcom.xpl respectively. These are in a special format and are not
directly executable. They need to be run vis XCOM. See description below for information
on how to run an XPL program.
"xplsm" is the Linux executable for the submonitor. "makefile" can be used to rebuild this
if desired. Rebuilding requires both gcc and Iron Spring PL/I.
- Miscellaneous files
- readme.html - this file
- run_xcom - a shell script to run the XPL compiler
- xpl.bnf - the BNF description of the XPL language in the format
required by analyzer. This can be copied and used as the basis for developing other
languages
- The directory"Language_Description" contains pages for the html language
description.
- The directory "Other_Versions" contains other versions of XPL. "xpl.zip"
is something close to the original System/360 version as distributed by the IBM users'
group SHARE. "xpl_dos.zip" is a PCDOS version of XPL by Andrew O. Makhorin, but unfortunately
without source. "xpl_multics.zip" contains a versopn of XPL for the Multics OS on
Honeywell 6000 hardware by Paul A. Karger, Fernando J. Corbató, and Jeffrey M. Broughton.
"xpl486-4.2.tar.gz" contains the sources for Dave Bodenstab's FreeBSD version. "XPL_S.zip"
contains some code from a version for Xerox Sigma CPV/BPM/BTM/RBM by Geoffery C. Leach
and Charles V. Codling.
Running XPL
The generic command to run an arbitrary XPL program is:
xplsm -p <program> [-i <input>] [-o <output>]' );
[-i1 <input1>] [-i2 <input2>] [-i3 <input3>]' );
[-o1 <output1>] [-o2 <output2>] [-o3 <output3>]' );
[-f1 <file1>] [-f2 <file2>] [-f3 <file3>]' );
[-t] [-d] [-m <maxmem>] [<parm data>]' );
- <program> is the name of the compiled XPL program to run.
- i<n> (n=1-3) identifies the names of text input files for the program. -i is the same as -i1.
- o<n> (n=1-3) identifies the names of text output files for the program. -o is the same as -o1.
The first output file, o1, is assumed to have printer "carriage control" which is interpreted
by the submonitor.
- f<n> (n=1-3) identifies the names of binary files used by the XPL program. If the program
uses these files and the names are not provided they are assumed to be work files and deleted
at the end of the program.
- t requests the program be run with trace initially active. Trace prints all x86 instructions
as they are executed. The trace toggle "/* $T */" in the source does not currently work.
- d requests a hex dump at the end of the program.
- m specifies memory to be used for data by the program. The default data storage is 64KB plus the
amount of data used initially by the program. This allows for expansion of string data.
- parm, anything which follows the other arguments on the command line, is a string passed as a
parameter to the XPL program. This may be up to 256 bytes including spaces.
run_xcom:
The shell script "run_xcom" runs the XPL compiler xcom to compile a program.
It takes a single argument, the name of the xpl input (without extension).
"./run_xcom prog" will compile a program "prog.xpl" and generate a compiled binary file "prog"
and a compilation listing "prog.lst".
run_analyzer:
The shell script "run_analyzer" runs the XPL grammar analyzer analyzer to process a grammar.
"./run_analyzer gram" will process a file "gram.bnf" and generate the xpl statements as
a file called "gram.dat" and a listing "gram.lst".
Rebuilding the submonitor
The PL/I code for the submonitor requires the Iron Spring PL/I compiler version 0.9.8 and above.
The C code requires GCC. the makefile will rebuild the entire submonitor, assuming the the PL/I compiler
and library are in system libraries, otherwise change "plic" and "libprf.a" to include the
paths to the compiler and the library.
Technical note
- The original XPL took advantage of the fact that System/360 architecture only used 24 bits
of a 32-bit address. An XPL character string was represented as a 32-bit value with the string
length in the high-order byte and the address in the low-order three bytes. This limits addresses
of strings to be below 2**24-1 or 16MB. The submonitor allocates the data area for an
XPL program from low memory, insuring that this is the case.
Peter Flass
Feb 15, 2015