Re: Compiling Prolog-like languages (incremental compiler)

"Aaron Sloman" <>
21 Jul 2002 01:52:16 -0400

          From comp.compilers

Related articles
Compiling Prolog-like languages (Sarah Thompson) (2002-07-02)
Re: Compiling Prolog-like languages (incremental compiler) (Aaron Sloman) (2002-07-21)
| List of all articles for this month |

From: "Aaron Sloman" <>
Newsgroups: comp.lang.prolog,comp.compilers,comp.lang.pop
Date: 21 Jul 2002 01:52:16 -0400
Organization: School of Computer Science, The University of Birmingham
References: 02-07-004
Keywords: prolog
Posted-Date: 21 Jul 2002 01:52:16 EDT

"Sarah Thompson" <> writes:
> Date: 2 Jul 2002 01:03:18 -0400

> ....
> I am in the process of designing and implementing a compiler for a
> special purpose programming language that is intended to facilitate
> the implementation of natural language chat systems (chatterbots).
> Lexical analysis and syntax analysis of natural language is already
> taken care of, and simple procedural scripting is supported. However,
> I feel the need for a 'back-end', for want of a better description,
> which supports theorem-prover/unification functionality. Since my
> language is compiled, I am looking for algorithms that could support
> true compilation rather than just running in an interpreted
> environment.

Other replies may already have given you what you need. If not, you
may find the poplog system helpful, especially if you want an
incremental compiler.

Poplog is a free, open-source, multi-language system for teaching
research and development in AI. It used to be an expensive
commercial product, sold by ISL and was used to develop their Clementine
data-mining system, before they were bought by SPSS:

The core of poplog is Pop-11 (a language with something like the
power of common lisp, but a more familiar, conventional syntax),
which is used to compile itself.

Because the incremental compiler is implemented as a collection of
pop-11 procedures available at run time, those procedures can be used to
write incremental compilers for other languages. So poplog includes
source libraries that provide incremental compilers for Common Lisp,
Prolog, ML (and available separately Scheme). The compilers can be added
to poplog as saved images (poplog is normally delivered with the saved
images pre-built)

The sources for adding prolog to poplog are in here
                with some extras here

These incremental compilers all compile source to an intermediate
level language: the Poplog Virtual Machine (PVM) language, which is
machine and operating system independent. Then machine specific
back-end compilers produce machine code. Compilation is done roughly
a procedure at a time. (In prolog lots of rules with the same
predicate with the same arity compile to one procedure).

For porting to a new machine/operating system, or when the system is
rebuilt, the poplog sources (after editing to generate the
appropriate machine instructions) use the compiler to the PVM
(enhanced to support some low level C-like language features). Then
the back-end code generator is replaced with a compiler that creates
assembler files for the target system. These are assembled, linked
and run, and after that the new system can be used to extend itself.
(That's an approximate, compressed overview).

You can get various versions of poplog from here:

A version packaged for linux+PC with various extensions produced at
Birmingham for teaching and research in AI can be found here:

The version of poplog for windows does not include any of the graphics
available in the Unix/linux versions, as the poplog graphical tools are
based on the X window system.

There's more information about poplog here

A primer of pop-11 (but not including information on how to use the
low level compiler tools) is here:
                or packaged in a tar bundle
                about 400 kbytes

Information for system developers who wish to port or rebuild poplog
is here
or tarred here:
                74 Kbytes

A huge amount of relevant online information comes with poplog and
is browsable here:

An introduction to the Poplog virtual machine is here, in the form
of information about the pop-11 "code-planting" instructions.
                73 kbyptes

There's more about support for prolog in poplog here

The core system sources for poplog include some extensions of the PVM
to support prolog, including unification, the prolog call stack, the
trail and operations on prolog terms. Thie files are in here
in these files
These files use the extended "system" dialect of pop-11, called syspop,
which is not as easily readable as pure pop-11.

You may be familiar with one or more of the books by Gerald Gazdar
and Chris Mellish
        Natural Language Processing in POP-11,
        Natural Language Processing in Common Lisp
        Natural Language Processing in Prolog

Published by Addison Wesley circa 1989. The examples, in all three
languages, are available as part of the poplog contrib directory

                about 290 Kbytes

If you are interested in how poplog can be used for introductory
teaching in natural language processing, look at

There's a mirror site for all the above here

                  GOSPL - The Global Open Source Poplog Library.

I am cross posting this to comp.lang.pop Please post any queries
about poplog prolog there: there are other readers of that group who
know more about the prolog subsystem than I do. The FAQ is

Best wishes

Aaron Sloman, ( )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT (ReadATas@please !)
PAPERS: (And free book on Philosophy of AI)

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.