There is two ways to make parsing: Eager Parsing, this find Errors, build the ATS and build scopes; and Lazy Parsing, faster, doesn’t build AST and partially scopes.
Demo – Tokens: are the minimal components of the file, every each of one has a value and a type.
Abstract Syntax Tree (AST): It is a graph that structure the login of out program, it is very used not only by the engine but trans pilers, bundlers, type checkers, etc.
In this case we are working with ESLint a type checker, to set our own rules there is this website where we can test the rules we are going to implement https://astexplorer.net/
Once here and setting before for babel-Eslint for the new version of Eslint. We can start building the function that will help to detect the error and send the message, also it is possible to autocorrect the errors.
In this example we set a rule that notice if the const declaration when is a number is in upper case or lower case, being an error lower case. Also we set the autocorrect to transform into Uppercase the errors.
After setting the structure of the code now is when the engine of the browser take that file and compile it into bytecode, it is not machine code (binary language), but it is close.
While reading the file the engine can learn and optimize the code, this that can look helpful it can be the cause of many errors like hoisting.
Before queueing them the Event Lopp schedule them but in case of promises their