GATE Computer ScienceHardGATE CS (PYQ pattern)
Construct the SLR(1) parsing table of S → a B | b A; A → a | a S | b A A; B → b | b S | a B B (augmented). In how many states of the SLR(1) automaton does the ACTION part have at least one conflicting cell?
- A. 5
- B. 3
- C. 4
- D. 2
Correct answer: D. 2
Using FOLLOW sets as reduce lookaheads, 2 states contain a multiply-defined ACTION cell (4 cells in all).
More Compiler Design questions
- An NFA over {a, b} has states 0 to 4, start state 0, and these moves (a missing move means no transition): δ(0,a)={1,2}; δ(0,b)={0,1,2}…
- Build the SLR(1) table for S → ( L ) | x; L → S | L , S (augmented with S′ → S). The ACTION part has a column for each of (, ), x, , and…
- int x = 1; void p() { x = x + 10; } void r() { print(x); } void q() { int x = 5; p(); r(); } main() { q(); r(); print(x); } What is…
- Each assignment is a definition named by its statement number. In 1: s = 0; 2: i = 0; 3: L1: if i >= n goto L4; 4: if a > 0 goto L2; 5: s…
- A basic block is converted to a DAG using value numbering, treating + and as commutative, reusing an existing node when the same operator…
- A web of a variable is a maximal union of def-use chains that share a definition or a use; a register allocator gives each web its own…