GATE CS 2026 Set 2 — Question 35
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.NAT+1 / -0MediumTokens & LexemesLexical AnalysisCompiler DesignRegular Expressions for Tokens
Compiler Design → Lexical Analysis → Regular Expressions for Tokens
Last updated
Question
A lexical analyzer uses the following token definitions
Correct answer
13 to 13
Solution
The lexical analyzer typically uses the "longest match" rule to identify tokens. Let's analyze the string token by token:Input String:
x1 23mm 78 y 7z zz5 14A 8H AaYcD1.
x1: Starts with a letter, followed by a digit. Matches . (Token 1)2.
: Whitespace (), ignored.3.
23mm: 23matches . The next charactermis not a digit, so the number token ends here. (Token 2)mmstarts with a letter, matches . (Token 3)
: Whitespace (), ignored.5.
78: Matches . (Token 4)6.
: Whitespace (), ignored.7.
y: Matches . (Token 5)8.
: Whitespace (), ignored.9.
7z:7matches . The next characterzis not a digit. (Token 6)zmatches . (Token 7)
: Whitespace (), ignored.11.
zz5: Starts with a letter, followed by letter and digit. Matches . (Token 8)12.
: Whitespace (), ignored.13.
14A:14matches . The next characterAis not a digit. (Token 9)Amatches . (Token 10)
: Whitespace (), ignored.15.
8H:8matches . The next characterHis not a digit. (Token 11)Hmatches . (Token 12)
: Whitespace (), ignored.17.
Total tokens identified: 13.AaYcD: Matches . (Token 13)Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Lexical Analysis
2026 Set 2 Q17In C runtime environment, which one of the following is stored in heap?2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]2026 Set 1 Q28Which of the following statements is/are true?2026 Set 2 Q41Consider the canonical parsing of the grammar below using terminals and…