Hi,
i need to split a javascript file into single instructions. For example:
a = 2;
foo()
function bar() {
b = 5;
print("spam");
}
has to be separated into three instructions. (assignment, function call and function definition).
Basically i need to instrument the code, injecting code between these instructions to perform checks. Splitting by ";" wouldn't obviously work because you can also end instructions with newlines and maybe i don't want to instrument code inside function and class definitions (i don't know yet). I took a course about grammars with flex/bison but in this case the semantic action for this rule would be "print all the descendants in the parse tree and put my code at the end" which can't be done with basic bison i think. How do I do this? I also need to split the code because i need to interface with python with python-spidermonkey. Or... is there a library out there already which saves me from reinventing the wheel? It doesn't have to be in python.
Thanks.