I recently did a program which must read some custom script. It is lacking of flexibility, however it's "crash-proof".
Here's the code of the interesting part :
https://pastebin.com/hgutDNVR
And here's an example of script :
https://pastebin.com/L3KDdz3d
Basically, the user can :
- Create and manage variables (up to 42)
- use mathematical tests/operators
A+3+8 is working, but sometimes using multiples operator on one line can result in wrong calculation.
- can use goto, labels, and other cursor moving command
- can use "program commands" (which interacts with the program and can't be scripted) and replace portions of the command arg by the content of variables
- do "IF" test (and some loop combined with the goto)
That was hard and it's clearly not a professionnal-quality-code (and it's lacking of fonctionnality), but it works with a good error checking a debug help for the user.