Version 3.0.0
Stable version 3.0.0

Refs #1527
Closes gh-1536
2 files changed
tree: 960b6fe34c3d631dbbe31d78c60ac59dc09751db
  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 programs.

A simple example:

var esprima = require('esprima');
var code = 'const answer = 42';
var tokens = esprima.tokenize(code);
var ast = esprima.parse(code);

which gives a list of tokens:

[ { type: 'Keyword', value: 'const' },
  { type: 'Identifier', value: 'answer' },
  { type: 'Punctuator', value: '=' },
  { type: 'Numeric', value: '42' } ]

and an abstract syntax tree:

{ type: 'Program',
  body:
   [ { type: 'VariableDeclaration',
       declarations: [Object],
       kind: 'const' } ],
  sourceType: 'script' }