org.mmbase.util
Class ExprCalc
java.lang.Object
org.mmbase.util.ExprCalc
public class ExprCalc
- extends Object
Class to calculate expressions. It implements a simple LL(1)
grammar to calculate simple expressions with the basic
operators +,-,*,/ and brackets.
The grammar in EBNF notation:
<expr> -> <term> { '+' <term> } | <term> { '-' <term> }
<term> -> <fact> { '*' <fact> } | <fact> { '/' <fact> }
<fact> -> <nmeral> | '(' <expr> ')'
- Version:
- $Id: ExprCalc.java 41055 2010-02-15 23:59:16Z michiel $
- Author:
- Arnold Beck
|
Method Summary |
double |
getResult()
Returns the calculated value of the expression |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExprCalc
public ExprCalc(String input)
- Constructor of ExrpCalc
- Parameters:
input - a String representing the expression
getResult
public double getResult()
- Returns the calculated value of the expression
MMBase 2.0-SNAPSHOT - null