|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.sns.tools.formula.FormulaGrammarBase
FormulaGrammarBase provides the foundation for the formula grammar.
It defines the constructs used by the grammar and is the abstract superclass
for the FormulaGrammar which is generated by the javacc tool.
| Field Summary | |
protected java.util.Map |
functionTable
A table of functions keyed by the function name. |
protected java.util.List |
operatorStack
Holds a list of operators in the order in which they should be evaluated. |
protected java.util.Map |
variableTable
A table of variables keyed by the variable name. |
| Constructor Summary | |
FormulaGrammarBase()
Creates a new instance of FormulaParserBase. |
|
| Method Summary | |
protected void |
addBaseFunctions()
Instantiate common math functions and add them to the function table. |
void |
addFunction(Function function)
Add a function a function to the function lookup table. |
java.util.List |
compile(java.lang.String formulaStr)
Parse the formula and compile the operations for performance. |
abstract int |
formula()
parse one line of code i.e. |
gov.sns.tools.formula.Variable |
getVariable(java.lang.String name)
Lookup the variable with the given name. |
boolean |
hasVariable(java.lang.String name)
Determine if a variable of the specified name exists. |
abstract void |
ReInit(java.io.Reader reader)
re-initialize the parser |
void |
setVariable(java.lang.String name,
double value)
Set the named variable to have the specified value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.List operatorStack
protected java.util.Map variableTable
protected java.util.Map functionTable
| Constructor Detail |
public FormulaGrammarBase()
| Method Detail |
protected void addBaseFunctions()
public final void addFunction(Function function)
function - the function to add to the function lookup table
public final void setVariable(java.lang.String name,
double value)
name - the name of the variablevalue - the value to assign to the variablepublic final gov.sns.tools.formula.Variable getVariable(java.lang.String name)
name - the name of the variable to fetchpublic final boolean hasVariable(java.lang.String name)
name - The name of the variable for which to check.
public final java.util.List compile(java.lang.String formulaStr)
throws ParseException
formulaStr - String representation of the formula.
ParseException - Exception if there is a parse error while parsing the formula.
public abstract int formula()
throws ParseException
ParseExceptionpublic abstract void ReInit(java.io.Reader reader)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||