MVEL 验证没有值的算术表达式

问题描述

我想在不提供输入或值的情况下验证给定的算术表达式 (a+b) 是否有效。 我尝试使用 ExpressionCompilerMVEL.compileExpression() 如下,

String expression = "a+b";
ExpressionCompiler c = new ExpressionCompiler(formula,ctx );
//c.setVerifyOnly(true); // tried this but didn't help
c.compile() // this will throw exception if expression is invalid

这适用于大多数情况,例如 a+b*,但是当表达式为 a+b) 时,这被编译为有效表达式,编译器不会抱怨额外的括号。

有什么办法可以让MVEL来验证这种a+b)类的表达式吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)