13.2 Implementation Basics

To implement Prolog we need to start with some basic items. First, all constants are represented by Strings. Variables are represented by instances of the class Var. Each variable has a name and a binding:

 public class Var {    String name;    Object binding; } 

The value of binding is the value the variable is bound to. It may be a constant or another variable. If the binding field is set to null, then the variable is considered unbound.

Next, we need something to represent terms like inside(baltimore, maryland). This kind of term is called a structure. Structures are implemented as instances of the class Structure:

 public class Structure {    public Object predicate;    public Object arg[]; } 


Programming for the Java Virtual Machine
Programming for the Javaв„ў Virtual Machine
ISBN: 0201309726
EAN: 2147483647
Year: 1998
Pages: 158
Authors: Joshua Engel

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net