jsint
Class Scheme

java.lang.Object
  extended byjsint.Scheme

public class Scheme
extends java.lang.Object

This class represents a Scheme interpreter.

Author:
Peter Norvig, Copyright 1998, peter@norvig.com, license subsequently modified by Jscheme project members licensed under zlib licence (see license.txt)

Field Summary
static java.lang.String[] ARGS
          The main() arguments
 
Constructor Summary
Scheme()
           
 
Method Summary
static Evaluator currentEvaluator()
           
static void defaultMain(java.lang.String[] files)
          The default main() behavior.
static java.lang.Boolean environmentImport(java.lang.Object x, java.lang.Object prefix)
           
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, java.lang.Object env)
          Evaluate an s-expression in a lexical environment.
static java.lang.Object evalToplevel(java.lang.Object x, DynamicEnvironment env)
          evalToplevel evaluates each element of a BEGIN.
static DynamicEnvironment getInitialEnvironment()
           
static DynamicEnvironment getInteractionEnvironment()
           
static DynamicEnvironment getNullEnvironment()
           
static void interruptCheck()
          Maybe interrupt this thread of execution.
static boolean isInterruptable()
           
static java.lang.Boolean languageImport(java.lang.Object x)
           
static java.lang.Object load(InputPort in)
           
static java.lang.Object load(java.lang.Object fileName)
          Eval all the expressions in a file.
static DynamicEnvironment loadEnvironment(java.lang.Object x)
          load the current file (or class) into a new initial environment and return the resulting DynamicEnvironment.
static boolean loadInit()
           
static void main(java.lang.String[] files)
          The following steps are performed If an "init.scm" resource or file is found, it is loaded.
static InputPort open(java.lang.String name)
           
static InputPort openFile(java.lang.String name)
           
static InputPort openResource(java.lang.String name)
           
static InputPort openURL(java.lang.String url)
           
static Evaluator popEvaluator()
           
static void pushEvaluator(Evaluator i)
           
static void readEvalWriteLoop(java.lang.String prompt)
          Prompt, read, eval, and write the result.
static void runJscheme()
           
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

ARGS

public static java.lang.String[] ARGS
The main() arguments

Constructor Detail

Scheme

public Scheme()
Method Detail

isInterruptable

public static boolean isInterruptable()

interruptCheck

public static void interruptCheck()
Maybe interrupt this thread of execution.


currentEvaluator

public static Evaluator currentEvaluator()

pushEvaluator

public static void pushEvaluator(Evaluator i)

popEvaluator

public static Evaluator popEvaluator()

getInteractionEnvironment

public static DynamicEnvironment getInteractionEnvironment()

getNullEnvironment

public static DynamicEnvironment getNullEnvironment()

getInitialEnvironment

public static DynamicEnvironment getInitialEnvironment()

main

public static void main(java.lang.String[] files)
The following steps are performed

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.


defaultMain

public static void defaultMain(java.lang.String[] files)
The default main() behavior.


runJscheme

public static void runJscheme()

readEvalWriteLoop

public static void readEvalWriteLoop(java.lang.String prompt)
Prompt, read, eval, and write the result. Also sets up a catch for any RuntimeExceptions encountered.


loadInit

public static boolean loadInit()

load

public static java.lang.Object load(java.lang.Object fileName)
Eval all the expressions in a file. Calls load(InputPort).


loadEnvironment

public static DynamicEnvironment loadEnvironment(java.lang.Object x)
load the current file (or class) into a new initial environment and return the resulting DynamicEnvironment.


environmentImport

public static java.lang.Boolean environmentImport(java.lang.Object x,
                                                  java.lang.Object prefix)

languageImport

public static java.lang.Boolean languageImport(java.lang.Object x)

open

public static InputPort open(java.lang.String name)

openURL

public static InputPort openURL(java.lang.String url)

openFile

public static InputPort openFile(java.lang.String name)

openResource

public static InputPort openResource(java.lang.String name)

load

public static java.lang.Object load(InputPort in)

evalToplevel

public static java.lang.Object evalToplevel(java.lang.Object x,
                                            DynamicEnvironment env)
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,
                                    java.lang.Object env)
Evaluate an s-expression in a lexical environment. First analyze it.


toBody

public 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)