Professional Documents
Culture Documents
Backtracking. Left Recursion. Left Factoring
Backtracking. Left Recursion. Left Factoring
Backtracking. Left Recursion. Left Factoring
an ambiguous grammar is a context-free grammar for which there exists a string that
can have more than one leftmost derivation or parse tree
21. What is left recursion? What is the problem with left recursion?
The grammar of the form,
S --> S / a / b
called left recursive where S is any non Terminal and a, and b are any set of terminals.
If a left recursion is present in any grammar then, during parsing in the syntax analysis
part of compilation there is a chance that the grammar will create an infinite loop. This is
because at every time of production of grammar S will produce another S without
checking any condition.
A handle of a string is a substring that matches the right side of a production, and
whose reduction to the nonterminal on the left side of the production represents one
step along the reverse of a rightmost derivation.