Skip to main content
11 votes

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: ...
AProgrammer's user avatar
  • 3,069
8 votes
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 ...
AProgrammer's user avatar
  • 3,069
6 votes

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 ...
user65808's user avatar
5 votes

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 ...
Raphael's user avatar
  • 72.4k
5 votes

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 ...
Sarvottamananda's user avatar
3 votes

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)^+.$$ ...
Anton Trunov's user avatar
  • 3,479
3 votes
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,$$ ...
Anton Trunov's user avatar
  • 3,479
3 votes
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 (...
Yuval Filmus's user avatar
3 votes
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 ...
user979616's user avatar
2 votes
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 ...
rici's user avatar
  • 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 ...
Rinkesh P's user avatar
  • 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 ...
ryhn's user avatar
  • 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 \,|...
Pseudonym's user avatar
  • 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 ...
Yuval Filmus's user avatar
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 ...
Aaron Rotenberg's user avatar
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 ...
reinierpost's user avatar
  • 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 ...
gnasher729's user avatar
  • 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-...
clinux's user avatar
  • 247
1 vote

Eliminating left recursion and left factoring this grammar

check this image the problem is explained
Harshitha's user avatar

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