org.rubato.scheme
Class Evaluator

java.lang.Object
  extended by org.rubato.scheme.Evaluator

public class Evaluator
extends java.lang.Object

This class provides the means for evaluating Scheme expressions.

Author:
Gérard Milmeister

Constructor Summary
Evaluator()
          Creates an evaluator with a global environment as the initial environment.
Evaluator(Env env)
          Creates an evaluator with the specified initial environment.
 
Method Summary
 void addError(java.lang.String msg, java.lang.Object... objects)
          Adds a new error message.
 void clearErrors()
          Removes all errors that occurred during the last evaluation.
 SExpr eval(java.util.List<SExpr> sexpr_list)
          Evaluates the specified list of expressions in the initial environment.
 SExpr eval(SExpr sexpr)
          Evaluates the specified expression in the initial environment.
 SExpr eval(SExpr sexpr, Env env)
          Evaluates the specified expression in the given environment env.
 SExpr eval(java.lang.String s)
          Parses and evaluates the code s in the initial environment.
 SInPort getCurrentInputPort()
          Returns the current input port.
 SOutPort getCurrentOutputPort()
          Returns the current output port.
 java.util.List<java.lang.String> getErrors()
          Returns the list of errors that occurred during the last evaluation.
 boolean hasErrors()
          Returns true iff the last evaluation had errors.
 void resetGlobal()
          Resets the initial environment to the global environment.
 void setEnvironment(Env env)
          Sets the initial environment to env.
 void setRunInfo(RunInfo runInfo)
          Sets the runinfo for the next evaluation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Evaluator

public Evaluator()
Creates an evaluator with a global environment as the initial environment.


Evaluator

public Evaluator(Env env)
Creates an evaluator with the specified initial environment.

Method Detail

resetGlobal

public void resetGlobal()
Resets the initial environment to the global environment.


setEnvironment

public void setEnvironment(Env env)
Sets the initial environment to env.


setRunInfo

public void setRunInfo(RunInfo runInfo)
Sets the runinfo for the next evaluation. The evaluator periodically checks this object and terminates whenever runInfo.stopped() is true.


eval

public SExpr eval(java.lang.String s)
Parses and evaluates the code s in the initial environment.


eval

public SExpr eval(java.util.List<SExpr> sexpr_list)
Evaluates the specified list of expressions in the initial environment.


eval

public SExpr eval(SExpr sexpr)
Evaluates the specified expression in the initial environment.


eval

public SExpr eval(SExpr sexpr,
                  Env env)
Evaluates the specified expression in the given environment env.


clearErrors

public final void clearErrors()
Removes all errors that occurred during the last evaluation.


getErrors

public final java.util.List<java.lang.String> getErrors()
Returns the list of errors that occurred during the last evaluation.


addError

public final void addError(java.lang.String msg,
                           java.lang.Object... objects)
Adds a new error message.


hasErrors

public final boolean hasErrors()
Returns true iff the last evaluation had errors.


getCurrentOutputPort

public SOutPort getCurrentOutputPort()
Returns the current output port.


getCurrentInputPort

public SInPort getCurrentInputPort()
Returns the current input port.