GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Kronuz/esprima-python: ECMAScript parsing infrastructure for multipurpose analysis

BranchesTags
Open more actions menu

Latest commit

 

History

91 Commits
91 Commits

Folders and files

NameName
Last commit message
Last commit date
esprima
esprima
 
 
examples
examples
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
ChangeLog
ChangeLog
 
 
LICENSE
LICENSE
 
 
LICENSE.BSD
LICENSE.BSD
 
 
MANIFEST.in
MANIFEST.in
 
 
README
README
 
 
README.rst
README.rst
 
 
pyproject.toml
pyproject.toml
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 

Repository files navigation

Donate PyPI Version PyPI License PyPI Format PyPI Status

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
  • 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 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.

About

ECMAScript parsing infrastructure for multipurpose analysis

esprima.org

Topics

astecmascriptesprimajavascriptparserparsingpython

Resources

Readme
Activity

Stars

265 stars

Watchers

13 watching

Forks

47 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.