Objective:
- To understand the basic principles in compilation.
- To study lexical analysis phase of compiler.
Theory:
- Analysis of source program.
- Synthesis of target program.
- Lexical Analysis – Determine lexical constituents in source program.
- Syntax Analysis – Determine structure of source string.
- Semantic Analysis – Determine meaning of source string.
Synthesis Step:
Task of Lexical Analysis:
- To scan the program into basic elements or tokens of the language.
- To build the Uniform symbol table (table of tokens).
- To build the symbol & literal table.
- To remove white spaces & comments.
- To detect errors such as invalid identifier or constant.
- Source program – Original Source program, which is scanned by compiler as string of characters.
- Terminal Table – A permanent database that has entry for each terminal symbols such as arithmetic operators, keywords, punctuation characters such as ‘;’ , ‘,’etc Fields: Name of the symbol.
- Literal Table – This table is created during lexical analysis so as to describe all literals in the program.