Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  The grammar A → AA | (A) | ε is no... Start Learning for Free
The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar is
  • a)
    ambiguous
  • b)
    left-recursive
  • c)
    right-recursive
  • d)
    an operator-grammar
Correct answer is option 'B'. Can you explain this answer?
Most Upvoted Answer
The grammar A → AA | (A) | ε is not suitable for predictive...
nswer (B) is correct because grammar is left recursive, hence the parser may fall into a loop. Answer A is not correct because ambiguity can occur from both left or right recursion.
Free Test
Community Answer
The grammar A → AA | (A) | ε is not suitable for predictive...
Explanation:

Predictive parsing is a top-down parsing technique that uses a lookahead symbol to predict which production rule to use to generate the input string. The grammar A AA | (A) | is not suitable for predictive parsing because it is left-recursive.

1. Left-Recursive Grammar:

A grammar is called left-recursive if there is a non-terminal symbol A that can derive a string beginning with itself. In the grammar A AA | (A) |, the non-terminal symbol A can derive a string beginning with itself, which makes it left-recursive.

2. Predictive Parsing:

Predictive parsing is a top-down parsing technique that tries to predict which production rule to use to generate the input string. It uses a lookahead symbol to predict the next input symbol and then uses a set of production rules to generate the input string.

3. Issues with Left-Recursive Grammar:

Left-recursive grammars are not suitable for predictive parsing because they can lead to infinite recursion. When a left-recursive rule is encountered during parsing, the parser will keep expanding the rule until it runs out of memory or exceeds the maximum recursion depth.

4. Solution:

To make the grammar suitable for predictive parsing, we need to eliminate left-recursion. One way to eliminate left-recursion is to rewrite the grammar using right-recursion. Another way is to use a technique called left-factoring, which involves factoring out common prefixes from the production rules.

In conclusion, the grammar A AA | (A) | is not suitable for predictive parsing because it is left-recursive. To make the grammar suitable for predictive parsing, we need to eliminate left-recursion using techniques such as left-factoring or right-recursion.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Question Description
The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer?.
Solutions for The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer?, a detailed solution for The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? has been provided alongside types of The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The grammar A → AA | (A) | ε is not suitable for predictive-parsing because the grammar isa)ambiguousb)left-recursivec)right-recursived)an operator-grammarCorrect answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev