I have an app that needs to read in and evaluate expressions from a source file. I've been using muParser to do this so far. But now I've run into a case where I need simple loop support in the expression. I don't need the ability to call functions from the scripting language, or any other advanced functionality, literally just:
- mathematical expressions (+,-,/,*,&, |, ~, etc)
- logical expressions (!, ||, &&, etc)
- conditionals (if,else..)
- loops (for)
With muParser I parsed the expressions after reading them in, assigning variables as needed and then solving:
expr="[0] + [1]*256 - 40"
In the above example, I'd replace [0] and [1] with their corresponding variables, and could then solve. Now, I need something like this:
expr="for(i=0; i < 10; i+=2) { if(i<=6) { [0] + [i]*256 -40; } }"
All I'm doing in reality is parsing a bytestream. In the script, I refer to bytes as [byte] and bits as [byte][bit]. Could someone suggest what a good framework/scripting launguage would let me do something like this?