SYNTAX ANALYSIS
ROLE OF THE PARSER
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
stack
|
|
cycle
|
|
queue
|
|
symbols
|
Detailed explanation-1: -If we have a left recursion in our grammar, then it leads to infinite recursion, due to which we cannot generate the given string.
Detailed explanation-2: -In compiler design, why should left recursion be eliminated in grammars? I am reading that it is because it can cause an infinite recursion, but is it not true for a right recursive grammar as well? Typically, compilers use top-down parsing. If you have left-recursion, then the parser goes into an infinite recursion.
Detailed explanation-3: -Before calculating the first and follow functions, eliminate Left Recursion from the grammar, if present.
Detailed explanation-4: -Removing left recursion cannot introduce ambiguity. This kind of transformation preserves ambiguity. If the CFG is already ambiguous, the result will be ambiguous too, and if the original is not, the resulting neither.