You can actually do it in the same way with event as you can with code. I've done it a few times. The last one was here:
Most of it was syntax error checking though.
Basically it grabs a token at a time from the string while skipping over spaces. regex could have been used to assist with that but I opted not to use it. After that it gives me a list of tokens which i then feed into this:
Which converts it to reverse polish notation, while preserving the order of operations. Then it becomes simple to eval from left to right. I didn't get around to implementing variables here, but it was on paper.
The main drawback is it can be a lot of events.
Magistross' suggestion would be by far the simplest. Although you wouldn't have control over what js code was run.