Could you recommend me a server-side javascript parser? [closed]
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionI have to extract defined variable and function names from a js code passed as a text. Example:
$js_code = " var MyVar1 = 'val1'; \n var MyVar2 = 'val2' ; \n function MyFunc() { some code }";
Extracted:
$js_vars = array("MyVar1", "MyVar2");
$js_func = array("MyFunc");
Have you tried Aptana Jaxer? It's an HTTP/Apache javascript parser.
There's also tools like jParser: http://timwhitlock.info/jparser/ Which is a php library which parses javascript. That might be more like what you need, but only if you're using PHP server-side.
I hope that helps.
精彩评论