GATE Computer ScienceEasyGATE CS (PYQ pattern)
S → a S | b S | c is LR(0). In its LR(0) parsing table the reduce action for a complete item is written in every terminal column including $. How many reduce entries does the ACTION table contain (accept excluded)?
- A. 3
- B. 9
- C. 14
- D. 12
Correct answer: D. 12
There are 3 states with a completed item (none mixes shift and reduce); each contributes 3+1 = 4 terminal columns, so 12.
More Compiler Design questions
- For the production A → B C D (A.i, B.i, C.i, D.i inherited; A.s, B.s, C.s, D.s synthesised), which rule set makes the SDD L-attributed?
- Productions are numbered (1) S → ( L ); (2) S → x; (3) L → S; (4) L → L , S. A shift-reduce parser parses "( x , ( x ) )". In which order…
- A table-driven LL(1) parser for S → A B C; A → a | ε; B → b | ε; C → c | ε parses "a c". Each pop of a non-terminal (expanding it) and…
- For G: S → a E c | a F d | b F c | b E d; E → e; F → e, what is the smallest k for which G is LL(k), and is G LALR(1)?
- Live-variable analysis is used to find dead assignments (target not live immediately after the statement) in 1: x = a + b; 2: if c > 0…
- A DAG is built for the basic block x = a b; y = b a; z = x + y; a = z − x; w = a b; v = y + x (+ and commutative, a new leaf for each…