| java.lang.Object jsint.Scheme
Scheme | public class Scheme (Code) | | This class represents a Scheme interpreter.
author: Peter Norvig, Copyright 1998, peter@norvig.com, license author: subsequently modified by Jscheme project members author: licensed under zlib licence (see license.txt) |
Method Summary | |
public static Evaluator | currentEvaluator() | public static void | defaultMain(String[] files) The default main() behavior. | public static Boolean | environmentImport(Object x, Object prefix) | public static Object | eval(Object x) Evaluate an s-expression in the global environment. | public static Object | eval(Object x, Object env) Evaluate an s-expression in a lexical environment. | public static Object | evalToplevel(Object x, DynamicEnvironment env) evalToplevel evaluates each element of a BEGIN. | public static DynamicEnvironment | getInitialEnvironment() | public static DynamicEnvironment | getInteractionEnvironment() | public static DynamicEnvironment | getNullEnvironment() | public static void | interruptCheck() Maybe interrupt this thread of execution. | public static boolean | isInterruptable() | public static Boolean | languageImport(Object x) | public static Object | load(Object fileName) Eval all the expressions in a file. | public static Object | load(InputPort in) | public static DynamicEnvironment | loadEnvironment(Object x) load the current file (or class) into a new initial environment
and return the resulting DynamicEnvironment. | public static boolean | loadInit() | public static void | main(String[] files) The following steps are performed
- If an "init.scm" resource or file is found, it is loaded.
It is expected to do all the processing, for example interpreting
command line arguments.
- Otherwise command line arguments are processed as follows:
- If the argument "-main" is seen, the next argument is
either "none" indicating that no main will be started, or the
name of a Scheme procedure or Java reflector to be invoked.
| public static InputPort | open(String name) | public static InputPort | openFile(String name) | public static InputPort | openResource(String name) | public static InputPort | openURL(String url) | public static Evaluator | popEvaluator() | public static void | pushEvaluator(Evaluator i) | public static void | readEvalWriteLoop(String prompt) Prompt, read, eval, and write the result.
Also sets up a catch for any RuntimeExceptions encountered. | public static void | runJscheme() | public static Object | toBody(Object exps) Handle internal defines, and convert a list of exps to a single exp. |
ARGS | public static String[] ARGS(Code) | | The main() arguments *
|
defaultMain | public static void defaultMain(String[] files)(Code) | | The default main() behavior. *
|
eval | public static Object eval(Object x)(Code) | | Evaluate an s-expression in the global environment. *
|
eval | public static Object eval(Object x, Object env)(Code) | | Evaluate an s-expression in a lexical environment. First analyze
it.
|
evalToplevel | public static Object evalToplevel(Object x, DynamicEnvironment env)(Code) | | evalToplevel evaluates each element of a BEGIN. This is so
macros can be defined and then used. Also toplevel macros can
expand into begin.
|
interruptCheck | public static void interruptCheck()(Code) | | Maybe interrupt this thread of execution. *
|
isInterruptable | public static boolean isInterruptable()(Code) | | |
load | public static Object load(Object fileName)(Code) | | Eval all the expressions in a file. Calls load(InputPort). *
|
loadEnvironment | public static DynamicEnvironment loadEnvironment(Object x)(Code) | | load the current file (or class) into a new initial environment
and return the resulting DynamicEnvironment.
|
loadInit | public static boolean loadInit()(Code) | | |
main | public static void main(String[] files)(Code) | | The following steps are performed
- If an "init.scm" resource or file is found, it is loaded.
It is expected to do all the processing, for example interpreting
command line arguments.
- Otherwise command line arguments are processed as follows:
- If the argument "-main" is seen, the next argument is
either "none" indicating that no main will be started, or the
name of a Scheme procedure or Java reflector to be invoked. All
of the remaining arguments are passed to it as a
String[].
- An argument beginning with "(" is read and evaluated as a
Scheme expression.
- Otherwise, the argument is treated as a file, resource or URL to
be loaded.
By putting the init.scm in a .jar file with the manifest
entry:
Main-Class: jsint.Scheme
you get scriptable jar files that can be invoked by:
java -jar name.jar
This idea was suggested by David May david@davudsplace.net.
By adding command line arguments or providing your own
init.scm file you can override the init.scm file in the .jar to
tailor your application.
|
readEvalWriteLoop | public static void readEvalWriteLoop(String prompt)(Code) | | Prompt, read, eval, and write the result.
Also sets up a catch for any RuntimeExceptions encountered. *
|
runJscheme | public static void runJscheme()(Code) | | |
toBody | public static Object toBody(Object exps)(Code) | | 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)
|
|
|