SkillAgentSearch skills...

Esprima2

modern javascript parser

Install / Use

/learn @s0md3v/Esprima2
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

esprima2 is a javascript parser written in python. It works for ECMAScript 2024 and has ~1500 unit tests.

Credits

  1. Ariya Hidayat created the original esprima library.
  2. Kronuz created a python port as esprima-python, line-by-line - faithfully.
  3. esprima library hasn't been updated since ECMAScript 2019 and esprima-python since ECMAScript 2017.
  4. With esprima2, I added the missing syntax support and now we can parse modern javascript.

Features

Installation

pip install esprima2

Usage

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) 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"
    }

More (and original) documentation is available here: https://esprima.org

Related Skills

View on GitHub
GitHub Stars69
CategoryDevelopment
Updated22d ago
Forks12

Languages

Python

Security Score

85/100

Audited on Mar 10, 2026

No findings