jscheme
Class REPL
java.lang.Object
|
+--jscheme.REPL
- public class REPL
- extends java.lang.Object
This class implements the three "hard" primitives in Scheme:
- REPL.readStream(INPUT)
-- this returns a enumerator of all scheme terms in the
InputStream or Reader.
- REPL.eval(X) -- this evaluates the object X as a Scheme term
- REPL.printToString(X, Quoted) --
this generates a string representation of the Object X to a Scheme term
If Quoted is true, and the term X involves
only Scheme literals, lists, and vectors. Then it will be
printed is such a way that reading it back in using REPL.readStream
produces a term which is "equal?" to X. If Quoted is false, then
it will be printed in a "more readable" format.
and it also provides a few useful methods constructed from these
- REPL.load(NAME)
-- load a Scheme program from a file,resource,or stream
- REPL.parseScheme(STRING)
-- parse STRING into a list of Scheme expressions
- REPL.readEvalPrintLoop()
-- starts a read/eval/print loop
The main method of REPL processes the command line arguments as follows:
- strings are viewed filenames and are loaded into the interpreter
- single quoted strings: ('....') are viewed as expressions are evaluated
- the tag "-main" is followed by n+1 strings p a1 ... an which are used
to construct a term (p a1 ... an) which is then evaluated
REPL provides factory methods for creating jscheme.SchemeSymbol and
jscheme.SchemePair objects
- REPL.internSchemeSymbol(string)
-- intern string as a Symbol
- REPL.makeSchemePair(first, rest)
-- creates a SchemePair
-
REPL.EMPTY_PAIR -- the empty SchemePair object
and it provides support for Exception handling and multi-threading
- REPL.tryCatch(Thunk,Catch)
-- return a value by calling the Thunk,
if an error occurs, call Catch on the error to get a value
- REPL.tryCatchFinally(Expr,Catch,Finally)
-- same as tryCatch, but in either case call the Finally thunk
before returning the value
- REPL.throwRuntimeException(Exc)
- REPL.synchronize(Obj,Proc)
Constructor Summary |
REPL()
|
Method Summary |
static java.lang.Object |
eval(java.lang.Object X)
|
static SchemeSymbol |
internSchemeSymbol(java.lang.String name)
|
static java.lang.Object |
load(java.lang.Object Name)
|
static void |
main(java.lang.String[] args)
|
static SchemePair |
makeSchemePair(java.lang.Object first,
java.lang.Object rest)
|
static SchemePair |
parseScheme(java.lang.String S)
|
static java.lang.String |
printToString(java.lang.Object X,
boolean Quoted)
|
static void |
readEvalPrintLoop()
|
static java.util.Enumeration |
readStream(java.io.InputStream in)
|
static java.util.Enumeration |
readStream(java.io.Reader in)
|
static java.lang.Object |
synchronize(java.lang.Object x,
SchemeProcedure p)
|
static java.lang.Object |
throwRuntimeException(java.lang.RuntimeException E)
provide scheme access to the exception throwing |
static java.lang.Object |
tryCatch(java.lang.Object E,
java.lang.Object F)
provide scheme access to the "try/catch" expression of Java |
static java.lang.Object |
tryCatchFinally(java.lang.Object e,
java.lang.Object f,
java.lang.Object g)
Provide scheme access to finally - unwind-protect. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EMPTY_PAIR
public static SchemePair EMPTY_PAIR
REPL
public REPL()
readStream
public static java.util.Enumeration readStream(java.io.InputStream in)
readStream
public static java.util.Enumeration readStream(java.io.Reader in)
eval
public static java.lang.Object eval(java.lang.Object X)
printToString
public static java.lang.String printToString(java.lang.Object X,
boolean Quoted)
load
public static java.lang.Object load(java.lang.Object Name)
parseScheme
public static SchemePair parseScheme(java.lang.String S)
readEvalPrintLoop
public static void readEvalPrintLoop()
main
public static void main(java.lang.String[] args)
internSchemeSymbol
public static SchemeSymbol internSchemeSymbol(java.lang.String name)
makeSchemePair
public static SchemePair makeSchemePair(java.lang.Object first,
java.lang.Object rest)
tryCatch
public static java.lang.Object tryCatch(java.lang.Object E,
java.lang.Object F)
- provide scheme access to the "try/catch" expression of Java
tryCatchFinally
public static java.lang.Object tryCatchFinally(java.lang.Object e,
java.lang.Object f,
java.lang.Object g)
- Provide scheme access to finally - unwind-protect.
throwRuntimeException
public static java.lang.Object throwRuntimeException(java.lang.RuntimeException E)
throws java.lang.RuntimeException
- provide scheme access to the exception throwing
synchronize
public static java.lang.Object synchronize(java.lang.Object x,
SchemeProcedure p)