\href{https://www.npmjs.com/package/esprima}{\texttt{ }} \href{https://www.npmjs.com/package/esprima}{\texttt{ }} \href{https://travis-ci.org/jquery/esprima}{\texttt{ }} \href{https://codecov.io/github/jquery/esprima}{\texttt{ }}

{\bfseries{Esprima}} (\href{http://esprima.org}{\texttt{ esprima.\+org}}, BSD license) is a high performance, standard-\/compliant \href{http://www.ecma-international.org/publications/standards/Ecma-262.htm}{\texttt{ ECMAScript}} parser written in ECMAScript (also popularly known as \href{https://en.wikipedia.org/wiki/JavaScript}{\texttt{ Java\+Script}}). Esprima is created and maintained by \href{https://twitter.com/ariyahidayat}{\texttt{ Ariya Hidayat}}, with the help of \href{https://github.com/jquery/esprima/contributors}{\texttt{ many contributors}}.\hypertarget{md_sfcode_node_modules_esprima_README_autotoc_md9221}{}\doxysubsubsection{Features}\label{md_sfcode_node_modules_esprima_README_autotoc_md9221}

\begin{DoxyItemize}
\item Full support for ECMAScript 2017 (\href{http://www.ecma-international.org/publications/standards/Ecma-262.htm}{\texttt{ ECMA-\/262 8th Edition}})
\item Sensible \href{https://github.com/estree/estree/blob/master/es5.md}{\texttt{ syntax tree format}} as standardized by \href{https://github.com/estree/estree}{\texttt{ ESTree project}}
\item Experimental support for \href{https://facebook.github.io/jsx/}{\texttt{ JSX}}, a syntax extension for \href{https://facebook.github.io/react/}{\texttt{ React}}
\item Optional tracking of syntax node location (index-\/based and line-\/column)
\item \href{http://esprima.org/test/ci.html}{\texttt{ Heavily tested}} ($\sim$1500 \href{https://github.com/jquery/esprima/tree/master/test/fixtures}{\texttt{ unit tests}} with \href{https://codecov.io/github/jquery/esprima}{\texttt{ full code coverage}})
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_esprima_README_autotoc_md9222}{}\doxysubsubsection{API}\label{md_sfcode_node_modules_esprima_README_autotoc_md9222}
Esprima can be used to perform \href{https://en.wikipedia.org/wiki/Lexical_analysis}{\texttt{ lexical analysis}} (tokenization) or \href{https://en.wikipedia.org/wiki/Parsing}{\texttt{ syntactic analysis}} (parsing) of a Java\+Script program.

A simple example on Node.\+js REPL\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{> var esprima = require('esprima');}
\DoxyCodeLine{> var program = 'const answer = 42';}
\DoxyCodeLine{}
\DoxyCodeLine{> esprima.tokenize(program);}
\DoxyCodeLine{[ \{ type: 'Keyword', value: 'const' \},}
\DoxyCodeLine{  \{ type: 'Identifier', value: 'answer' \},}
\DoxyCodeLine{  \{ type: 'Punctuator', value: '=' \},}
\DoxyCodeLine{  \{ type: 'Numeric', value: '42' \} ]}
\DoxyCodeLine{  }
\DoxyCodeLine{> esprima.parseScript(program);}
\DoxyCodeLine{\{ type: 'Program',}
\DoxyCodeLine{  body:}
\DoxyCodeLine{   [ \{ type: 'VariableDeclaration',}
\DoxyCodeLine{       declarations: [Object],}
\DoxyCodeLine{       kind: 'const' \} ],}
\DoxyCodeLine{  sourceType: 'script' \} }

\end{DoxyCode}


For more information, please read the \href{http://esprima.org/doc}{\texttt{ complete documentation}}. 