csheets.core.formula.compiler
Class ExcelExpressionCompiler

java.lang.Object
  extended by csheets.core.formula.compiler.ExcelExpressionCompiler
All Implemented Interfaces:
ExpressionCompiler

public class ExcelExpressionCompiler
extends Object
implements ExpressionCompiler

A compiler that generates Excel-style formulas from strings.

Author:
Einar Pehrson

Field Summary
static char FORMULA_STARTER
          The character that signals that a cell's content is a formula ('=')
 
Constructor Summary
ExcelExpressionCompiler()
          Creates the Excel expression compiler.
 
Method Summary
 Expression compile(Cell cell, String source)
          Compiles an expression from the given string.
protected  Expression convert(Cell cell, antlr.collections.AST node)
          Converts the given ANTLR AST to an expression.
 char getStarter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMULA_STARTER

public static final char FORMULA_STARTER
The character that signals that a cell's content is a formula ('=')

See Also:
Constant Field Values
Constructor Detail

ExcelExpressionCompiler

public ExcelExpressionCompiler()
Creates the Excel expression compiler.

Method Detail

getStarter

public char getStarter()
Specified by:
getStarter in interface ExpressionCompiler
Returns:
the

compile

public Expression compile(Cell cell,
                          String source)
                   throws FormulaCompilationException
Description copied from interface: ExpressionCompiler
Compiles an expression from the given string.

Specified by:
compile in interface ExpressionCompiler
Parameters:
cell - the cell for which the expression is to be compiled
source - a string representing the expression to be compiled
Returns:
the compiled expression
Throws:
FormulaCompilationException - if the expression could not be compiled

convert

protected Expression convert(Cell cell,
                             antlr.collections.AST node)
                      throws FormulaCompilationException
Converts the given ANTLR AST to an expression.

Parameters:
node - the abstract syntax tree node to convert
Returns:
the result of the conversion
Throws:
FormulaCompilationException