org.mmbase.util
Class ExprCalc

java.lang.Object
  |
  +--org.mmbase.util.ExprCalc

public class ExprCalc
extends java.lang.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> ')'

Author:
Arnold Beck

Constructor Summary
ExprCalc(java.lang.String input)
          Constructor of ExrpCalc
 
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
 

Constructor Detail

ExprCalc

public ExprCalc(java.lang.String input)
Constructor of ExrpCalc
Parameters:
input - a String representing the expression
Method Detail

getResult

public double getResult()
Returns the calculated value of the expression


MMBase 2001