GATE Computer ScienceModerateGATE CSE · NIELIT
A C lexer applies the maximal-munch rule (always take the longest possible token). How many tokens does it produce for the input x=a---b<<=c++>=d; ?
- A. 12
- B. 11
- C. 13
- D. 14
Correct answer: A. 12
Tokens: x = a -- - b <<= c ++ >= d ; — "---" splits as "--" "-", "<<=" is one token, and "c++>=d" gives c, ++, >=, d; total 12.
More Compiler Design questions
- How many basic blocks does this three-address code contain? 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s…
- Using Sethi–Ullman numbering (a leaf that is a left operand needs 1 register, a leaf that is a right operand can be used from memory and…
- Grammar: S → A B D; A → a A | ε; B → b B | A c | ε; D → d D | ε. What is |FOLLOW(A)| + |FOLLOW(B)| + |FOLLOW(D)|? (FOLLOW sets may contain…
- Grammar: E → T X; X → + T X | − T X | ε; T → F Y; Y → F Y | / F Y | ε; F → ( E ) | id | num | − F. How many non-empty cells does its LL(1)…
- How many states does the canonical LR(0) automaton have for the augmented grammar S' → S, S → a S b | a b?
- Program: int x = 5; int f() { return x; } int g() { int x = 7; return f() + x; } int h() { int x = 11; return g() + f() + x; } main calls…