tag | acede764b4ef5f1c7c5b3b01a5a285e748674cbb | |
---|---|---|
tagger | Ariya Hidayat <ariya.hidayat@gmail.com> | Sat Sep 03 07:14:07 2016 -0700 |
object | dea024fc158259ed513d78c1bb910ce847fd556c |
Version 3.0.0
commit | dea024fc158259ed513d78c1bb910ce847fd556c | [log] [tgz] |
---|---|---|
author | Ariya Hidayat <ariya.hidayat@gmail.com> | Wed Aug 31 21:55:59 2016 -0700 |
committer | Ariya Hidayat <ariya.hidayat@gmail.com> | Sat Sep 03 06:35:25 2016 -0700 |
tree | 960b6fe34c3d631dbbe31d78c60ac59dc09751db | |
parent | a25fc8b0f30a058c51d4fa0b408703ddba5db599 [diff] |
Stable version 3.0.0 Refs #1527 Closes gh-1536
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.
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' }