w*r 发帖数: 64 | 1 需要用一个简单的math expression parser。类似于做:
f(x1, x2,... xn) = (a1x1 + x2 *x3)*a2 -x4 ..
基本上都是四则运算。有没有什么open source的上手就可以用的library?谢谢! | m******t 发帖数: 2416 | 2
antlr? It's fairly straightfoward.
【在 w*r 的大作中提到】 : 需要用一个简单的math expression parser。类似于做: : f(x1, x2,... xn) = (a1x1 + x2 *x3)*a2 -x4 .. : 基本上都是四则运算。有没有什么open source的上手就可以用的library?谢谢!
| F****n 发帖数: 3271 | 3 Why not use Rhino, hoho.
【在 m******t 的大作中提到】 : : antlr? It's fairly straightfoward.
| c*****t 发帖数: 1879 | 4 No need to use antlr. My CookCC is smaller, faster and better :)
In fact, operator precedence is the worst nightmare for LL parsers
such as antlr.
CookCC even comes with a calculator example (well, a mini script
interpreter of a few hundred lines) that you just need to do minor
modifcations:
http://code.google.com/p/cookcc/source/browse/trunk/tests/javaap/calc/Calculator.java
【在 m******t 的大作中提到】 : : antlr? It's fairly straightfoward.
| w*r 发帖数: 64 | 5 thanks!
永远向唐僧大师学习!
【在 c*****t 的大作中提到】 : No need to use antlr. My CookCC is smaller, faster and better :) : In fact, operator precedence is the worst nightmare for LL parsers : such as antlr. : CookCC even comes with a calculator example (well, a mini script : interpreter of a few hundred lines) that you just need to do minor : modifcations: : http://code.google.com/p/cookcc/source/browse/trunk/tests/javaap/calc/Calculator.java
|
|