Which phase of compiler generates stream of atoms ?
2015
Which phase of compiler generates stream of atoms ?
- A.
Syntax Analysis
- B.
Lexical Analysis
- C.
Code Generation
- D.
Code Optimization
Attempted by 67 students.
Show answer & explanation
Correct answer: B
Answer: Lexical Analysis.
Explanation: Lexical analysis (also called scanning) reads the raw source characters and groups them into a stream of tokens (often called atoms).
What the lexical analyzer produces: tokens such as identifiers, keywords, operators, literals, and punctuation.
How those tokens are used: the parser (syntax analysis) consumes the token stream to build a parse tree or abstract syntax tree.
Why other phases are incorrect: code generation produces target code from an intermediate representation, and code optimization improves code quality; neither produces the initial token stream.