|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectescjava.prover.SExp
escjava.prover.SList
SList
s represent possibly-empty lists of
SExp
s.
As a convenience, lists of fewer than 9 elements may be created
directly by calling SList.make
on the desired
elements. E.g., SList.make(x, y)
creates the list
(
x
y)
where
x and y are the contents of the SExp
variables x
and y
. Longer lists may be
created either from arrays (see fromArray
) or by
combining shorter lists via append
.
As a further convenience, SList.make
calls
SExp.fancyMake(Object)
on its arguments before placing them in
the resulting list. This means that Atom
s may be
specified by a String
holding their name and that
S-expression integers may be specified by Integer
s.
E.g., SList.make("NEG", new Integer(1))
represents the
S-expression (NEG, 1)
.
SList
s may not contain null
elements.
SList
s can be tested to see if they are empty, can
have their length determined, and can have their i-index
element extracted. (If an attempt is made to extract a
non-existent element, SExpTypeError
will be
thrown.)
S-expressions are currently immutable; accordingly all manipulation methods act functionally. S-expressions may be made mutable later via the addition of mutation methods.
SList
s can be appended to each other. Elements
can also be added to the front or end of a list.
SList
s are currently implemented via pairs and a
nil object a la Lisp. These are provided by the non-public classes
SPair
and SNil
. This implementation is
subject to change at any time; clients should rely only on the
publically-provided interface of this class.
SNil
,
SPair
Constructor Summary | |
(package private) |
SList()
SList may not be extended outside this package. |
Method Summary | |
SList |
addEnd(SExp x)
|
SList |
addFront(SExp x)
|
SList |
append(SList x)
|
SExp |
at(int i)
|
static SList |
fromArray(SExp[] a)
|
SList |
getList()
If we represent a list, return it as an SList ;
otherwise, throw SExpTypeError . |
(package private) SPair |
getPair()
If we represent a non-empty list, return it as a SPair ; otherwise, throw SExpTypeError . |
abstract boolean |
isEmpty()
|
boolean |
isList()
Do we represent a list? |
abstract int |
length()
|
static void |
main(java.lang.String[] args)
A simple test routine |
static SList |
make()
|
static SList |
make(java.lang.Object a1)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4,
java.lang.Object a5)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4,
java.lang.Object a5,
java.lang.Object a6)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4,
java.lang.Object a5,
java.lang.Object a6,
java.lang.Object a7)
|
static SList |
make(java.lang.Object a1,
java.lang.Object a2,
java.lang.Object a3,
java.lang.Object a4,
java.lang.Object a5,
java.lang.Object a6,
java.lang.Object a7,
java.lang.Object a8)
|
void |
prettyPrint(java.io.PrintStream out)
Pretty-print a textual representation of us on a given PrintStream .
|
void |
print(java.io.PrintStream out)
Print a textual representation of us on a given PrintStream .
|
static SList |
reverseD(SList l)
Destructive list reversal |
void |
setAt(int i,
SExp s)
Modify the list in place by set the i th element to
s . |
private boolean |
specialPrint(java.io.PrintStream out)
Specially print a textual representation of us on a given PrintStream . |
Methods inherited from class escjava.prover.SExp |
display, fancyMake, getAtom, getInteger, isAtom, isInteger, make, print, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
SList()
SList
may not be extended outside this package.
Method Detail |
public static SList make()
public static SList make(java.lang.Object a1)
SExp.fancyMake(Object)
to our arguments.public static SList make(java.lang.Object a1, java.lang.Object a2)
SExp.fancyMake(Object)
to our arguments.public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3)
SExp.fancyMake(Object)
to our arguments. public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3, java.lang.Object a4)
SExp.fancyMake(Object)
to our arguments. public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3, java.lang.Object a4, java.lang.Object a5)
SExp.fancyMake(Object)
to our arguments. public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3, java.lang.Object a4, java.lang.Object a5, java.lang.Object a6)
SExp.fancyMake(Object)
to our arguments. public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3, java.lang.Object a4, java.lang.Object a5, java.lang.Object a6, java.lang.Object a7)
SExp.fancyMake(Object)
to our arguments. public static SList make(java.lang.Object a1, java.lang.Object a2, java.lang.Object a3, java.lang.Object a4, java.lang.Object a5, java.lang.Object a6, java.lang.Object a7, java.lang.Object a8)
SExp.fancyMake(Object)
to our arguments.public static SList fromArray(SExp[] a)
public boolean isList()
SExp
isList
in class SExp
public SList getList()
SExp
SList
;
otherwise, throw SExpTypeError
.
getList
in class SExp
public abstract boolean isEmpty()
public abstract int length()
SPair getPair() throws SExpTypeError
SPair
; otherwise, throw SExpTypeError
.
SExpTypeError
public SExp at(int i) throws SExpTypeError
i
(indices start at
0). If we are not long enough to have an element at that
index, then SExpTypeError
is thrown.
SExpTypeError
public void setAt(int i, SExp s) throws SExpTypeError
i
th element to
s
.
SExpTypeError
public SList append(SList x)
public static SList reverseD(SList l)
public SList addFront(SExp x)
x
is non-null.public SList addEnd(SExp x)
This function is likely to be slower than addFront
.
public void print(java.io.PrintStream out)
PrintStream
.
Note: This routine will take a PrintWriter
instead when we switch to a more recent version of JDK.
print
in class SExp
public void prettyPrint(java.io.PrintStream out)
PrintStream
.
Note: This routine will take a PrintWriter
instead when we switch to a more recent version of JDK.
prettyPrint
in class SExp
private boolean specialPrint(java.io.PrintStream out) throws SExpTypeError
PrintStream
. This is a subroutine used in
pretty-printing.
Note: This routine will take a PrintWriter
instead when we switch to a more recent version of JDK.
SExpTypeError
public static void main(java.lang.String[] args) throws SExpTypeError
SExpTypeError
|
ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |