I read the following example in one of my professors notes.

1) we have a SLR(1) Grammar G as following. we use SLR(1) parser generator and generate a parse table S for G. we use LALR(1) parser generator and generate a parse table L for G.

S->AB

A->dAa

A-> lambda (lambda is a string with length=0)

B->aAb

Solution: the number of elements with R (reduce) in S is more than L.

but in one site I read:

2) Suppose T1, T2 is created with SLR(1) and LALR(1) for Grammar G. if G be a SLR(1) Grammar which of the following is TRUE?

a) T1 and T2 has not any difference.

b) total Number of non-error entries in T1 is lower than T2

c) total Number of error entries in T1 is lower than T2

Solution:

The LALR(1) algorithm generates exactly the same states as the SLR(1) algorithm, but it can generate different actions; it is capable of resolving more conflicts than the SLR(1) algorithm. However, if the grammar is SLR(1), both algorithms will produce exactly the same machine (a is right).

any one could describe for me which of them is true?

EDIT: infact my question is why for a given SLR(1) Grammar, the parse table of LALAR(1) and SLR(1) is exactly the same, (error and non-error entries are equal and number of reduce is equal) but for the above grammar, the number of Reduced in S is more than L.

More Huimen Maisori's questions See All
Similar questions and discussions