Re: Compiling Prolog-like languages (incremental compiler)

"Aaron Sloman" <A.Sloman@cs.bham.ac.uk>
21 Jul 2002 01:52:16 -0400

          From comp.compilers

Related articles
Compiling Prolog-like languages sarah@telergy.com (Sarah Thompson) (2002-07-02)
Re: Compiling Prolog-like languages (incremental compiler) A.Sloman@cs.bham.ac.uk (Aaron Sloman) (2002-07-21)
| List of all articles for this month |
From: "Aaron Sloman" <A.Sloman@cs.bham.ac.uk>
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" <sarah@telergy.com> 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:
        http://www.spss.com/software/clementine/


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
        http://www.cs.bham.ac.uk/research/poplog/src/master/C.all/plog/src/
                with some extras here
        http://www.cs.bham.ac.uk/research/poplog/src/master/C.all/plog/lib/
        http://www.cs.bham.ac.uk/research/poplog/src/master/C.all/plog/auto/


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:
        http://www.cs.bham.ac.uk/research/poplog/freepoplog.html


A version packaged for linux+PC with various extensions produced at
Birmingham for teaching and research in AI can be found here:
        http://www.cs.bham.ac.uk/research/poplog/linux-cd/


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
        http://www.cs.bham.ac.uk/research/poplog/poplog.info.html


A primer of pop-11 (but not including information on how to use the
low level compiler tools) is here:
        http://www.cs.bham.ac.uk/research/poplog/primer/
                or packaged in a tar bundle
                http://www.cs.bham.ac.uk/research/poplog/pophtmlprimer.tar.gz
                about 400 kbytes


Information for system developers who wish to port or rebuild poplog
is here
        http://www.cs.bham.ac.uk/research/poplog/sysdoc/
or tarred here:
        http://www.cs.bham.ac.uk/research/poplog/sysdoc.tar.gz
                74 Kbytes


A huge amount of relevant online information comes with poplog and
is browsable here:
        http://www.cs.bham.ac.uk/research/poplog/doc/


An introduction to the Poplog virtual machine is here, in the form
of information about the pop-11 "code-planting" instructions.
        http://www.cs.bham.ac.uk/research/poplog/doc/popref/vmcode
                73 kbyptes


There's more about support for prolog in poplog here


        http://www.cs.bham.ac.uk/research/poplog/doc/popref/prolog


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
        http://www.cs.bham.ac.uk/research/poplog/src/master/C.all/src/
in these files
        plog_area.p
        plogcore.p
        plog_process.p
        plogterms.p
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
        http://www.cs.bham.ac.uk/research/poplog/contrib/nlp_book/


or
        http://www.cs.bham.ac.uk/research/poplog/gazdar-mellish-nlp-examples.tar.gz
                about 290 Kbytes


If you are interested in how poplog can be used for introductory
teaching in natural language processing, look at
        http://www.cs.bham.ac.uk/research/poplog/teach/grammar
        http://www.cs.bham.ac.uk/research/poplog/teach/storygrammar


There's a mirror site for all the above here
        http://www.poplog.org


Including
                  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
        http://www.cs.bham.ac.uk/research/poplog/comp.lang.pop.faq.html


Best wishes


Aaron
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/ (And free book on Philosophy of AI)
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html


Post a followup to this message

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