csheets.core.formula.util
Class Interpreter

java.lang.Object
  extended by csheets.core.formula.util.Interpreter
All Implemented Interfaces:
ExpressionVisitor

public abstract class Interpreter
extends Object
implements ExpressionVisitor

A base-class for customized formula interpreters. The interpretation relies on the Visitor pattern, so a typical invocation would look like formula.accept(interpreter).

Author:
Einar Pehrson

Constructor Summary
Interpreter()
          Creates a new interpreter.
 
Method Summary
abstract  Value visitBinaryOperation(BinaryOperation operation)
          Visits the given binary expression.
abstract  Value visitFunctionCall(FunctionCall call)
          Visits the given function call.
 Value visitLiteral(Literal literal)
          Visits the given literal.
 Value visitReference(Reference reference)
          Visits the given cell reference.
abstract  Value visitUnaryOperation(UnaryOperation operation)
          Visits the given unary expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interpreter

public Interpreter()
Creates a new interpreter.

Method Detail

visitLiteral

public Value visitLiteral(Literal literal)
Description copied from interface: ExpressionVisitor
Visits the given literal.

Specified by:
visitLiteral in interface ExpressionVisitor
Parameters:
literal - the literal to visit
Returns:
an arbitrary object

visitUnaryOperation

public abstract Value visitUnaryOperation(UnaryOperation operation)
Description copied from interface: ExpressionVisitor
Visits the given unary expression.

Specified by:
visitUnaryOperation in interface ExpressionVisitor
Parameters:
operation - the operation to visit
Returns:
an arbitrary object

visitBinaryOperation

public abstract Value visitBinaryOperation(BinaryOperation operation)
Description copied from interface: ExpressionVisitor
Visits the given binary expression.

Specified by:
visitBinaryOperation in interface ExpressionVisitor
Parameters:
operation - the operation to visit
Returns:
an arbitrary object

visitReference

public Value visitReference(Reference reference)
Description copied from interface: ExpressionVisitor
Visits the given cell reference.

Specified by:
visitReference in interface ExpressionVisitor
Parameters:
reference - the reference to visit
Returns:
an arbitrary object

visitFunctionCall

public abstract Value visitFunctionCall(FunctionCall call)
Description copied from interface: ExpressionVisitor
Visits the given function call.

Specified by:
visitFunctionCall in interface ExpressionVisitor
Parameters:
call - the function call to visit
Returns:
an arbitrary object