Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.util.lisp
Class Interpreter

    java.lang.Object
      ix.util.lisp.Interpreter

Direct Known Subclasses:
  LispInterpreter

    public abstract class Interpreter

extends java.lang.Object

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.
`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 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` | `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

### DEFAULT

    protected java.lang.Object DEFAULT

  The value this interpreter thinks expressions should return when they cannot determine any more appropriate value.

### TRUE

    protected static java.lang.Object TRUE

  The value that an interpreter thinks should be used by default to represent truth. It is the same as Boolean.TRUE.

### FALSE

    protected static java.lang.Object FALSE

  The value that an interpreter thinks should be used by default to represent falsity. It is the same as Boolean.FALSE.

### globalEnv

    protected Interpreter.GlobalEnv globalEnv

  This interpreter's global / top-level environment.

### iscript

    protected static IScript iscript

  An IScript factory used when constructing external forms.

Constructor Detail

### Interpreter

    public Interpreter()

  Constructs an interpreter.

Method Detail

### isTrue

    public boolean isTrue(java.lang.Object obj)

  Determines whether this interpreter regards the object as true; otherwise, the object is considered false.

  Note that expressions do not call this method directly. Instead, they must call the `Interpreter.Env.isTrue(Object)` method of an environment.

### topLevelEval

    public java.lang.Object topLevelEval(Interpreter.Expr e)

  Evaluates the expression in the top-level enviromnent of this interpreter.

### topLevelApply

    public java.lang.Object topLevelApply(java.lang.Object function,
                                          java.lang.Object[] args)

  Applies the function to the specified arguments. Note that the function may be given as a name (`Symbol`) rather than as an instance of `Interpreter.Function`. If so, the name is looked up in the top-level environment of this interpreter.

### nameForClass

    protected static java.lang.String nameForClass(java.lang.Class c)

  A utility that returns a relatively readable name for a class.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD