**Esprima** (`esprima.org <http://esprima.org>`__, BSD license) is a
high performance, standard-compliant
`ECMAScript <http://www.ecma-international.org/publications/standards/Ecma-262.htm>`__
parser officially written in ECMAScript (also popularly known as
`JavaScript <https://en.wikipedia.org/wiki/JavaScript>`__) and ported to
Python. Esprima is created and maintained by `Ariya
Hidayat <https://twitter.com/ariyahidayat>`__, with the help of `many
contributors <https://github.com/jquery/esprima/contributors>`__.
Python port is a line-by-line manual translation and was created and is
maintained by `German Mendez Bravo
(Kronuz) <https://twitter.com/germbravo>`__.
Features
~~~~~~~~
- Full support for ECMAScript 2017 (`ECMA-262 8th
Edition <http://www.ecma-international.org/publications/standards/Ecma-262.htm>`__)
- Sensible `syntax tree
format <https://github.com/estree/estree/blob/master/es5.md>`__ as
standardized by `ESTree project <https://github.com/estree/estree>`__
- Experimental support for `JSX <https://facebook.github.io/jsx/>`__, a
syntax extension for `React <https://facebook.github.io/react/>`__
- Optional tracking of syntax node location (index-based and
line-column)
- `Heavily tested <http://esprima.org/test/ci.html>`__ (~1500 `unit
tests <https://github.com/jquery/esprima/tree/master/test/fixtures>`__
with `full code
coverage <https://codecov.io/github/jquery/esprima>`__)
Installation
~~~~~~~~~~~~
.. code:: shell
pip install esprima
API
~~~
Esprima can be used to perform `lexical
analysis <https://en.wikipedia.org/wiki/Lexical_analysis>`__
(tokenization) or `syntactic
analysis <https://en.wikipedia.org/wiki/Parsing>`__ (parsing) of a
JavaScript program.
A simple example:
.. code:: javascript
>>> import esprima
>>> program = 'const answer = 42'
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.