This
is a simple (but powerful) infix
expression evaluator.
Evaluating an expression is as simple as the following line :
Double result = new DoubleEvaluator().evaluate(expression);
Key features:
- Functions support: including variable number of arguments and
functions with no argument.
- Constants support: for example pi and e when evaluating expressions
on doubles.
- Variables support: Expressions can include variables (example
"sin(x)").
- Highly configurable: This library comes with a lot of built-in functions
and operators, it is very easy to reduce the number of them (for example,
the trigonometric functions can be removed from the function set if you want to implement
a financial calculator).
It's also easy to define your own bracket pairs ({},[], etc ...) or to add
your own operators, functions or constants.
- Localization: Function and constant's names can be changed easily.
- Extensible: This library is provided with an evaluator that deals
with expression on real numbers, if you need one on complex numbers, or anything
else, you can implement your own.
- Full expression syntax check: Basic infix evaluators consider expressions
such as "4 3 +" as valid expressions. Javaluator performs a full syntax check
while evaluating the expression.
- Small footprint: This library is distributed as a 16kB jar. It needs
no external library in order to run.
Limitations:
- Only one character long operators are supported.
- Only unary and binary operators are supported (ternary operators such as condition?value if true:value if false are not).
- Non-associative operators are not supported.
License information is available there.