Let’s begin with one of the most basic and important concepts — Syntax Parser.
The program that reads our code and determines what it does and if it’s grammar is valid.
We can take example of human translators, take a look at above example. If person ‘A’ understands only English and person ‘C’ understands only ‘German’, then how can they communicate ? Correct, through ‘translators’ (also known as interpreters) who understands both the languages. In computer language, those programs or translators are called ‘compilers’ & they also have to do with ‘interpreters’.
But those programs — interpreters & compilers do the process. They actually read our code character by character and determines if syntax is valid and then implements that syntax in a way the computer can understand.
Suppose we have our code & there is a program that is going to convert what we have written into a real set of computer instructions, something that hardware can physically understand.
If we look at the above example, here we have a JS function with a variable which is represented in the computer’s memory and which is being translated from what we are writing to what the computer can understand. There is a compiler or an interpreter between those two things & part of that is a syntax parser.
It is going through character by character like F-U-N-C-T-I-O-N and it says oh that’s a ‘function’, so there should be a space after this. And the next thing that it looks up until the parenthesis() will be the ‘name of the function’ etc. And that’s translated by the systems that someone else wrote. But it also means in the translation process, the programmers that wrote the compiler can choose to do extra stuff. Our code is not actually being given to the computer but the translation of it, so the engine that is interpreting our code can decide or choose to do other things also.
I hope you enjoy the article with the basic concept of syntax parser. In the next article we are going to talk about lexical environment and execution context. Stay tuned!