de.dante.extex.interpreter.expression
Class Evaluator

java.lang.Object
  extended byde.dante.extex.interpreter.expression.Evaluator
Direct Known Subclasses:
ExTeXEvaluator, TeXEvaluator

public class Evaluator
extends java.lang.Object

This class provides some static methods to parse an expression and return its value.

Version:
$Revision: 1.1 $
Author:
Gerd Neugebauer

Constructor Summary
Evaluator()
          Creates a new object.
 
Method Summary
 void eval(EType term, Context context, TokenSource source, Typesetter typesetter)
          Creates a new object from a token stream.
 void register(ETypeParser parser)
          Register a Terminal for usage.
 void register(java.lang.String name, de.dante.extex.interpreter.expression.BinaryFunction function)
          Register a binary function in the evaluator.
 void register(java.lang.String name, ConstantFunction function)
          Register a constant in the evaluator.
 void register(java.lang.String name, ParsingFunction function)
          Register a function in the evaluator.
 void register(java.lang.String name, UnaryFunction function)
          Register a unary function in the evaluator.
protected static void skipComma(Context context, TokenSource source)
          Find the next comma after any white-space and discard it and the white-space afterwards.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Evaluator

public Evaluator()
Creates a new object.

Method Detail

skipComma

protected static void skipComma(Context context,
                                TokenSource source)
                         throws InterpreterException
Find the next comma after any white-space and discard it and the white-space afterwards.

Parameters:
context - the interpreter context
source - the source for new tokens
Throws:
InterpreterException - in case of an error

eval

public void eval(EType term,
                 Context context,
                 TokenSource source,
                 Typesetter typesetter)
          throws InterpreterException
Creates a new object from a token stream.

Parameters:
term - the terminal to store the result in
context - the interpreter context
source - the source for next tokens
typesetter - the typesetter
Throws:
InterpreterException - in case of an error

register

public void register(ETypeParser parser)
Register a Terminal for usage. the registered instance is used to access the parser and converter methods.

Parameters:
parser - the terminal parser instance

register

public void register(java.lang.String name,
                     ParsingFunction function)
Register a function in the evaluator.

Parameters:
name - the name of the function in the expression
function - the function object

register

public void register(java.lang.String name,
                     ConstantFunction function)
Register a constant in the evaluator.

Parameters:
name - the name of the function in the expression
function - the function object

register

public void register(java.lang.String name,
                     UnaryFunction function)
Register a unary function in the evaluator.

Parameters:
name - the name of the function in the expression
function - the function object

register

public void register(java.lang.String name,
                     de.dante.extex.interpreter.expression.BinaryFunction function)
Register a binary function in the evaluator.

Parameters:
name - the name of the function in the expression
function - the function object