Please answer all the questions 1. LALR(1) has the same number of states as SLR(
ID: 3727912 • Letter: P
Question
Please answer all the questions
1. LALR(1) has the same number of states as SLR(1):
2. Consider the following grammar: S aAdx | bBdy | bAeu | aBev , A c , B c , is it LALR(2)?
3. Consider the following grammar: S AB) , A B | a) , B aB | a , will it accept the string "a)aaa)"?
4. what is the language of the grammar with the following production rules? S ASb | c , A a :
5. Consider the following grammar: S aAbB | Bc , A aAa | a , B Bb | Ab | cC | AC , C c , calculate First(A):
4. what is the language of the grammar with the following production rules? S ASb | c , A a :
Explanation / Answer
Answer: - Yes, this grammar will accept the string a)aaa), by following the below set of rules,
S AB) ………………………. S AB)
A a)……………………… S a)B)
B aB……………………… S a)aB)
B aB……………………… S a)aaB)
B a……………………… S a)aaa), hence string accepted.
3. What is the language of the grammar with the following production rules? S ASb | c , A a?
Answer: - Language of the grammar is ancbn.
4. First (A) :-
As A -> aAa / a
therefore, first(A) will be the terminal variable a, as there is no non-terminal variable on first position that may change the values, its just "a",
Final answer, First(A) = a