Pro_Trail 1.4


io.github.JalogTeam.jalog
Class Pro_Trail

java.lang.Object
  extended by io.github.JalogTeam.jalog.Pro_Trail

public class Pro_Trail
    

Class Pro_Trail implements the trail concept of Prolog. It stores information about variable bindings and supports clearing those bindings on backtrack.

Logically the trail is a stack of variable references. When a variable is bound to a value or another variable a pointer to the variable is pushed to the trail. On backtrack variables are popped from the trail and the binding of each popped variable is cleared.


Method Summary
 public void mark(Pro_TrailMark Mark)
           Updates the parameter Mark to indicate which bindings shall be cleared on a possible backtrack.
 public void append(Pro_Term pn)
           The method pushes a variable reference to the trail.
 public void backtrack(Pro_TrailMark Mark)
           Pops variables from the trail and clears the binding of each popped variable.
 public void dump(String header)
           Dumps the contents of the trail (for debugging).
 

Method Detail

mark

public void mark(Pro_TrailMark Mark)

Updates the parameter Mark to indicate which bindings shall be cleared on a possible backtrack.

When backtrack is called with this Mark the variable bindings pushed to the trail after this call are cleared.

Parameters:
Mark - must not be null. This is updated to indicate the current top of the trail.

append

public void append(Pro_Term pn)

The method pushes a variable reference to the trail.

It is usually necessary to push all variables to the trail after they are bound to another variable or a value.

Parameters:
pn - must not be null; the variable that was bound.

backtrack

public void backtrack(Pro_TrailMark Mark)

Pops variables from the trail and clears the binding of each popped variable. The parameter Mark indicates which variables are to be popped: those variables that were pushed to the trail after the object Mark was updated.

Parameters:
Mark - must not be null. Indicates which variables are to be popped.

dump

public void dump(String header)
Prints the header and then the contents of the trail.

Parameters:
header - the header to be printed.

Authors: Mikko Levanto, Ari Okkonen