org.rubato.scheme
Class SExpr

java.lang.Object
  extended by org.rubato.scheme.SExpr
Direct Known Subclasses:
Env, SBoolean, SChar, SClosure, SCons, SDenotator, SForm, SInPort, SNumber, SOutPort, SPrimitive, SString, SVector, Symbol

public abstract class SExpr
extends java.lang.Object

This is the abstract base class for all types of Scheme values, e.g., numbers, symbols, conses, closures, etc.

Author:
Gérard Milmeister

Field Summary
static SExpr NULL
          The unique instance of the Scheme () value.
static SExpr VOID
          The unique instance representating a non-value result.
 
Method Summary
static SExpr car(SExpr sexpr)
          Returns the car of sexpr, which must be an SCons.
static SExpr cdr(SExpr sexpr)
          Returns the car of sexpr, which must be an SCons.
static SCons cons(SExpr car, SExpr cdr)
          Returns the cons of car and cdr.
abstract  java.lang.String display()
          Returns a string representation of this SExpr.
abstract  boolean eq_p(SExpr sexpr)
          Returns true iff this is equal to sexpr in the eq? sense.
abstract  boolean equal_p(SExpr sexpr)
          Returns true iff this is equal to sexpr in the equal? sense.
abstract  boolean equals(java.lang.Object obj)
          Returns true iff this is equal to obj.
abstract  boolean eqv_p(SExpr sexpr)
          Returns true iff this is equal to sexpr in the eqv? sense.
 SExpr getCar()
          Returns the car of this SExpr.
 SExpr getCdr()
          Returns the cdr of this SExpr.
 int getLength()
          Returns the length if this is a regular list, otherwise -1.
 boolean isBoolean()
          Returns true iff this is a boolean.
 boolean isChar()
          Returns true iff this is a character.
 boolean isClosure()
          Returns true iff this is a closure.
 boolean isComplex()
          Returns true iff this is a complex number.
 boolean isCons()
          Returns true iff this is a cons.
 boolean isDenotator()
          Returns true iff this is a Scheme denotator object.
 boolean isForm()
          Returns true iff this is a Scheme form object.
 boolean isInteger()
          Returns true iff this is an integer.
 boolean isList()
          Returns true iff this is a list.
 boolean isNull()
          Returns true iff this is the Scheme () value.
 boolean isNumber()
          Returns true iff this is a number.
 boolean isPair()
          Returns true iff this is a cons.
 boolean isPrimitive()
          Returns true iff this is a primitive function.
 boolean isRational()
          Returns true iff this is a rational.
 boolean isReal()
          Returns true iff this is a real number.
 boolean isString()
          Returns true iff this is a Scheme string.
 boolean isSymbol()
          Returns true iff this is a Scheme symbol.
 boolean isVector()
          Returns true iff this is a Scheme vector.
 boolean isVoid()
          Returns true iff this is the Scheme no-value.
 SExpr nth(int i)
          Returns the i-th element if this is a regular list, otherwise null.
 void setCar(SExpr sexpr)
          Sets the car of this SExpr.
 void setCdr(SExpr sexpr)
          Sets the cdr of this SExpr.
abstract  java.lang.String toString()
          Returns a string representation of this SExpr.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final SExpr NULL
The unique instance of the Scheme () value.


VOID

public static final SExpr VOID
The unique instance representating a non-value result.

Method Detail

cons

public static final SCons cons(SExpr car,
                               SExpr cdr)
Returns the cons of car and cdr.


car

public static final SExpr car(SExpr sexpr)
Returns the car of sexpr, which must be an SCons.


cdr

public static final SExpr cdr(SExpr sexpr)
Returns the car of sexpr, which must be an SCons.


eq_p

public abstract boolean eq_p(SExpr sexpr)
Returns true iff this is equal to sexpr in the eq? sense.


eqv_p

public abstract boolean eqv_p(SExpr sexpr)
Returns true iff this is equal to sexpr in the eqv? sense.


equal_p

public abstract boolean equal_p(SExpr sexpr)
Returns true iff this is equal to sexpr in the equal? sense.


equals

public abstract boolean equals(java.lang.Object obj)
Returns true iff this is equal to obj. Normally this returns the same result as equal_p(org.rubato.scheme.SExpr).

Overrides:
equals in class java.lang.Object

toString

public abstract java.lang.String toString()
Returns a string representation of this SExpr.

Overrides:
toString in class java.lang.Object

display

public abstract java.lang.String display()
Returns a string representation of this SExpr. This is the representation intended to show the result of an evaluation, and should be a valid Scheme expression if possible.


isNull

public boolean isNull()
Returns true iff this is the Scheme () value.


isVoid

public boolean isVoid()
Returns true iff this is the Scheme no-value.


isCons

public boolean isCons()
Returns true iff this is a cons.


isNumber

public boolean isNumber()
Returns true iff this is a number.


isInteger

public boolean isInteger()
Returns true iff this is an integer.


isRational

public boolean isRational()
Returns true iff this is a rational.


isReal

public boolean isReal()
Returns true iff this is a real number.


isComplex

public boolean isComplex()
Returns true iff this is a complex number.


isString

public boolean isString()
Returns true iff this is a Scheme string.


isChar

public boolean isChar()
Returns true iff this is a character.


isBoolean

public boolean isBoolean()
Returns true iff this is a boolean.


isVector

public boolean isVector()
Returns true iff this is a Scheme vector.


isSymbol

public boolean isSymbol()
Returns true iff this is a Scheme symbol.


isClosure

public boolean isClosure()
Returns true iff this is a closure.


isPrimitive

public boolean isPrimitive()
Returns true iff this is a primitive function.


isDenotator

public boolean isDenotator()
Returns true iff this is a Scheme denotator object.


isForm

public boolean isForm()
Returns true iff this is a Scheme form object.


isList

public boolean isList()
Returns true iff this is a list.


getCar

public SExpr getCar()
Returns the car of this SExpr.

Returns:
null if this is not a cons

getCdr

public SExpr getCdr()
Returns the cdr of this SExpr.

Returns:
null if this is not a cons

setCar

public void setCar(SExpr sexpr)
Sets the car of this SExpr. Does nothing if this is not a cons.


setCdr

public void setCdr(SExpr sexpr)
Sets the cdr of this SExpr. Does nothing if this is not a cons.


isPair

public boolean isPair()
Returns true iff this is a cons.


getLength

public int getLength()
Returns the length if this is a regular list, otherwise -1.


nth

public SExpr nth(int i)
Returns the i-th element if this is a regular list, otherwise null.