Source code
Revision control
Copy as Markdown
Other Tools
Metadata-Version: 1.1
Name: esprima
Version: 4.0.1
Summary: ECMAScript parsing infrastructure for multipurpose analysis in Python
Author: German M. Bravo (Kronuz)
Author-email: german.mb@gmail.com
License: BSD License
Description: |Donate| |PyPI Version| |PyPI License| |PyPI Format| |PyPI Status|
high performance, standard-compliant
parser officially written in ECMAScript (also popularly known as
Python. Esprima is created and maintained by `Ariya
Python port is a line-by-line manual translation and was created and is
maintained by `German Mendez Bravo
Features
~~~~~~~~
- Full support for ECMAScript 2017 (`ECMA-262 8th
- Sensible `syntax tree
- Optional tracking of syntax node location (index-based and
line-column)
with `full code
Installation
~~~~~~~~~~~~
.. code:: shell
pip install esprima
API
~~~
Esprima can be used to perform `lexical
(tokenization) or `syntactic
JavaScript program.
A simple example:
.. code:: javascript
>>> 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
Keywords: esprima ecmascript javascript parser ast
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Code Generators
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: General
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6