in Compiler Design edited by
6,298 views
4 votes
4 votes

The answer is given A it is right but what is the problem in D option it also may be possible or not?

in Compiler Design edited by
6.3k views

1 comment

Answer is given A , It is right answer. could D also be one possible answer?

0
0

3 Answers

6 votes
6 votes
Best answer

 A recursive descent parser is a kind of top-down parser built from a set of mutually recursive procedures (or a non-recursive equivalent) where each such procedure usually implements one of the productions of the grammar.

It is said so because it's clear that recursive descent parser will go into infinite loop if the non-terminal keeps on expanding into itself.

Similarly, talking about a recursive descent parser,even with backtracking---When we try to expand a non-terminal, we may eventually find ourselves again trying to expand the same non-terminal without having consumed any input.

A-> Ab

Here,while expanding the non-terminal A can be kept on expanding into

A-> AAb -> AAAb -> ... -> infinite loop of A.

Hence, we prevent left-recursive productions while working with recursive-descent parsers.

selected by
2 votes
2 votes
Ansswer will be a And Left Recursive is a problem for Top down and not for Bottom up parser . So it can be used for parsing :)

4 Comments

Then Non determinism(Left factoring) is also problem for top down parser only not for bottom- up ?

what about ambiguity is it creates problem both for top down as well as bottom up (exept oprator precedence) ?

please explain.
0
0
What i need to explain

you are absolutely right what you said :)
1
1
Thanks for your help...
0
0
For ambiguity the reason may be left recursion or factoring but not always left recursed is ambiguous or left factored is ambigous

example :S->Sa | a is not ambiguous where as

S->Sa | SS| a  is  ambiguous

But both grammers are left recursed
1
1
0 votes
0 votes

ans is (c)

formal grammar that contains left recursion cannot be parsed by a LL(k)-parser or other naive recursive descent parser unless it is converted to a weakly equivalent right-recursive form.