It all depends on what you really want to do with your language. I would suggest that you really do not want the user to run arbitrary javascript that runs in the same global space in which your application lives.
So, depending on what you really want to do, you do not have to use eval() . For example, let's take your statement:
variable "helloWorld" = 5
Suppose you parse this and you parse it into an assertion object with four elements in an array:
var statement = ["variable", "helloWorld", "=", 5];
OK, you can see from the first element of the array that the user is declaring a variable. Now you probably don't want user variables to fall into the global namespace (another reason not to use eval() . Therefore, instead you create an object for user variables:
var userVars = {};
Now, when you process this above statement, you will see that this is the assignment of a user variable that you simply translate into:
userVars[statement[1]] = statement[3];
You now have an object in a variable named userVars with a property named "helloWorld" with a value of 5 . None of the user variables in the global namespace can affect the operation of your own programs.
Now, obviously, if you want to get detailed expressions and a logical stream, then everything becomes more complicated, but this, I hope you will see how you can simply not use eval() in the global namespace.
Another "safe" way to execute arbitrary user javascript is to place it in an iframe hosted by a different domain than your main web page. You can send JS to your server and transfer it to another server (possibly in the same field), which then serves as an iframe, or you can use window.postMessage() to deliver JS text to another cooperating iframe and execute it.
Since the iframe is hosted in a different domain, it is isolated from your own web page and your own web application server. This is basically how jsFiddle works and allows the user to run arbitrary javascript while keeping the native application safe from many attacks.
Or, in the spirit of using window.postMesage() for an isolated iframe, you can even use eval() in this other iframe. If the JS user point needs to interact with your game, then you will need to figure out how to allow two iframes to talk to each other, but do it safely. This can be done using window.postMessage() , which is supported in IE8 or later.
The beauty of an isolated iframe is that it has its own isolated set of globals, and it cannot really conflict with your game, except through the whateve interface that you open through window.postMessage() .