Install pyjsparser via pip
masterInstall the pyjsparser package using pip to get access to the fast JavaScript parser for Python.
pip install pyjsparserrepository·master·Indexed 42 days ago
https://github.com/piotrdabkowski/pyjsparserA fast JavaScript parser for Python, implemented as a manual translation of esprima.js. It converts JavaScript strings into an Abstract Syntax Tree (AST) following the Esprima syntax tree format.
Install the pyjsparser package using pip to get access to the fast JavaScript parser for Python.
pip install pyjsparserUse the parse function from pyjsparser to convert a JavaScript string into an Abstract Syntax Tree (AST). The generated AST follows the Esprima syntax tree format.
>>> from pyjsparser import parse
>>> parse('var $ = "Hello!"')
{
"type": "Program",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "$"
},
"init": {
"type": "Literal",
"value": "Hello!",
"raw": '"Hello!"'
}
}
],
"kind": "var"
}
]
}