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,v 1.12 2004/09/29 14:29:24 pierre Exp $
- 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 build 1.8.1.20060716