org.statcato.calculator
Class MathExpParserComplete

java.lang.Object
  extended by org.statcato.calculator.MathExpParserComplete

public class MathExpParserComplete
extends java.lang.Object

A parser for mathematical expressions using the recurive descent algorithm. Acceptable expressions are defined by the following grammar:

E -> T { ("+" | "-") T}
T -> F { ("*" | "/") F}
F -> P {"^" F}
P -> v | "(" E ")" | "-" T | func_name"(" E ")" | Cx | "'" L "'"
L -> column_label

where expressions enclosed by { } can appear zero or more times.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
MathExpParserComplete(Spreadsheet sp)
           
 
Method Summary
 java.lang.String getError()
          Returns error message from the scanner.
 CompUnit parse(java.lang.String exp, boolean isRadian)
          Parses the given expression.
 CompUnit S()
          Parses a statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathExpParserComplete

public MathExpParserComplete(Spreadsheet sp)
Method Detail

parse

public CompUnit parse(java.lang.String exp,
                      boolean isRadian)
Parses the given expression.

Parameters:
exp - expression in string
isRadian - boolean value of whether radians are used

getError

public java.lang.String getError()
Returns error message from the scanner.

Returns:
error string

S

public CompUnit S()
Parses a statement. S->E

Returns:
the value of a statement