eval()
eval(str) - evaluates/executes a string of GScript.
You asked for it and you got it. eval is a function available in other scripting languages. Its only parameter is a string of code to be executed. This is not so much to show off the script, but rather I hope I can get some input into what this function should do. Useful? Sure. You could save expressions such as "player.hp += this.hpgain;" in mudlib files, or similar. The possibilities are probably endless, but I'm just the guy doing the coding.
Currently supports:- strings, arrays, variables, functions, comments, operators
- error catching, garbage collection
- variable assignment toggling, protection
To be added:- flow structures
- temp.- variables of calling function accessible
To be limited in final release:- for, while, do-while loops
- 'new' operator
- script complexity
If there's something you want to fix/write, go ahead and post your update in this thread. Questions, comments, critique, and requests are welcomed. Please try it and report issues!
I have included an "unstable" version of the parser. It may have some debug messages, etc. This file will be updated more regularly.
Updates:- April 16
- fixed small bug with constructs like a(2) [the 2 turned into 0].
- added support for dynamic variable names this.(@blah).
- added support for the [] operator.
- April 19
- added support for special concatenation operators (SPC, TAB, NL), oops!
- tested @ array; it works
- April 26
- fixed a bug with inserting operators with constructs like h = f(g(x)).
- the script is accurately finding functions (there may be some issues). It is not yet calling the functions, though.
- April 28, 29, 30
- Made the dot operator a LOT faster, yay!
- added support for functions, woo!
- added comma operator (that should be all of them!)