high-performance javascript parser, tokenizer and lexical analyser
Project description
esprima2 is a javascript parser written in python. It supports syntax up to ECMA 2025 and has ~1500 unit tests.
Credits
- Ariya Hidayat created the original esprima library.
- Kronuz created a python port as esprima-python, line-by-line - faithfully.
esprimalibrary hasn't been updated since ECMAScript 2019 andesprima-pythonsince ECMAScript 2017.- With
esprima2, I added the missing syntax support and now we can parse modern javascript.
Features
- Syntax support up to ECMA 2025
- Sensible syntax tree format as standardized by ESTree project
- Experimental support for JSX, a syntax extension for React
- Optional tracking of syntax node location (index-based and line-column)
- Heavily tested (~1500 unit tests)
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file esprima2-6.0.0.tar.gz.
File metadata
- Download URL: esprima2-6.0.0.tar.gz
- Upload date:
- Size: 60.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4f045a7171b1027ae770d4b28caf55f987f133436d569d52e221ae313d9f83
|
|
| MD5 |
52dbf3a2253a92665d4ecedf2983bd3b
|
|
| BLAKE2b-256 |
8bb387832c18ff84010a08ea64e4c0c4c91550e0e28207b835db4849cd0aec81
|
Provenance
The following attestation bundles were made for esprima2-6.0.0.tar.gz:
Publisher:
pypi.yml on s0md3v/esprima2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
esprima2-6.0.0.tar.gz -
Subject digest:
3a4f045a7171b1027ae770d4b28caf55f987f133436d569d52e221ae313d9f83 - Sigstore transparency entry: 1355519202
- Sigstore integration time:
-
Permalink:
s0md3v/esprima2@5f4760043843b0f74eeb3188280f9f55850f763d -
Branch / Tag:
refs/tags/v6.0.0 - Owner: https://github.com/s0md3v
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5f4760043843b0f74eeb3188280f9f55850f763d -
Trigger Event:
push
-
Statement type:
File details
Details for the file esprima2-6.0.0-py3-none-any.whl.
File metadata
- Download URL: esprima2-6.0.0-py3-none-any.whl
- Upload date:
- Size: 76.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0596fae544e0a9d7a07b1243ee9e9016b568812c20f9a06cb8f85bbb7c2ef443
|
|
| MD5 |
f834ad1bdcad9e92d4d8008dd5aa661c
|
|
| BLAKE2b-256 |
7f10583154299cde5ba31a2818490788398c9a9cbb01292cc485d505e03b5966
|
Provenance
The following attestation bundles were made for esprima2-6.0.0-py3-none-any.whl:
Publisher:
pypi.yml on s0md3v/esprima2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
esprima2-6.0.0-py3-none-any.whl -
Subject digest:
0596fae544e0a9d7a07b1243ee9e9016b568812c20f9a06cb8f85bbb7c2ef443 - Sigstore transparency entry: 1355519208
- Sigstore integration time:
-
Permalink:
s0md3v/esprima2@5f4760043843b0f74eeb3188280f9f55850f763d -
Branch / Tag:
refs/tags/v6.0.0 - Owner: https://github.com/s0md3v
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@5f4760043843b0f74eeb3188280f9f55850f763d -
Trigger Event:
push
-
Statement type: