Skip to content
Official PYQ · 1987

GATE CS 1987 Q1-xi — Lexical Analysis

Explain with AI

In a compiler the module that checks every character of the source text is called:

Choose one option
View worked solution

Answer: C

The correct option is C.

Here is a breakdown of the roles of the compiler phases mentioned:

  • Lexical Analyser (Scanner): This is the first phase of a compiler. It reads the source program character-by-character, groups these characters into meaningful sequences called lexemes, and translates them into a stream of tokens. Thus, it is the module that inspects every single character of the source text.
  • Syntax Analyser (Parser): This phase takes the stream of tokens produced by the lexical analyser and groups them into grammatical phrases, represented by a parse tree. It operates on tokens, not individual characters.
  • Code Optimiser: This phase attempts to improve the intermediate code so that the resulting target program runs faster or consumes less memory.
  • Code Generator: This phase maps the intermediate representation of the source program into the target language (usually machine code or assembly language).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Lexical Analysis questions