|
|||||||||
| Home >> All >> [ silk overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
silk
Class Scheme

java.lang.Objectsilk.Scheme
- public class Scheme
- extends java.lang.Object
This class represents a Scheme interpreter.
| Field Summary | |
static java.io.PrintWriter |
error
|
static InputPort |
input
|
static java.io.PrintWriter |
output
|
static java.lang.String |
version
|
| Constructor Summary | |
Scheme()
|
|
| Method Summary | |
static java.lang.Object |
analyze(java.lang.Object x,
Environment env)
Analyze (or preprocess or precompile) an expression into "code". |
private static java.lang.Object |
checkForDefines(Pair body)
Check for embedded defines this checks for any improperly embedded defines and also flattens the body |
private static void |
checkLength(java.lang.Object f,
int len,
java.lang.Object x)
|
static java.lang.Object |
eval(java.lang.Object x)
Evaluate an s-expression in the global environment. |
static java.lang.Object |
eval(java.lang.Object x,
Environment env)
Evaluate an s-expression in an environment. |
static java.lang.Object |
evalToplevel(java.lang.Object x)
evalToplevel evaluates each element of a BEGIN. |
static java.lang.Object |
execute(java.lang.Object x,
Environment env)
Evaluate analyzed code in an environment. |
private static java.lang.Object |
executeButLast(java.lang.Object[] xv,
Environment env)
Evaluate |
private static Pair |
extractDefines(Pair defines,
Pair body)
Return a Pair who's first is a list of simple defines and who's rest is the remaining body. |
private static boolean |
isSpecial(java.lang.Object f)
|
static java.lang.Object |
load(InputPort in)
Eval all the expressions coming from an InputPort. |
static java.lang.Object |
load(java.lang.Object fileName)
Eval all the expressions in a file. |
static void |
main(java.lang.String[] files)
Treat each command line arg as a file to load, unless it starts with a "(", in which case eval it. |
static java.lang.Object |
readEvalWriteLoop(java.lang.String prompt)
Prompt, read, eval, and write the result. |
private static Pair |
simplifyDefine(Pair definition)
|
private static boolean |
startsWith(java.lang.Object list,
java.lang.Object atom)
Is the first element of the list identical to the given atom? |
private static java.lang.Object |
toBody(java.lang.Object exps)
Handle internal defines, and convert a list of exps to a single exp. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
input
public static InputPort input
output
public static java.io.PrintWriter output
error
public static java.io.PrintWriter error
version
public static java.lang.String version
| Constructor Detail |
Scheme
public Scheme()
| Method Detail |
main
public static void main(java.lang.String[] files)
- Treat each command line arg as a file to load, unless it starts with
a "(", in which case eval it. Then enter a read eval write loop.
readEvalWriteLoop
public static java.lang.Object readEvalWriteLoop(java.lang.String prompt)
- Prompt, read, eval, and write the result.
Also sets up a catch for any RuntimeExceptions encountered.
load
public static java.lang.Object load(java.lang.Object fileName)
- Eval all the expressions in a file. Calls load(InputPort).
load
public static java.lang.Object load(InputPort in)
- Eval all the expressions coming from an InputPort.
evalToplevel
public static java.lang.Object evalToplevel(java.lang.Object x)
- evalToplevel evaluates each element of a BEGIN. This is so
macros can be defined and then used. Also toplevel macros can
expand into begin.
eval
public static java.lang.Object eval(java.lang.Object x)
- Evaluate an s-expression in the global environment.
eval
public static java.lang.Object eval(java.lang.Object x, Environment env)
- Evaluate an s-expression in an environment. First analyze it.
analyze
public static java.lang.Object analyze(java.lang.Object x, Environment env)
- Analyze (or preprocess or precompile) an expression into "code".
The code returned is either a Symbol, a LocalVariable, a Closure, or
an array whose first element is either one of (quote if or begin set!)
or is code evaluating to a procedure.
execute
public static java.lang.Object execute(java.lang.Object x, Environment env)
- Evaluate analyzed code in an environment. Don't pass this a raw
s-expression; you need to analyze the s-expression first.
isSpecial
private static boolean isSpecial(java.lang.Object f)
checkLength
private static void checkLength(java.lang.Object f, int len, java.lang.Object x)
toBody
private static java.lang.Object toBody(java.lang.Object exps)
- Handle internal defines, and convert a list of exps to a single exp.
Examples: (x) => (begin x), (x y) => (begin x y),
((define a 1) (+ a a)) => ((lambda (a) (begin (set! a 1) (+ a a))) #f)
extractDefines
private static Pair extractDefines(Pair defines, Pair body)
- Return a Pair who's first is a list of simple defines and who's
rest is the remaining body.
checkForDefines
private static java.lang.Object checkForDefines(Pair body)
- Check for embedded defines
this checks for any improperly embedded defines
and also flattens the body
startsWith
private static boolean startsWith(java.lang.Object list, java.lang.Object atom)
- Is the first element of the list identical to the given atom?
simplifyDefine
private static Pair simplifyDefine(Pair definition)
executeButLast
private static java.lang.Object executeButLast(java.lang.Object[] xv, Environment env)
- Evaluate
|
|||||||||
| Home >> All >> [ silk overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
silk.Scheme