pyjsparser

repository·master·Indexed 42 days ago

https://github.com/piotrdabkowski/pyjsparser

A 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.

Tokens
389
Snippets
2
Records
2
Agent score
4%

What's inside pyjsparser

  1. Parse JavaScript code with parse()

    master

    Use 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"
        }
      ]
    }