• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..01-Jan-1970-

bin/H03-May-2022-

dist/H03-May-2022-

ChangeLogH A D01-Jan-19709.7 KiB236170

LICENSE.BSDH A D01-Jan-19701.3 KiB2218

README.mdH A D01-Jan-19702.4 KiB4636

package.jsonH A D01-Jan-19705.2 KiB142141

README.md

1[![NPM version](https://img.shields.io/npm/v/esprima.svg)](https://www.npmjs.com/package/esprima)
2[![npm download](https://img.shields.io/npm/dm/esprima.svg)](https://www.npmjs.com/package/esprima)
3[![Build Status](https://img.shields.io/travis/jquery/esprima/master.svg)](https://travis-ci.org/jquery/esprima)
4[![Coverage Status](https://img.shields.io/codecov/c/github/jquery/esprima/master.svg)](https://codecov.io/github/jquery/esprima)
5
6**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
7standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
8parser written in ECMAScript (also popularly known as
9[JavaScript](https://en.wikipedia.org/wiki/JavaScript)).
10Esprima is created and maintained by [Ariya Hidayat](https://twitter.com/ariyahidayat),
11with the help of [many contributors](https://github.com/jquery/esprima/contributors).
12
13### Features
14
15- Full support for ECMAScript 2017 ([ECMA-262 8th Edition](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
16- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree)
17- Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/)
18- Optional tracking of syntax node location (index-based and line-column)
19- [Heavily tested](http://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://codecov.io/github/jquery/esprima))
20
21### API
22
23Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) (tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program.
24
25A simple example on Node.js REPL:
26
27```javascript
28> var esprima = require('esprima');
29> var program = 'const answer = 42';
30
31> esprima.tokenize(program);
32[ { type: 'Keyword', value: 'const' },
33  { type: 'Identifier', value: 'answer' },
34  { type: 'Punctuator', value: '=' },
35  { type: 'Numeric', value: '42' } ]
36
37> esprima.parseScript(program);
38{ type: 'Program',
39  body:
40   [ { type: 'VariableDeclaration',
41       declarations: [Object],
42       kind: 'const' } ],
43  sourceType: 'script' }
44```
45
46For more information, please read the [complete documentation](http://esprima.org/doc).