Skip to content

jquery/esprima

Folders and files

NameName
Last commit message
Last commit date

Latest commit

512cd66 · Aug 29, 2021
Jul 2, 2021
Dec 23, 2016
Oct 28, 2015
Sep 27, 2020
May 8, 2021
Aug 29, 2021
Aug 29, 2021
Apr 14, 2018
Mar 11, 2015
May 8, 2021
Nov 17, 2015
May 29, 2020
May 7, 2015
Jun 12, 2017
Nov 8, 2016
Jun 11, 2021
May 8, 2021
May 8, 2021
Oct 28, 2015

NPM version npm download Tests Coverage Status

Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser written in ECMAScript (also popularly known as JavaScript). Esprima is created and maintained by Ariya Hidayat, with the help of many contributors.

Features

API

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.

A simple example on Node.js REPL:

> var esprima = require('esprima');
> var 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);
{ type: 'Program',
  body:
   [ { type: 'VariableDeclaration',
       declarations: [Object],
       kind: 'const' } ],
  sourceType: 'script' }

For more information, please read the complete documentation.