JEP myParser = new JEP();
myParser.addStandardFunctions();
myParser.parseExpression("10 * log( 12345 / ( (5 ^ 2) * 3) )");
System.out.println(myParser.getValue());
If you try and do
myParser.parseExpression("10 * log10( 12345 / ( (5 ^ 2) * 3) )");
Jep does not understand "log10" is a function and interprets it as "log * 10" using implicit multiplication.
However unless you explicitly call myParser.setImplicitMul(true); it will not allow implicit multiplication and raise an exception.
Thank you for the quick reply.
I tried to use it as "log" in my expression like you mentioned but I get the error "Syntax Error (implicit multiplication not enabled)".
This is how my parser has been set up
org.nfunk.jep.JEP myParser = new org.nfunk.jep.JEP();
myParser.setAllowUndeclared(true);
Node node = jep.parseExpression(test);
if ( jep.hasError()) {
System.out.println("ERROR: " + jep.getErrorInfo());
}
I can only make it work if I use a later version of JEP. I used the trial version 3.3.0 of the Jep parser as
Jep jep = new Jep();
Node node = jep.parse(test);
com.singularsys.jep.walkers.TreeAnalyzer ta = new com.singularsys.jep.walkers.TreeAnalyzer(node);
System.out.println(ta.toString());
Is it that version 2.4.1 does not support function parsing?
Yes that's correct
--
You received this message because you are subscribed to the Google Groups "Jep Java Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-users+...@googlegroups.com.
To post to this group, send email to jep-...@googlegroups.com.
Visit this group at http://groups.google.com/group/jep-users.
For more options, visit https://groups.google.com/d/optout.