GATE Computer ScienceModerateGATE CSE · NIELIT
With ^ right-associative and higher than * which is higher than + and − (both left-associative), what is the postfix form of a − b * c ^ d ^ e + f?
- A. a b c d e ^ * ^ - f +
- B. a b c ^ d ^ e * - f +
- C. a b c d e ^ ^ * f + -
- D. a b c d e ^ ^ * - f +
Correct answer: D. a b c d e ^ ^ * - f +
Operator precedence parsing gives a b c d e ^ ^ * - f +: d ^ e is evaluated first (right associativity), then c ^ (d^e), then b *, then a −, then + f.
More Compiler Design questions
- Consider this three-address code: 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s = s + t; 7: i = i + 1; 8…
- 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?
- 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′…