edited by
14,294 views
44 votes
44 votes

Consider the $\text{SLR(1)}$ and $\text{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
edited by

2 Answers

Best answer
40 votes
40 votes
  • Goto part & shift entries must be same.
  • Reduce entries & error entries may be different due to conflicts.

Correct Answer: B;C;D.

21 votes
21 votes

All the LR parsers differ just in the placement of reduce moves.

The entire GoTo part is the same for LR(0), SLR(1), LALR(1) and CLR(1).

The placements of shift-moves is the same for LR(0), SLR(1), LALR(1) and CLR(1).

 

However, they differ in the placement of reduce moves. Which, in turn, makes them differ in the blank spaces(error entries) left in the parsing table.

 

Options B, C and D


How they differ in the placement of reduce moves in the parsing table?

  1. LR(0) puts reduce moves in the entire row for the final item.
     
  2. SLR(1) puts reduce moves only in the Follow() of LHS of the final item.
     
  3.  CLR(1) puts reduce moves only in the lookaheads of the final item.
     
  4. LALR(1) puts reduce moves in all the merged lookaheads for same final items. (You need to get a grip over LR(1) items to get this line)
Answer:

Related questions

23 votes
23 votes
4 answers
2
Kathleen asked Sep 13, 2014
4,668 views
Context-free languages are:closed under unionclosed under complementationclosed under intersectionclosed under Kleene closure
24 votes
24 votes
4 answers
3
Kathleen asked Sep 13, 2014
5,345 views
A computer system has $6$ tape devices, with n processes competing for them. Each process may need $3$ tape drives. The maximum value of n for which the system is guarant...
28 votes
28 votes
5 answers
4
Kathleen asked Sep 12, 2014
8,841 views
A $2-3$ tree is such thatAll internal nodes have either $2$ or $3$ childrenAll paths from root to the leaves have the same lengthThe number of internal nodes of a $2-3$ t...