What i understand is that "In computer technology, a parser is a program, usually part of a compiler, that receives input in the form of sequential source program instructions, interactive online commands, markup tags, or some other defined interface and breaks them up into parts (for example, the nouns (objects), verbs (methods), and their attributes or options) that can then be managed by other programming (for example, other components in a compiler). A parser may also check to see that all input has been provided that is necessary." Which means a parser breaks javascript up and forms some tree and parse it to machine code to run but how does it happens in case of esprima..

1

There are 1 best solutions below

0
On BEST ANSWER

Esprima is just a parser, a tool that breaks down the language syntax into an abstract syntax tree (AST). It's totally different from the runtime that consumes the AST and executes it.

A scenario where Esprima is used is code quality checking. Syntax-checking tools that run on JS use libraries like Esprima to parse JS code before handing it off to a library that analyzes the AST it produced.