开发者

Are there any really simple/limited scripting languages for the JVM/BSF?

I'm looking for a really simple / limited scripting language for the JVM or the Bean Scripting Framework but can't find any.

I need the following operators:

  • +
  • -
  • *
  • /
  • maybe ** (power)
  • maybe sqrt

... and the ability to define Double type variables to create expressions like

(A+B)/2

The script may not call any JVM code (ma开发者_如何学编程ybe with the exception of a Math class, but that's optional).

What options do i have?

I know I could just write that kind of thing myself, but I would prefer a tested, stable and fast solution. I tried Groovy before and really like it... but it's hard no to give my users the full power over the JVM with it.


There are no language that are as simple as I need them, so I will define one myself using ANTLR. The best example I found so far is in this answer.


I think JEXL fits the bill.

Also, to create a sandbox for your expressions look at this question.


check out FScript, maybe


Try BeanShell. It's super simple and has the same syntax as Java (although you can generally use shorthand bean accesor notation). It's a great tool for embedding debugging and management capabilities into a running JVM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜