Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser officially written in ECMAScript (also popularly known as JavaScript) and ported to Python. Esprima is created and maintained by Ariya Hidayat, with the help of many contributors.
Python port is a line-by-line manual translation and was created and is maintained by German Mendez Bravo (Kronuz).
Features
Full support for ECMAScript 2017 (ECMA-262 8th Edition)
Sensible syntax tree format as standardized by ESTree project
Optional tracking of syntax node location (index-based and line-column)
Heavily tested (~1500 unit tests with full code coverage)
Installation
pip install esprima
API
Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of 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"
}
For more information, please read the complete documentation.
Metadata
Release files for esprima 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| esprima-4.0.1.tar.gz | 47.0 kB | Details |
Release files / esprima-4.0.1.tar.gz
| Download URL | esprima-4.0.1.tar.gz |
|---|---|
| Size | 47.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08db1a876d3c2910db9cfaeb83108193af5411fc3a3a66ebefacd390d21323ee
|
|
BLAKE2b-256 checksum How to use checksums |
cca150fccd68a12bcfc27adfc9969c090286670a9109a0259f3f70943390b721
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.15
|