commit | a25fc8b0f30a058c51d4fa0b408703ddba5db599 | [log] [tgz] |
---|---|---|
author | Ariya Hidayat <ariya.hidayat@gmail.com> | Thu Sep 01 07:17:17 2016 -0700 |
committer | Ariya Hidayat <ariya.hidayat@gmail.com> | Sat Sep 03 06:35:23 2016 -0700 |
tree | a518737c03ada98a43816b16b465c13e344c4098 | |
parent | 745910209ca938a1ccb64ca6490e50f9b7d8b5b2 [diff] |
Ensure TypeScript compilation before npm publish Refs #1527
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' }