githubEdit

esprima

NPM versionarrow-up-right npm downloadarrow-up-right Build Statusarrow-up-right Coverage Statusarrow-up-right

Esprima (esprima.orgarrow-up-right, BSD license) is a high performance, standard-compliant ECMAScriptarrow-up-right parser written in ECMAScript (also popularly known as JavaScriptarrow-up-right). Esprima is created and maintained by Ariya Hidayatarrow-up-right, with the help of many contributorsarrow-up-right.

Features

API

Esprima can be used to perform lexical analysisarrow-up-right (tokenization) or syntactic analysisarrow-up-right (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 documentationarrow-up-right.

Last updated