Compiler :
Compiler takes high level human readable program as input and convert it into the lower level code.This conversion takes place using different phases.First phase of compiler is lexical analysis.
Different phases of compilers :
- Analysis Phase
- Synthesis Phase
1.Analysis Phase :
- Lexical analysis
- Syntax analysis
- Semantic analysis
Lexical Analysis Phase :
Task of Lexical Analysis is to read the input characters and produce as output a sequence of tokens that the parser uses for syntax analysis.
- Lexical Analyzer is First Phase Of Compiler.
- Input to Lexical Analyzer is “Source Code“
- Lexical Analysis Identifies Different Lexical Units in a Source Code.
- Different Lexical Classes or Tokens or Lexemes
- Identifiers
- Constants
- Keywords
- Operators
- Example : sum = num1 + num2 ;
Token Type sum Identifier = Operator num1 Identifier + Operator num2 Identifier ; Seperator - Lexical Analyzer is also called “Linear Phase” or “Linear Analysis” or “Scanning“
- Individual Token is also Called Lexeme
- Lexical Analyzer’s Output is given to Syntax Analysis.
No comments:
Post a Comment