A lexical analyzer uses the following token definitions: For the string givenβ¦
2026
A lexical analyzer uses the following token definitions:

For the string given below,
π₯1 23ππ 78 π¦ 7π§ π§π§5 14π΄ 8π» π΄ππππ·
the number of tokens (excluding π€π ) that will be produced by the lexical analyzer is_____________.
Attempted by 18 students.
Show answer & explanation
Correct answer: 13
To find the number of tokens, we parse the input string from left to right using the given grammar rules.
Rules: id starts with a letter, number starts with a digit.
x1 -> id
23 -> number
mm -> id
78 -> number
y -> id
7 -> number
z -> id
zz5 -> id
14 -> number
A -> id
8 -> number
H -> id
AaYcD -> id
Total number of tokens = 13.
A video solution is available for this question β log in and enroll to watch it.