3

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 (maybe 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.

arturh
  • 6,056
  • 4
  • 39
  • 48

4 Answers4

3

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.

Community
  • 1
  • 1
arturh
  • 6,056
  • 4
  • 39
  • 48
2

I think JEXL fits the bill.

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

Community
  • 1
  • 1
Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
  • There were some recent posts to the JEXL mailing list about getting the power operator precedence to work right and I think it did not work correctly. Better check that out and see if it applies to you. – Sarel Botha Dec 07 '11 at 17:52
1

check out FScript, maybe

trigan-d
  • 11
  • 1
  • looks like the best option yet, althrough they seem to allow access to java classes in the latest version. but I'll try using an older version of it. Thanks!! – arturh Dec 15 '09 at 09:31
0

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.

Joel
  • 29,538
  • 35
  • 110
  • 138