GATE Computer ScienceModerateGATE CS · ISRO
Using E → E + T | T; T → T * F | F; F → id, how many reductions does a bottom-up parser perform for the input id + id * id?
- A. 6
- B. 7
- C. 8
- D. 9
Correct answer: C. 8
The parse tree has 8 internal nodes: F→id three times, T→F twice, T→T*F once, E→T once and E→E+T once, which gives 8 reductions.
More Compiler Design questions
- In the grammar S → A B c | d; A → B B | a; B → b | ε; C → A C | ε, how many non-terminals are nullable?
- For the grammar S → A B; A → a A | b | ε; B → a B | b A | ε, how many cells of the LL(1) parsing table contain more than one production?
- For S → L = R | R; L → R | id; R → L, how many states of the LR(0) automaton contain a conflict that SLR(1) fails to resolve?
- For E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id, what is the sum of the sizes of the FOLLOW sets of E, E′, T, T′…
- How many LR(0) items does the grammar S → a S b | S S | ε | c d have (the ε-production contributes one item; do not count the augmented…
- A basic block is: t1 = a + b; t2 = a − b; t3 = t1 t2; t4 = a + b; t5 = t4 t2; t6 = t3 + t5; y = t6 / t3. How many nodes (leaves included)…