GATE CS 2026 Set 2 | Question 35
Compiler Design › Basics & Lexical · NAT · 1 mark · Answer: 13
- Question 35Compiler Designnat1 markA lexical analyzer uses the following token definitions
For the string given below,letter -> [A-Za-z] digit -> [0-9] id -> letter (letter | digit)* number -> digit+ ws -> (blank | tab | newline)+
the number of tokens (excluding ) that will be produced by the lexical analyzer is __________. (answer in integer)x1 23mm 78 y 7z zz5 14A 8H AaYcDAnswer: 13
Solution
Anidmust start with a letter; anumberis a run of digits. Scanning (maximal munch):x1→id(1);23mm→23+mm(2);78→number(1);y→id(1);7z→7+z(2);zz5→id(1);14A→14+A(2);8H→8+H(2);AaYcD→id(1). Total .
More GATE PYQ on Basics & Lexical
All GATE CS Compiler Design PYQ →Attempt GATE CS 2026 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →