Aruna
Aruna

Reputation: 196

How to convert a JavaScript file into an abstract syntax tree

I have a JavaScript file which I need to parse and find errors in that. To do so I am planning to convert into an Abstract Syntax Tree (AST), so that I can parse through the nodes.

Can anyone suggest to me how to convert JavaScript into AST?

Upvotes: 1

Views: 2320

Answers (1)

vsemozhebuty
vsemozhebuty

Reputation: 13772

You can try https://github.com/acornjs/acorn

Some other parsers are mentioned in https://astexplorer.net — try to change the parser settings and follow the link in the upper right corner.

Upvotes: 1

Related Questions