2
Lexical Analysis
1. What is the role of a lexical analyzer?
Ans: The lexical analysis is the first phase of a compiler where a lexical analyzer acts as an interface between the source program and the rest of the phases of compiler. It reads the input characters of the source program, groups them into lexemes, and produces a sequence of tokens for each lexeme. The tokens are then sent to the parser for syntax analysis. If lexical analyzer is placed as a separate pass in the compiler, it would require an intermediate file to place its output, from which the parser would then take its input. To eliminate the need for the intermediate file, the lexical analyzer and the syntactic analyzer (parser) are often grouped together into the same pass ...
Get Express Learning: Principles of Compiler Design now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.