ECMAScript parsing infrastructure for multipurpose analysis

Esprima is a high performance, standard-compliant ECMAScript parser written in ECMAScript (also popularly known as JavaScript).

Features

  • Full support for ECMAScript 5.1 (ECMA-262)
  • Sensible syntax tree format, compatible with Mozilla Parser AST
  • Optional tracking of syntax node location (index-based and line-column)
  • Heavily tested (> 600 tests with solid statement and branch coverage)
  • Experimental support for ES6/Harmony (module, class, destructuring, ...)

Esprima serves as an important building block for some JavaScript language tools, from code instrumentation to editor autocompletion.

Autocomplete

Once the full syntax tree is obtained, various static code analysis can be applied to give an insight to the code: syntax visualization, code validation, editing autocomplete (with type inferencing) and many others.

Regenerating the code from the syntax tree permits a few different types of code transformation, from a simple rewriting (with specific formatting) to a more complicated minification.

Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as Rhino and Node.js. It is distributed under the BSD license.