java.lang.Object | +--Sexpr
Implements Lisp S-expressions. Every S-expression has car,
cdr, and value fields; if isAtom
is true, only the value field is used; if isAtom
is false, only the car and cdr fields are
used. The field isNull is true if the S-expression represents
an empty list, while the field isNumeric tells whether the
S-expression represents a numeric atom.
| Field Summary | |
(package private) Sexpr |
car
The CAR of this S-expression; valid only for nonempty lists. |
(package private) Sexpr |
cdr
The CDR of this S-expression; valid only for nonempty lists. |
(package private) boolean |
isAtom
True if this S-expression represents an atom. |
(package private) boolean |
isNull
True if this S-expression represents an empty list. |
(package private) boolean |
isNumeric
True if this S-expression represents a numeric atom. |
static Sexpr |
NIL
The Lisp constant NIL. |
static Sexpr |
T
The Lisp constant T. |
(package private) java.lang.String |
value
The value of this S-expression; valid only for atoms. |
| Constructor Summary | |
(package private) |
Sexpr(int value)
Constructs a numeric S-expression. |
(package private) |
Sexpr(Sexpr car,
Sexpr cdr)
Constructs an S-expression that is a list. |
(package private) |
Sexpr(java.lang.String value)
Constructs an atomic S-expression. |
| Method Summary | |
static void |
main(java.lang.String[] args)
Unit testing for this class. |
static Sexpr |
parse(java.lang.String input)
Turns an input string into an S-expression. |
java.lang.String |
toString()
Turns this S-expression into a String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
Sexpr car
Sexpr cdr
boolean isAtom
boolean isNull
boolean isNumeric
public static Sexpr NIL
NIL.
public static Sexpr T
T.
java.lang.String value
| Constructor Detail |
Sexpr(int value)
value - The integer value of the S-expression.
Sexpr(Sexpr car,
Sexpr cdr)
car - The car of the new S-expression.Sexpr(java.lang.String value)
value - The String value of the S-expression.| Method Detail |
public static void main(java.lang.String[] args)
public static Sexpr parse(java.lang.String input)
public java.lang.String toString()
toString in class java.lang.Object