# Tag Info

### Correct name for a recursive descent parser that uses loops to handle left recursion?

It is just an LL(1) parser implemented with recursive descent. Starts with: ...
• 3,069
Accepted

### Why not use Right Recursion to avoid Left Recursion?

The left recursive and the right recursive grammars describe the same language. But grammars do more than give the set of allowed strings in the language, they also give a structure to such strings ...
• 3,069

### Why is left recursion bad?

(I know this question's pretty old by now, but in case other people have the same question...) Are you asking in the context of recursive descent parsers? For example, for the grammar ...

### Correct name for a recursive descent parser that uses loops to handle left recursion?

You want to look into LL($k$) parsing. The Wikipedia article is mostly useless, but it's basically recursive descent with $k$ symbols lookahead. There is also LL($*$) which permits unbounded ...
• 72.4k

### Can I remove left recursion on this grammar

Yes that is correct. Also you can safely remove $A\rightarrow A$ type of production rules. So the equivalent grammar is $S'\rightarrow aS'\ |\ \epsilon$. If you analyze carefully you will see that ...
• 4,817

### Indirect Left recursion

Yes, both your answers are correct. Note that the language under consideration is regular, see wikipedia. The first grammar is equivalent to this regular expression: $$r_1 = a(ba)^* \mid (ba)^+.$$ ...
• 3,479
Accepted

### Transform grammar for repeating characters into LL(1)

Let's construct an LL(1) grammar for the language $\mathscr{L}(a^+)$. Firstly, observe that all the production rules in this case must have one of two forms: $$A \to a\Gamma$$ or $$A \to \epsilon,$$ ...
• 3,479
Accepted

### Explanation of Grammar Ambiguity

A grammar $G$ is non-amgibuous if every word in $L(G)$ has a unique parse tree. The simplest way to prove that your grammar non-ambiguous is to prove that $L(S + S),L(S * S),L(a)$ are all distinct (...
• 277k
Accepted

### Need to remove indirect left recursion from CFG

You should focus on trying to only modify productions that aren't "good". A production is "good" if it : Starts with a terminal, Is an epsilon production, or Is in the form ...
• 115
Accepted

### Remove left recursion from a grammar without necessarily removing epsilon production

If a grammar includes nullable productions, then it may have hidden left recursion; a production such as $A\to N A \beta$ where $N$ is nullable. Such a production won't be removed by Ullman's ...
• 12k
1 vote

### How would this grammar be converted to a non-left recursive rule?

The given grammar has a direct and an indirect recursion. There is no rule to solve this or such which mentions whether any production is to be changed or not. However one way to keep things clear ...
• 1,024
1 vote
Accepted

### eliminate left recursion of below grammar

$$𝑆 → YX \ | \ Y \\ Y → Ab \ | \ b \\ X → ABX \ | \ AB \\ A → SB \ | \ BS \ | \ a \\ 𝐵 → 𝐴𝑆 \ | \ d$$ At first I say which rules have a left recursion, considering that the middle tree which ...
• 26
1 vote

### Generating a recursive descent parser for grammar having Kleene star

I don't know that there is a "standard" way to do left recursion elimination from Kleene star. But this is one obvious translation: \begin{eqnarray*}F & \rightarrow & F^*\,|\, a \,|...
• 22.1k
1 vote

### Would a parser for this left-recursive grammar require infinite input?

Your grammar captures the empty language. To see this, you need to use the definition of a language described by a context-free grammar. A context-free grammar is a tuple $(T,N,S,P)$, where $T$ is the ...
• 277k
1 vote

### How to convert the left recursive grammar into right recursive grammar

Consider where "a" terminals can appear in a string produced by this grammar. Based on that, you should be able to split the "A" nonterminal up to make a right-recursive grammar that matches the same ...
• 3,523
1 vote

### Conversion of ambiguous left recursive grammar to LL(1)

I don't want to do your homework, but the two insights that appear to solve it for me are: What the first rules $S \rightarrow SoS$ $S \rightarrow SlSr$ say is that whatever else $S$ can be ...
• 5,584
1 vote

### Why not use Right Recursion to avoid Left Recursion?

You can use a grammar to recognize a language, but usually you want more: You want to know how a string was parsed. (That's why we want grammars that are unique, otherwise there are sentences that can ...
• 30.1k
1 vote

### How does this left-associative recursive descent parser work?

ANTLR handles direct left recursive grammar via a technic they call an oracle. You can find their paper to learn all about it. Basically the parser remembers if it had just parsed the current non-...
• 247
1 vote

### Eliminating left recursion and left factoring this grammar

check this image the problem is explained

Only top scored, non community-wiki answers of a minimum length are eligible