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: ...
  • 3,014
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 ...
  • 3,014
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 ...
6 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 ...
  • 71.6k
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 ...
  • 4,787
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 (...
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 ...
3 votes

Why is left recursion bad?

From Bison manual: "Any kind of sequence can be defined using either left recursion or right recursion, but you should always use left recursion, because it can parse a sequence of any number of ...
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)^+.$$ ...
  • 3,459
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,$$ ...
  • 3,459
1 vote

Eliminating left recursion and left factoring this grammar

check this image the problem is explained
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 ...
  • 769
1 vote
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 ...
  • 11.7k
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

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 ...
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 ...
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 ...
  • 4,943
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 ...
  • 27.1k
1 vote

Eliminate Left Recursion

The "standard" pattern to eliminate the immediate left recursion would have been: B -> F B' | A B' B' -> ฮต | A B' I guess this is why you have been told ...
  • 217
1 vote

Removing Left Recursion

The fact confusing you might be, that the given grammar isn't left recursive at all and so nothing has to be done. To be left recursive there would have to be a nonterminal Symbol, that by a chain of ...
  • 217

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