I need to split a JavaScript file into single instructions. For example
a = 2; foo() function bar() { b = 5; print(\"spam\"); }
has to
Why not use a JavaScript parser? There are lots, including a Python API for ANTLR and a Python wrapper around SpiderMonkey.