We have an application that allows users to enter conditionals in the form
bound op x op bound2, we store this as a string, and then parse it at runtime to evaluate it.
It is a decent amount of work, for a very limited conditional statement.
We are looking for a way to serialize and then evaluate complex conditions, with at least a switch statement level of complexity.
I saw in this question How to serialize and deserialize lambda expression in F#? that in f# you can just serialize a lambda (and I assume that there is some way to get a lambda from a text string), but:
- We need to do this in Java
- I know that we can compile java code on the fly, and make it "safe" by stripping out keywords, and disallowing things like
System.but even if its not a security nightmare, it is prohibitively computationally expensive to do thousands of times.
Does anyone know of a small language out there whose interpreter can do just the basics (conditionals, loops, variable assignment) and be run in/as java, or any way to run those types of expression as they are defined at runtime and need to be persisted.
Update: To be clear, the minimum functionality I need is an if else chain. I don't just need to evaluate one condition. The one condition is what I have now already.