Basics of Language Processor
Language processing
Language processor internally divided in two parts (1) Analysis phase (2) Synthesis phase. Alternative names of these phases are Front end and Back end respectively.
Source program given as an input to language process, first undergo with analysis. Analysis phase perform 3 types of analysis on source code:
(1) Lexical analysis
Scanner , first phase of analysis phase, apply lexical analysis on source code using lexical rules. Any part of source code not satisfies the lexical rules then lexical error is generated.
Lexical check on code is same as spelling check in English language.
(2) Syntax analysis
Parser, second phase of analysis phase, apply syntax analysis on the source code using syntax rules. Any part of source code not satisfies the syntax rules then syntax error is generated.
Syntax check on code is same as grammatical check in English language.
(3) Semantic analysis
Semantic analyzer, third phase of analysis phase, apply semantic analysis on the source code using semantic rules. Any part of source code not satisfies the semantic rules then semantic error is generated.
Semantic check on code is same as meaning check in English language.
If all analysis rules are satisficed then intermediate representation (IR) / intermediate code (IC) generated by analysis phase.
Synthesis phase takes IR as input. It performed memory allocation for IR and generate target code from IR.