CMU Artificial Intelligence Repository
GRIPS Compiler: Grips/Prolog demonstration mini-compiler.
lang/prolog/code/syntax/compiler/
This is a demonstration compiler, written in a functional language
(GRIPS) that can be translated into Prolog. The GRIPS translator is
available separately.
The compiler takes programs in a (very small) subset of Pascal. It
lexically analyzes them into tokens, parses the token list into a
tree, generates code from the tree, fixes up references in the code,
and then interprets the code on a stack virtual machine. It displays
the output of each stage, and the interpreter displays the machine
state as each instruction is obeyed.
The compiler is written in a functional style, using functions
(sometimes represented as sets of domain->codomain pairs) to represent
well-known concepts in programming language semantics, such as the
store and the environment.
Here is an example program that it can compile and run.
program p;
label
99, 100;
const
five = 5;
var
v : integer;
w : integer;
begin
write('Hello.');
v := 1;
w := 1;
99:
if v=five then goto 100;
v := v + 1;
w := w * v;
goto 99;
100:
write('v = ');
write(v);
write('v! = ');
write(w)
end.
See Also:
lang/prolog/code/syntax/grips/
Origin:
src.doc.ic.ac.uk:packages/prolog-pd-software/ (146.169.2.1)
as compiler.tar.Z
Version: 11-JAN-91
Ports: Edinburgh-compatible Prologs.
CD-ROM: Prime Time Freeware for AI, Issue 1-1
Author(s): Jocelyn Paine
Department of Experimental Psychology
Oxford University
South Parks Road
Oxford OX1 3UD
Tel: (0865) 271444
Fax: (0865) 310447
Keywords:
Authors!Paine, Grips, Lexical Analysis, Oxford, Parsing,
Pascal Interpreter in Prolog, Prolog!Code, Prolog!Syntax,
Syntax, lex@{\tt lex}
References: ?
Last Web update on Mon Feb 13 10:34:00 1995
AI.Repository@cs.cmu.edu