Class Sexpr

java.lang.Object
  |
  +--Sexpr

class Sexpr
extends java.lang.Object

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

car

Sexpr car
The CAR of this S-expression; valid only for nonempty lists.


cdr

Sexpr cdr
The CDR of this S-expression; valid only for nonempty lists.


isAtom

boolean isAtom
True if this S-expression represents an atom.


isNull

boolean isNull
True if this S-expression represents an empty list.


isNumeric

boolean isNumeric
True if this S-expression represents a numeric atom.


NIL

public static Sexpr NIL
The Lisp constant NIL.


T

public static Sexpr T
The Lisp constant T.


value

java.lang.String value
The value of this S-expression; valid only for atoms.

Constructor Detail

Sexpr

Sexpr(int value)
Constructs a numeric S-expression.

Parameters:
value - The integer value of the S-expression.

Sexpr

Sexpr(Sexpr car,
      Sexpr cdr)
Constructs an S-expression that is a list.

Parameters:
car - The car of the new S-expression.

Sexpr

Sexpr(java.lang.String value)
Constructs an atomic S-expression.

Parameters:
value - The String value of the S-expression.
Method Detail

main

public static void main(java.lang.String[] args)
Unit testing for this class.


parse

public static Sexpr parse(java.lang.String input)
Turns an input string into an S-expression.


toString

public java.lang.String toString()
Turns this S-expression into a String.

Overrides:
toString in class java.lang.Object


Generated by BlueJ