search
Log In
23 votes
6.4k views

The grammar $A \rightarrow AA \mid (A) \mid \epsilon$ is not suitable for predictive-parsing because the grammar is:

  1. ambiguous

  2. left-recursive

  3. right-recursive

  4. an operator-grammar

in Compiler Design 6.4k views
0
The given grammar is Ambiguous and left recursive....

But it's also not operator grammar

Because property is (NO two variable in right side or No null production).

What's correct answer??

3 Answers

53 votes
 
Best answer

both A and B can be answers but A is a better answer. Because we have standard procedure for removing left-recursion but ambiguity is not easy to remove. - checking if a given CFG is ambiguous is a undecidable problem.


edited by
0
Since ambiguity is undecidable problem so left recursion should be answer then, isn't it?
1
A->AA

both left recursive and right recursive??
13 votes

Any Grammar which is Left Recursive will cause any Predictive Parser to fall into an infinite loop. No matter if it is ambiguous or not, it won't be parsable. This is more stronger than saying it is ambiguous so fails.

Hence, answer = option B

10
nopes A is a better answer.
17
i think the precedence should go like

1) ambigious

2) left recursive

3) left factoring
0
how can it be parsed if it is ambiguous in the first place
0
It can not be parse when ambiguous. Ambiguous is more appropiate then left recursive as we can remove left recursion easily.
0
But in key answer is B
11
There is no official answer key before GATE 2011. Which key are you talking about?
2 votes
answer - B
Answer:

Related questions

26 votes
2 answers
1
2k views
Consider the context-free grammar $E \rightarrow E + E$ $E \rightarrow (E * E)$ $E \rightarrow id$ where $E$ is the starting symbol, the set of terminals is $\{id, (,+,),*\}$, and the set of nonterminals is $\{E\}$. Which of the following terminal strings has more than one parse tree when parsed according to ... $id + (id* (id * id))$ $(id* (id * id)) + id$ $((id * id + id) * id)$
asked Nov 4, 2014 in Compiler Design Ishrat Jahan 2k views
23 votes
2 answers
2
4.6k views
Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production. ... to $7$ Precedence of $+$' is higher than that of $\times$', and both operators are left associative; expression is evaluated to $9$
asked Nov 27, 2016 in Compiler Design jothee 4.6k views
38 votes
7 answers
3
9.7k views
Statement for Linked Answer Questions 83a & 83b: Consider the following expression grammar. The semantic rules for expression evaluation are stated next to each grammar production. ... of a shift over a reduce action It detects shift-reduce conflict, and resolves the conflict in favor of a reduce over a shift action
asked Sep 23, 2014 in Compiler Design Kathleen 9.7k views
19 votes
1 answer
4
5.6k views
Consider the grammar: $S \rightarrow (S) \mid a$ Let the number of states in SLR (1), LR(1) and LALR(1) parsers for the grammar be $n_1, n_2$ and $n_3$ respectively. The following relationship holds good: $n_1 < n_2 < n_3$ $n_1 = n_3 < n_2$ $n_1 = n_2 = n_3$ $n_1 \geq n_3 \geq n_2$
asked Sep 22, 2014 in Compiler Design Kathleen 5.6k views
...