The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+19 votes

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

asked in Compiler Design by Veteran (52k points) | 3.5k views

3 Answers

+40 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.

answered by Boss (13.2k points)
edited by
Since ambiguity is undecidable problem so left recursion should be answer then, isn't it?

both left recursive and right recursive??
+9 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

answered by Boss (30.6k points)
nopes A is a better answer.
i think the precedence should go like

1) ambigious

2) left recursive

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

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,530 questions
54,139 answers
71,068 users