Jep 3.2 - Java Expression Parser
JEP is a Java library for parsing and evaluating mathematical expressions. With this package you can allow your users to enter an arbitrary formula as a string, and instantly evaluate it. JEP supports user defined variables, constants, and functions. A number of common mathematical functions and constants are included.
As of February, a new release of Jep is available! We made a bunch of improvements to the configurable parser component, making it even more powerful than before. Additionally you can now analyse parsed expressions, parse multiple expressions separated by semi-colons, and much more.
See the Jep web site for more information: http://www.singularsys.com/jep
Changes from Jep 3.1 to 3.2:
General Changes:
- Added support for expression tree analysis using TreeAnalyser
- Fixed errors in the documentation of the default configuration
- Improved the operator table
Changes to the configurable parser:
- New StandardConfigurableParser class
- Parse error reporting with line and column numbers
- Added support for hexadecimal numbers (e.g.
0x1F) - Added support for bitwise operators (bitwise or:
a | b, bit shiftinga << 2) in BitwiseOperatorTable - Added support for
a?b:c,x+=1,++xsyntax - Added support for case-insensitive operators
- Added support for multiple expressions separated by semicolons
- Added support for multiple dimensional array access (
a[1][1]accesses the first element of a two-dimensional array) - Fixed issues with escape characters
- Fixed power and unary minus precedence to be consistent with the standard parser ("-3^2" should equal -9)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Artur Biesiadowski replied on Sat, 2008/03/01 - 4:41am
For people looking for something similar with bit better licensing terms, I would suggest Janino - I have quite pleasant experience with it. There is no extra math support like in JEP, but bit more on java evaluation part.
http://www.janino.net/
Raphael Valyi replied on Sat, 2008/03/01 - 9:37am
Hi
I remember considering using JEP some years ago and actually went for Fractal Aid (I can't really remember why, may be licensing had to be GPL compatible or beacause of the good documentation and very clean code). I've been very happy working with it, here is the link for anybody wanting to give it a try:
http://fraid.sourceforge.net/
BTW, I'm very eager to try mixing it with JRuby when I get some spare time.
Hope this helps,
Raphaël Valyi.
Nathan Funk replied on Sat, 2008/03/01 - 11:16am
There are some advantages that Jep has over Janino and FrAid. Here are some reasons why you might prefer Jep:
Of course everybody is free to evaluate for their specific use cases. If you have chosen other products after evaluating Jep, we would like to hear about it!
Nathan Funk
http://www.singularsys.com/jep
Ivaylo Iliev replied on Wed, 2008/04/30 - 12:37am
Hmm, the last posting needs some correction.
FrAid is 488KB but with:
In the form most comparable to JEP it is 217KB - http://fraid.sourceforge.net/begin/fraid_core.jar (and it is still a complete stand alone system, not parser only) I haven't used JEP and am not comparing it with FrAid, just happen to know FrAid...
Like the licensing argument as well ;)