Ari Lamstein and Peter Selinger
The PPL compiler was written by Ari Lamstein under the supervision of Peter Selinger as part of a UROP project in the Winter of 2000, and as part of an REU project in the Spring of 2000, at the University of Michigan.
PPL is an extension of the call-by-name lambda calculus with integers, booleans, let and let rec bindings, products and sum types. The type system of PPL is ML-polymorphism. The syntax of PPL terms M,N is as follows. Here reserved words and symbols are shown in red, n and j are integers, and x is an identifier.
The PPL compiler translates closed PPL terms into an idealized
assembly language. This idealized assembly language differs from
actual assembly language in several respects: it allows for an
infinite number of registers, and it has opcodes for certain
high-level operations, such as allocation and exit, which would
normally be realized as system calls. For reasons of portability, the
``assembly code'' generated by the PPL compiler is actually realized
as a set of pre-processor macros in the C language; thus, the output
ppl can be compiled by any
C-compiler on the target machine.
ppl filename, where
filenameis a file which contains a PPL program. The compiler will read the program, write its most general type to the terminal, and write its assembly code translation to a file. PPL accepts the following command line options:
||Do not compile; parse and type-check only.|
||Print CBN reduction sequence.|
||Reduce term to CBN normal form.|
||Create optimized compiled code.|
Print additional type information depending on |
||Read input from terminal.|
||Write output to terminal.|
||Write output to specified file.|
||Print help message and exit.|
||Print version info and exit.|
--parseflag will cause the compiler to read and type-check a PPL program but not compile it. The
--stepflags cause the compiler to apply CBN reduction to the input term. In
--reducemode, the final normal form is printed, whereas in
--stepmode, the entire reduction sequence is printed, one term per line. The
--typeinfo modeflag alters the amount of type information that is displayed to the terminal.
modemust be one of
letor an integer nesting depth n. The compiler then gives type information on, respectively, no variables, all variables, all variables defined on the top-level, variables defined only by let and let-rec constructs, and variables defined up to a depth of n. The
--untypedflag causes the compiler to not type-check the PPL program. The
--optimizeflag will cause the compiler to beta-reduce certain redexes before compilation, yielding more efficient assembly code.
--output filename flags affect where the compiler
looks for input and where it writes the output. When using the
--term flag one may find it useful to enclose the term in
quotation marks. This will prevent shell substitutions.
--help flag provides a list and brief description of
all PPL options. The
--version flag gives information on
which version of the compiler is in use.
There is also a graphical user interface for PPL called
ppli. It is written in Tcl/Tk. In Unix, it can be
accessed by typing
wish ppli at the command line.
ppli provides a window to type a PPL program or load a
program from a file, together with various buttons for compiling,
reducing, and stepping through the reduction sequence of a term.
Theory and Implementation of a Functional Programming Language, Rose-Hulman Institute of Technology Undergraduate Mathematics Journal 1(2), 2000. (DVI, PS, PS 2up, PDF)
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.