retagged by
482 views
3 votes
3 votes

Consider the following grammars:

  1. $S \rightarrow aS \mid Sa \mid  \in$
  2. $E \rightarrow E +E \mid E^*E \mid id$
  3. $A \rightarrow AA \mid (A) \mid a$
  4. $S \rightarrow SS \mid AB, \ A \rightarrow Aa \mid a, \ B \rightarrow Bb \mid b$

 

These grammars are:

  1. Ambiguous
  2. Unambiguous
  3. Regular
  4. Inherently Ambiguous
retagged by

1 Answer

1 votes
1 votes

1. SaS|Sa|∈

2. EE+E|EE|id

3. AAA|(A)|a

4. SSS|ABAAa|aBBb|b

 

Let's look at first grammar, you can generate "aa" by two parse trees so its ambiguous. If you are in hurry, you can choose this option because other grammar's are ambiguous too. Otherwise, check for all options...

Option B says Unambiguous, which can't be possible because grammar 1 is ambiguous.

Option C says regular, but we can generate $a^n b^n$ So can't be regular grammar.

Choice D is also wrong because, to be an Inherently Ambiguous language we need all grammar generated by this Lang. To be ambiguous, which is not take grammar 3 can we generate a by two parse trees?

Answer:

Related questions

2 votes
2 votes
2 answers
1
Bikram asked Nov 25, 2016
663 views
Consider the following grammar:$S \rightarrow L = P \mid P$$L \rightarrow ^*P \mid id$$P \rightarrow L$The above grammar is:AmbiguousSLR(1)LALR(1)None of the above
3 votes
3 votes
1 answer
2
Bikram asked Nov 25, 2016
263 views
Which grammar causes recursive-descent parser to go into infinite loop?LL(1)Left recursive grammarRight recursive grammarGrammar with left factors
3 votes
3 votes
2 answers
3
Bikram asked Nov 25, 2016
493 views
Consider the following grammar:$S \rightarrow aMd \mid bNd \mid aNe \mid bMe$$M \rightarrow c$$N \rightarrow c$The grammar above is:LR(1) but not LALR(1)LALR(1) but no...
3 votes
3 votes
1 answer
4
Bikram asked Nov 25, 2016
442 views
Consider the following grammar:$E \rightarrow E + T \mid T$$T \rightarrow T ^* F \mid F$$F \rightarrow (E) \mid id$What are the productions for E, T and F after convertin...