GATE CSE · Compiler Design
Generate GATE-level questions covering tokens, lexemes, regular expressions, finite automata (DFA/NFA), lexical errors, and token recognition. Include conversion and identification problems.
45 questions · 0 PYQs · 20 AI practice · GATE CSE 2027
Which of the following strings are accepted by the regular expression (0|1)*011?
The pumping lemma for regular languages states that for any regular language L, there exists a pumping length p such that any string s ∈ L with |s| ≥ p can be split as s = xyz where |xy| ≤ p, |y| ≥ 1, and xy^i z ∈ L for all i ≥ 0. How is the pumping lemma used in lexical analysis?
Consider the NFA for the regular expression (a|b)*abb with states {0,1,2,3} where state 3 is the accepting state. How many states does the minimized DFA for this NFA have?
The transition from a regular expression to a DFA for use in a lexical analyzer typically follows which sequence of steps?
Which of the following correctly describes the role of a lexical analyzer (scanner) in a compiler?
Consider a DFA for recognizing C-style comments of the form /* ... / (comment begins with / and ends with */). Which of the following correctly describes the minimum number of states needed?
A token in lexical analysis consists of:
Which of the following correctly describes the differences between a DFA and an NFA in terms of expressive power and implementation?
Consider the regular expression r = a(a|b)*b. Which of the following strings are in L(r)?
DFA minimization using Hopcroft's algorithm partitions DFA states into groups of indistinguishable states. Two states p and q are distinguishable if:
In a lexer, what is the role of 'lexeme' as distinct from 'token' and 'pattern'?
Consider the NFA obtained by Thompson's construction for the regular expression (a|b)*. How many states does this NFA have?
What is the minimum number of states in a DFA accepting the language L = {w ∈ {0,1}* | the number of 0s in w is divisible by 3}?
Lex (or Flex) is a tool for generating lexical analyzers. Which of the following correctly describes how lex processes its input specification?
Which of the following are properties of regular languages relevant to lexical analysis?
Which of the following tasks are typically performed by the lexical analysis phase of a compiler?
Which of the following errors can be detected by the lexical analyzer?
Which of the following regular expressions denotes the set of all strings over {a, b} that contain at least one 'a'?
The subset construction algorithm converts an NFA to a DFA. Consider an NFA with states {0,1,2,3} where state 0 is initial, state 3 is accepting, and transitions include ε-moves. The ε-closure of a state s is:
Regular expressions are used to specify token patterns in lexical analysis. Which of the following regular expressions correctly describes identifiers in most programming languages (a letter followed by zero or more letters or digits)?
Want unlimited AI-generated Lexical Analysis questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →