Version 3.1.3
Stable version 3.1.3

Refs #1584
Closes gh-1683
2 files changed
tree: 71375dd02c9ef35ee1602885770b11a1403a39d1
  1. bin/
  2. dist/
  3. src/
  4. test/
  5. tools/
  6. .editorconfig
  7. .gitignore
  8. .npmignore
  9. .travis.yml
  10. appveyor.yml
  11. ChangeLog
  12. circle.yml
  13. CONTRIBUTING.md
  14. LICENSE.BSD
  15. package.json
  16. README.md
  17. webpack.config.js
README.md

NPM version npm download Build Status 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.parse(program);
{ type: 'Program',
  body:
   [ { type: 'VariableDeclaration',
       declarations: [Object],
       kind: 'const' } ],
  sourceType: 'script' }