Coder Social home page Coder Social logo

jixiang-zhang / esprima-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kronuz/esprima-python

0.0 0.0 0.0 7.41 MB

ECMAScript parsing infrastructure for multipurpose analysis

Home Page: http://esprima.org

License: Other

Python 100.00%

esprima-python's Introduction

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

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.

esprima-python's People

Contributors

kronuz avatar diogovincenzi avatar beardypig avatar lucasg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.