**Contents**show

## Can recursive descent parser use left-recursive grammar?

The main limitation of recursive descent parsing (and top-down parsing algorithms in general) is that they only work on grammars with certain properties. For example, if **a grammar contains any left recursion, recursive descent parsing doesn’t work**.

## Can SLR parser handle left recursion?

2 Answers. **LR(1) parsers can handle** some types of left recursion, though not all left-recursive grammars are LR(1). There are no shift/reduce or reduce/reduce conflicts in this grammar, and so it should be LR(1) (unless I made a mistake somewhere!)

## How does left recursion affect top down parser?

A grammar that produces more than one parse tree for some sentence is said to be ambiguous. Due to the presence of left recursion **some top down parsers enter into infinite loop so we have to eliminate left recursion**. The nonterminal A generates the same strings as before but is no longer left recursive.

## Can recursive descent parser handle ambiguous grammar?

The LL(k) grammars therefore **exclude all ambiguous grammars**, as well as all grammars that contain left recursion. … Any context-free grammar can be transformed into an equivalent grammar that has no left recursion, but removal of left recursion does not always yield an LL(k) grammar.

## Can recursive descent parser parse the grammar?

Recursive-descent parsing can **only parse grammars that have disjoint predict sets for productions that share a common left hand side**. Two common properties of grammars that violate this condition are: Left recursion: any grammar containing productions with left recursion, that is, productions of the form A –> A X1…

## What are the limitations of recursive descent parser?

**Recursive descent parsers have some disadvantages:**

- They are not as fast as some other methods.
- It is difficult to provide really good error messages.
- They cannot do parses that require arbitrarily long lookaheads.

## Do we need to remove left recursion for SLR?

**No**, you need to eliminate the left recursion!

## Why does left recursion and non left factored grammar does not create problem for bottom up parser?

The main reason why Bottom up parser doesnt have any problem with Left recursive is **that it start building tree from leaves** . After seeing through a input you will check the next lookahead , if that lookahead lies in follow of a NT then you will reduce and if not then shift .

## Is left recursion a problem for LR parsers?

3) In LR parsers left recursion **is not a problem** because the parser tries to find the substring in the current sentential form that can be reduced to its LHS to get the next sentential form in right most derivation.

## Why is left recursion grammar bad not used in top down parser?

To understand why not, let’s take a very simple left-recursive grammar. There is only one token, a, and only one nonterminal, S. So the parsing table has just one entry. … The problem is that, on lookahead a, **the parser cannot know if another a comes after the lookahead**.

## Why left recursion causes difficulty during top down parsing?

The issue with left recursion is that **if you have a nonterminal that’s left-recursive and find a string that might match it**, you can’t necessarily know whether to use the recursion to generate a longer string or avoid the recursion and generate a shorter string.