Prolog Cafe v1.2

jp.ac.kobe_u.cs.prolog.compiler
Class Compiler

java.lang.Object
  extended by jp.ac.kobe_u.cs.prolog.compiler.Compiler

public class Compiler
extends java.lang.Object

The Compiler class provides methods for translating Prolog programs into Java programs. The Compiler class supports the following compiler options. All of them are set to true in default setting.

Let us show a sample session for translating a Prolog program $PLCAFEDIR/examples/prolog/list.pl into Java. The list.pl contains predicates append/3, nrev/2, and range/3. It is noted that our Prolog-to-Java translator is originally witten in Prolog, and then bootstrapped. Please see the following two Prolog programs in details.


Field Summary
protected  boolean arithmeticCompilation
          Compiler option for arithmetic compilation.
static java.lang.String COPYRIGHT
          Copyright information
protected  boolean eliminateDisjunctions
          Compiler option for eliminating disjunctions.
protected  boolean generateClosure
          Non-standard option.
protected  boolean inlineExpansion
          Compiler option for inline expansion.
protected  boolean optimiseRecursiveCall
          Compiler option for optimising recursive call.
protected  boolean switchOnHash
          Compiler option for second-level indexing.
static java.lang.String VERSION
          Version information
 
Constructor Summary
Compiler()
           
 
Method Summary
protected static boolean fileExists(java.lang.String _file)
           
 boolean getArithmeticCompilation()
          Returns the boolean value of arithmeticCompilation.
 boolean getEliminateDisjunctions()
          Returns the boolean value of eliminateDisjunctions.
 boolean getGenerateClosure()
          Returns the boolean value of generateClosure.
 boolean getInlineExpansion()
          Returns the boolean value of inlineExpansion.
 boolean getOptimiseRecursiveCall()
          Returns the boolean value of optimiseRecursiveCall.
 boolean getSwitchOnHash()
          Returns the boolean value of switchOnHash.
static void main(java.lang.String[] argv)
           
 boolean prologToJava(java.lang.String prolog, java.lang.String dir)
          Translates a Prolog program into Java programs.
 boolean prologToWAM(java.lang.String _prolog, java.lang.String _wam)
          Translates a Prolog program into a WAM-based intermediate code.
 void setArithmeticCompilation(boolean b)
          The arithmeticCompilation field is set to b.
 void setEliminateDisjunctions(boolean b)
          The eliminateDisjunctions field is set to b.
 void setGenerateClosure(boolean b)
          The generateClosure field is set to b.
 void setInlineExpansion(boolean b)
          The inlineExpansion field is set to b.
 void setOptimiseRecursiveCall(boolean b)
          The optimiseRecursiveCall field is set to b.
 void setSwitchOnHash(boolean b)
          The switchOnHash field is set to b.
protected static void usage()
          Shows usage
 boolean wamToJava(java.lang.String _wam, java.lang.String _dir)
          Translates WAM-based intermediate code into Java programs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static java.lang.String VERSION
Version information


COPYRIGHT

public static java.lang.String COPYRIGHT
Copyright information


eliminateDisjunctions

protected boolean eliminateDisjunctions
Compiler option for eliminating disjunctions. Its initial value is true


arithmeticCompilation

protected boolean arithmeticCompilation
Compiler option for arithmetic compilation. Its initial value is true


inlineExpansion

protected boolean inlineExpansion
Compiler option for inline expansion. Its initial value is true


optimiseRecursiveCall

protected boolean optimiseRecursiveCall
Compiler option for optimising recursive call. Its initial value is true


switchOnHash

protected boolean switchOnHash
Compiler option for second-level indexing. Its initial value is true


generateClosure

protected boolean generateClosure
Non-standard option. Compiler option for closure generation. Its initial value is false

Constructor Detail

Compiler

public Compiler()
Method Detail

prologToWAM

public boolean prologToWAM(java.lang.String _prolog,
                           java.lang.String _wam)
Translates a Prolog program into a WAM-based intermediate code.

Parameters:
_prolog - an input Prolog file
_wam - an output file for WAM-based intermediate code.
Returns:
true if succeeds, otherwise false.

wamToJava

public boolean wamToJava(java.lang.String _wam,
                         java.lang.String _dir)
Translates WAM-based intermediate code into Java programs.

Parameters:
_wam - an input file for WAM-based intermediate code.
_dir - a destination directory for java files. The directory must already exist.
Returns:
true if succeeds, otherwise false.
See Also:
prologToWAM(String, String)

prologToJava

public boolean prologToJava(java.lang.String prolog,
                            java.lang.String dir)
Translates a Prolog program into Java programs.

Parameters:
prolog - an input Prolog file
dir - a destination directory for java files. The directory must already exist.
Returns:
true if succeeds, otherwise false.
See Also:
prologToWAM(String, String), wamToJava(String, String)

main

public static void main(java.lang.String[] argv)

fileExists

protected static boolean fileExists(java.lang.String _file)

usage

protected static void usage()
Shows usage


getEliminateDisjunctions

public boolean getEliminateDisjunctions()
Returns the boolean value of eliminateDisjunctions.

See Also:
eliminateDisjunctions

setEliminateDisjunctions

public void setEliminateDisjunctions(boolean b)
The eliminateDisjunctions field is set to b.

See Also:
eliminateDisjunctions

getArithmeticCompilation

public boolean getArithmeticCompilation()
Returns the boolean value of arithmeticCompilation.

See Also:
arithmeticCompilation

setArithmeticCompilation

public void setArithmeticCompilation(boolean b)
The arithmeticCompilation field is set to b.

See Also:
arithmeticCompilation

getInlineExpansion

public boolean getInlineExpansion()
Returns the boolean value of inlineExpansion.

See Also:
inlineExpansion

setInlineExpansion

public void setInlineExpansion(boolean b)
The inlineExpansion field is set to b.

See Also:
inlineExpansion

getOptimiseRecursiveCall

public boolean getOptimiseRecursiveCall()
Returns the boolean value of optimiseRecursiveCall.

See Also:
optimiseRecursiveCall

setOptimiseRecursiveCall

public void setOptimiseRecursiveCall(boolean b)
The optimiseRecursiveCall field is set to b.

See Also:
optimiseRecursiveCall

getSwitchOnHash

public boolean getSwitchOnHash()
Returns the boolean value of switchOnHash.

See Also:
switchOnHash

setSwitchOnHash

public void setSwitchOnHash(boolean b)
The switchOnHash field is set to b.

See Also:
switchOnHash

getGenerateClosure

public boolean getGenerateClosure()
Returns the boolean value of generateClosure.

See Also:
generateClosure

setGenerateClosure

public void setGenerateClosure(boolean b)
The generateClosure field is set to b.

See Also:
generateClosure

Prolog Cafe v1.2

Copyright (C) 1997-2008 M.BANBARA and N.TAMURA