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?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2011 · Q19
Time
Select one answerSingle correct
Solution
Official answer: A) Finite state automata
Lexical AnalysisIn compiler construction:
Lexical analysis is the phase that converts a sequence of characters into a sequence of tokens (identifiers, keywords, literals, operators, etc.).
Tokens in programming languages like Java are specified using regular expressions.
The formal computational model that is both necessary and sufficient to recognize languages defined by regular expressions is a Finite State Automaton (DFA/NFA).
More powerful automata (like pushdown automata or Turing machines) are not required for lexical analysis because token definitions do not require nesting or arbitrary counting.
Therefore, option (A) is correct.
Try the question first, then check your work.
Examiner trap
Tokens in lexical analysis are described by regular expressions. Which automaton precisely recognizes regular languages?
This Lexical Analysis previous year question is Q19 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Lexical Analysis in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Lexical Analysis PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Lexical Analysis has 7 GATE CSE PYQs across 6 papers from 2011 to 2026. 5 of them are 1-mark MCQs like this one, and GATE CSE 2011 has 2.
How GATE tests Lexical AnalysisIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.