Skip to content
Official PYQ · 2011

GATE CS 2011 Q19 — Lexical Analysis

Explain with AI

The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?

Choose one option
View worked solution

Answer: A

The correct option is A.

Explanation:

  1. Role of Lexical Analysis: The primary task of a lexical analyzer (scanner) is to read the input characters of the source program, group them into lexemes, and produce a sequence of tokens (such as keywords, identifiers, operators, and constants).
  2. Language Class: These tokens are specified using regular expressions. The set of all valid tokens forms a regular language.
  3. Machine Model: The class of automata that is both necessary and sufficient to recognize regular languages is the Finite State Automaton (FSA) (either deterministic or non-deterministic, as they are equivalent in power).

Why other options are incorrect:

  • Deterministic / Non-deterministic Pushdown Automata (DPDA / NPDA): These are used for recognizing context-free languages (like syntax analysis/parsing). While they have the power to recognize regular languages, they are not necessary because a simpler model (FSA) is sufficient.
  • Turing Machine: This is used for recursively enumerable languages and is far too powerful and computationally expensive for lexical analysis.

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

Published
Report a correction
Keep exploringMore Lexical Analysis questions