I'm currently working on a small project in java where I need to process a very lightweight scripting language for a robot that I've made up.
It doesn't need to deal with arithmetic or any complicated functionality, it only needs to run certain commands and deal with if and while statements.
It could look something like this:
turn(90,cw)
move(25)
sleep(5000)
get(temp)
turn(90,ccw)
get(image)
This is something that I've had no problem with and was able to get it working very quickly. However once I started considering if and while statements, I realised that things might be a lot more complex.
For instance, It would be quite simple to manage something like this:
while(temp > 50)
move(25)
turn(90,cw)
But I'm getting very confused as to how I can start to process statements like this:
while(temp > 50)
if(light < 100)
move(25)
turn(90,cw)
move(10)
Looking at it, I can see things getting very confusing very quickly!
Is there a preferred method for processing "lightweight scripts" like these? Or would I be better off just sticking with it and working out some kind of manual parser?
Thanks for any help you can give me!
EDIT - Thanks for the help everyone, I got it working really quickly using the Java Scripting Engine!