Java 1.5: mathematical formula parser

自闭症网瘾萝莉.ら 提交于 2019-12-01 19:31:42

Have you thought about the benefits of JSR-223 ? in a few words, this spec allows Java developers to integrate with great ease dynamic languages and their parsers. Using such parser, your need for defining a parser transforms into the need for defining an internal DSL, which resolves into creating simply a good API, and letting your user choose wether they prefer Javascript/Groovy/Scala/WTF syntax they happen to prefer.

Try JEP.

You can define new variables to the parser hence it can contain reference names like "INTEREST_RATE".But you have to define it before hand.

As for cell references you will have to extract the number's and edit the expression accordingly or probably there might be some options which I'm not yet aware of.

If you can't use Java 6 and its scripting support then have a look at the Apache Bean Scripting Framework (BSF). From that page:

... BSF 3.x will run on Java 1.4+, allowing access to JSR-223 scripting for Java 1.4 and Java 1.5.

i released an expression evaluator based on Dijkstra's Shunting Yard algorithm, under the terms of the Apache License 2.0:

http://projects.congrace.de/exp4j/index.html

There's a commercial tool called formula4j which may be useful to some.

It has no direct help for cell references. You would have to handle those yourself, and translate the cell references into values.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!