Programming languages are often divided, somewhat artificially, into compiled and interpreted languages, although the boundaries have become blurred. As such, don’t worry about it. The concepts discussed here apply equally well to compiled as well as interpreted languages. We will use the word compiler below, but for the scope of this article, that shall include the meaning of interpreter.
Compilers have to perform three major tasks when presented with a program text (source code):
- Lexical analysis
- Syntactic analysis
- Code generation or execution
The bulk of the compiler’s work centers around steps 1 and 2, which involve understanding the program source code and ensuring its syntactical correctness. We call that process parsing, which is the parser’s responsibility.