ai.krr
Class SyntaxAdaptableSymbol

java.lang.Object
  extended by ai.krr.SyntaxAdaptableSymbol
All Implemented Interfaces:
Symbol, inf.compilers.SyntaxAdaptable, java.lang.Comparable<Symbol>
Direct Known Subclasses:
AnonymousSymbol, BooleanSymbol, CharacterSymbol, NamedSymbol, NumericSymbol, StringSymbol

public abstract class SyntaxAdaptableSymbol
extends java.lang.Object
implements Symbol, inf.compilers.SyntaxAdaptable

This class implements the foundations for symbolic programming in Java.

Author:
Gerhard Wickler

Constructor Summary
SyntaxAdaptableSymbol()
           
 
Method Summary
 boolean isBooleanSymbol()
           This function tests whether this Symbol is a BooleanSymbol.
 boolean isNamedSymbol()
           This function tests whether this Symbol is a NamedSymbol.
 boolean isNumericSymbol()
           This function tests whether this Symbol is a NumericSymbol.
 void prettyPrint(int indent, java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
           This function can be used write this SyntaxAdaptable object to the given Writer.
static Symbol read(java.io.Reader r, inf.compilers.SyntaxAdaptor<SyntaxAdaptableSymbol> sa)
           This function can be used to read a Symbol from the given Reader.
 void write(java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
           This function can be used write this logical Symbol to the given Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ai.krr.Symbol
getClassOrderIndex
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

SyntaxAdaptableSymbol

public SyntaxAdaptableSymbol()
Method Detail

write

public void write(java.io.Writer w,
                  inf.compilers.SyntaxAdaptor sa)
           throws inf.compilers.ExpressivenessException,
                  java.io.IOException

This function can be used write this logical Symbol to the given Writer. The syntax in which it is written is defined by the SyntaxAdaptor that is also given to this function.

Specified by:
write in interface inf.compilers.SyntaxAdaptable
Parameters:
w - the Writer to which this Symbol is written
sa - the SyntaxAdaptor that determines the syntax
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support this type of Symbol
java.io.IOException - if writing to the Writer fails

prettyPrint

public void prettyPrint(int indent,
                        java.io.Writer w,
                        inf.compilers.SyntaxAdaptor sa)
                 throws inf.compilers.ExpressivenessException,
                        java.io.IOException

This function can be used write this SyntaxAdaptable object to the given Writer. The syntax is the same as for normal writing. The only difference is the inclusion of extra space and newlines for better readability.

Specified by:
prettyPrint in interface inf.compilers.SyntaxAdaptable
Parameters:
indent - the amount of indentation for the first line
w - the Writer to which this Symbol is written
sa - the SyntaxAdaptor that determines the syntax
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support this type of Symbol
java.io.IOException - if writing to the Writer fails

isBooleanSymbol

public boolean isBooleanSymbol()

This function tests whether this Symbol is a BooleanSymbol. This default implementation always returns false.

Specified by:
isBooleanSymbol in interface Symbol
Returns:
true if and only if this is a BooleanSymbol

isNumericSymbol

public boolean isNumericSymbol()

This function tests whether this Symbol is a NumericSymbol. This default implementation always returns false.

Specified by:
isNumericSymbol in interface Symbol
Returns:
true if and only if this is a NumericSymbol

isNamedSymbol

public boolean isNamedSymbol()

This function tests whether this Symbol is a NamedSymbol. This default implementation always returns false.

Specified by:
isNamedSymbol in interface Symbol
Returns:
true if and only if this is a NamedSymbol

read

public static Symbol read(java.io.Reader r,
                          inf.compilers.SyntaxAdaptor<SyntaxAdaptableSymbol> sa)
                   throws inf.compilers.ExpressivenessException,
                          java.text.ParseException,
                          java.io.IOException

This function can be used to read a Symbol from the given Reader. The given SyntaxAdaptor determines the exact Syntax that will be used.

Parameters:
r - the Reader from which characters forming the Symbol are read
sa - the SyntaxAdaptor defining the syntax and used for parsing
Returns:
a Symbol corresponding to the characters read
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException