The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+21 votes

Choose the correct alternatives (more than one may be correct ) and write the corresponding letters only:

Consider the $SLR(1)$ and $LALR (1)$  parsing tables for a context free grammar. Which of the following statement is/are true?

  1. The goto part of both tables may be different.
  2. The shift entries are identical in both the tables.
  3. The reduce entries in the tables may be different.
  4. The error entries in tables may be different
asked in Compiler Design by Veteran (52k points)
edited by | 1.6k views

1 Answer

+21 votes
Best answer
  • Goto part & shift entry must be same.
  • Reduce entry & error entry may b different due to conflicts.

Correct Answer: $B,C,D$

answered by Veteran (59.8k points)
edited by
Seeing some examples we can say that the goto entries and shift entries are same but can give u some ,logic behind it and why is not affected by the lookahead symbols present in LALR(1) parser .
in LALR(1) we merge LR(1) items states with same LR(0) items but with different lookaheads
answer must be b,c,d
  • Reduce entry & error entry may b different due to conflicts. I think reduce entries are different because of look a heads.
yes Reduce entries are different because of look aheads due to combining of states.

Reduce(LALR) >= Reduce(SLR)

Anu007  can you explain how "Reduce(LALR) >= Reduce(SLR)"? Does it means LALR can have more reduce entries than SLR?


@meghna @Anu007

Reduce entries in LALR and SLR are different unless Follow of nonterminals != Lookaheads

We can't always say that Reduce(LALR) >= Reduce(SLR)

In LALR we place reduce only in Lookaheads but in SLR we place it in FOLLOWs

Corrrect me if i am wrong

The Answer should be B, C & D.

Shift Entries are also identical in both SLR(1) & LALR(1).
Can you give me an example for these points

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,548 questions
54,174 answers
71,128 users