Skip to main content

high-performance javascript parser, tokenizer and lexical analyser

Project description

esprima2 is a javascript parser written in python. It works for ECMAScript 2024 and has ~1500 unit tests.

Credits

  1. Ariya Hidayat created the original esprima library.
  2. Kronuz created a python port as esprima-python, line-by-line - faithfully.
  3. esprima library hasn't been updated since ECMAScript 2019 and esprima-python since ECMAScript 2017.
  4. With esprima2, I added the missing syntax support and now we can parse modern javascript.

Features

Installation

pip install esprima2

Development

Run the test suite with:

python3 -m test

Usage

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) a JavaScript program.

A simple example:

    >>> import esprima
    >>> program = 'const answer = 42'

    >>> esprima.tokenize(program)
    [{
        type: "Keyword",
        value: "const"
    }, {
        type: "Identifier",
        value: "answer"
    }, {
        type: "Punctuator",
        value: "="
    }, {
        type: "Numeric",
        value: "42"
    }]

    >>> esprima.parseScript(program)
    {
        body: [
            {
                kind: "const",
                declarations: [
                    {
                        init: {
                            raw: "42",
                            type: "Literal",
                            value: 42
                        },
                        type: "VariableDeclarator",
                        id: {
                            type: "Identifier",
                            name: "answer"
                        }
                    }
                ],
                type: "VariableDeclaration"
            }
        ],
        type: "Program",
        sourceType: "script"
    }

More (and original) documentation is available here: https://esprima.org

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esprima2-5.0.2.tar.gz (50.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

esprima2-5.0.2-py3-none-any.whl (67.8 kB view details)

Uploaded Python 3

File details

Details for the file esprima2-5.0.2.tar.gz.

File metadata

  • Download URL: esprima2-5.0.2.tar.gz
  • Upload date:
  • Size: 50.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for esprima2-5.0.2.tar.gz
Algorithm Hash digest
SHA256 e57cba7f8ba19f0ab92da12f958f115a0fd895a22b0215e745502b56701a34a1
MD5 1d761ed321cd30e88eaf520e0b995574
BLAKE2b-256 f2cccae6626e0d5b96bc4d2e7f0be0a68363abfcb668d4b07f419aa2202489d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for esprima2-5.0.2.tar.gz:

Publisher: pypi.yml on s0md3v/esprima2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file esprima2-5.0.2-py3-none-any.whl.

File metadata

  • Download URL: esprima2-5.0.2-py3-none-any.whl
  • Upload date:
  • Size: 67.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for esprima2-5.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 41d579d53a27ed212eb3b9309161d7768749c00157e8eac257da8a447f10110f
MD5 27de75b4d5292f58187a30bca4590326
BLAKE2b-256 9d48e10e10b4b487f16b7d8e699f1527fb9e13d8d294fa794310510a70c50e35

See more details on using hashes here.

Provenance

The following attestation bundles were made for esprima2-5.0.2-py3-none-any.whl:

Publisher: pypi.yml on s0md3v/esprima2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page