|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.util.lisp.Interpreter
public abstract class Interpreter
The skeleton of a progamming language interpreter. This class
implements a language that is semantically similar to a simple
version of Scheme without continuations. However, it doesn't
provide any syntax or built-in functions. It is expected that
they will be provided by a subclass. The subclass should produce
Expr
objects from whatever surface syntax
it desires. There are Expr classes for constants (literals),
variable references, conditional expressions, and so on. Functions
should implement the Function
interface.
Usually they will extend the JFunction
class.
Nested Class Summary | |
---|---|
protected class |
Interpreter.AbstractEnv
An implementation of Env that supplies some utility methods. |
static class |
Interpreter.AbstractFunction
An implementation of Function that supplies some utility methods and implements part of the interface. |
static class |
Interpreter.And
A conditional AND. |
static class |
Interpreter.Assignment
An assignment to a variable. |
static class |
Interpreter.Call
A function call. |
static class |
Interpreter.Closure
An interpreted function. |
static interface |
Interpreter.Env
The context in which an expression is evaluated. |
static class |
Interpreter.Error
The root class for exceptions thrown for error conditions detected by an Interpreter or by an expression. |
static class |
Interpreter.Expr
The root class for expressions. |
static interface |
Interpreter.Function
An object that represents a function that can be applied to arguments. |
class |
Interpreter.GlobalEnv
A global / top-level environment. |
static class |
Interpreter.If
A simple conditional expression. |
static class |
Interpreter.JFunction
A function implemented in Java. |
static class |
Interpreter.Lambda
An expression whose value is a function closed in the environment in which this Lambda is evaluated. |
static class |
Interpreter.Let
An expression that binds variables and then evaluates an expression in the resulting environment. |
class |
Interpreter.LexicalEnv
An environment for local values of variables. |
static class |
Interpreter.Literal
A reference to an object that is treated as a literal. |
static class |
Interpreter.Or
A conditional OR. |
static class |
Interpreter.Sequence
A sequence of expressions. |
static class |
Interpreter.VarRef
A reference to a variable. |
static class |
Interpreter.While
A while loop. |
Field Summary | |
---|---|
protected boolean |
acceptOnlySafeBuiltins
Controls whether only safe builtin functions are added. |
protected java.lang.Object |
DEFAULT
The value this interpreter thinks expressions should return when they cannot determine any more appropriate value. |
protected static java.lang.Object |
FALSE
The value that an interpreter thinks should be used by default to represent falsity. |
protected Interpreter.GlobalEnv |
globalEnv
This interpreter's global / top-level environment. |
protected static IScript |
iscript
An IScript factory used when constructing external forms. |
protected static java.lang.Object |
TRUE
The value that an interpreter thinks should be used by default to represent truth. |
Constructor Summary | |
---|---|
Interpreter()
Constructs an interpreter. |
Method Summary | |
---|---|
boolean |
isSafe()
Says whether the interpreter can safely be used in cases where you don't want the user to be able to do such things as call arbitrary Java methods, read or write files, or get other information about the host machine. |
boolean |
isTrue(java.lang.Object obj)
Determines whether this interpreter regards the object as true; otherwise, the object is considered false. |
protected static java.lang.String |
nameForClass(java.lang.Class c)
A utility that returns a relatively readable name for a class. |
java.lang.Object |
topLevelApply(java.lang.Object function,
java.lang.Object[] args)
Applies the function to the specified arguments. |
java.lang.Object |
topLevelEval(Interpreter.Expr e)
Evaluates the expression in the top-level enviromnent of this interpreter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object DEFAULT
protected static java.lang.Object TRUE
protected static java.lang.Object FALSE
protected Interpreter.GlobalEnv globalEnv
protected static IScript iscript
protected boolean acceptOnlySafeBuiltins
JFunction
is
added.
isSafe()
Constructor Detail |
---|
public Interpreter()
Method Detail |
---|
public boolean isTrue(java.lang.Object obj)
Note that expressions do not call this method directly.
Instead, they must call the Interpreter.Env.isTrue(Object)
method
of an environment.
public java.lang.Object topLevelEval(Interpreter.Expr e)
public java.lang.Object topLevelApply(java.lang.Object function, java.lang.Object[] args)
Symbol
)
rather than as an instance of Interpreter.Function
.
If so, the name is looked up in the top-level environment
of this interpreter.
public boolean isSafe()
acceptOnlySafeBuiltins
,
LispInterpreter.LispInterpreter(boolean beSafe)
protected static java.lang.String nameForClass(java.lang.Class c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |