I need to split the JavaScript file into separate instructions. for example
a = 2; foo() function bar() { b = 5; print("spam"); }
must be divided into three teams. (purpose, function call and function definition).
Basically I need to use the code, entering the code between these instructions to perform the checks. Separation of ";" won't work, because you can also end instructions with new characters, and maybe I don't want to enter the code inside the functions and class definitions (I don't know yet). I took a course on grammars with flex / Bison , but in this case the semantic action for this rule is “print all descendants in the parse tree and put my code at the end”, which cannot be done with the base Bison, I think. How can I do it? I also need to split the code because I need to interact with Python using python-spidermonkey. Or ... is there a library that saves me from rethinking the wheel? It should not be in Python.
javascript python parsing spidermonkey
Bruceberry
source share