Prolog

My implementation of Prolog in Java is interpreter-based; hopefully it can be generically interfaced with Java. Towards the latter goal, I have hacked together two applets: botworld and GLog.

The plan is to implement a JIT for it; in other words, to dynamically build and execute Java classes from the source predicates, based on information (e.g. mode and type information) collected at run time. I guess this is an attempt to show that the complexity associated with static source analysis can be avoided. My supervisor is Andrew Taylor at CSE, UNSW.

The source is available: directory, prolog.tar.gz, and some cruddy javadoc-generated documentation. Be aware that it is a work in progress and is therefore likely to undergo radical (unannounced) change. Please scan the source files for clues as to what makes the parser happy, limitations, what to do with pre-compiled predicates, etc. Any and all feedback is welcomed.

Limitations

To Do

Web links

W-Prolog
SWI-Prolog Home
Carnegie Mellon AI Repository - prolog
ISO Prolog Standard
Peter Van Roy's Homepage
Lee Naish's Homepage
The GNU Prolog compiler (gprolog)

Java

kawa
Various bits and pieces that make life easier - gnu.math in particular.
JavaClass
Code generation. Very good stuff.
JLex
Lexical analyzer. Doesn't get much better than this. Seems I was wrong. Take a look at JFlex.
gnu.getopt
Command-line argument parser. Stock GNU stuff.
The Java Virtual Machine Specification (Sun)
Compilation clues, general background. A little buggy (still).
JavaWorld articles: 1, 2
Using the ClassLoader, details of loading classes, etc.

What you get:

I have included gnu.getopt and a hacked version of gnu.math (from kawa, renamed as prolog.math). You'll need to separately obtain a copy of JavaClass.

You will need to hack the startup script (run) to set the CLASSPATH variable appropriately. Also, if you want to rebuild from the source, the GNUMakefile supplied does the job if you have GNU make [dunno about stock make].

Legal mumblings

Assuming UNSW doesn't mind, this is released under the LGPL. Be kind to it.
    Prolog Interpreter and JIT Compiler.
    Copyright (C) 2000 Peter Gammie (peteg@cse.unsw.edu.au)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA