LL (1) Parser
LL (1) Parser
Left recursion often poses problems for parser, either because it leads them into
infinite recursion.
Q2.S->Aa
A->Sb|c
Q.S → (L) / a
L→L,S/S
Q. A → Ba / Aa / c
B → Bb / Ab / dw
Left factoring is removing the common left factor that appears in two productions
of the same non-terminal.
Left factoring is a process by which the grammar with common prefixes is
transformed to make it useful for Top down parser. It consists in “factoring out”
prefixes which are common to two or more productions.
HOW TO REMOVE LEFT FACTORING?
Q1. A -> qB | qC
Ans: A -> qA’
A’ -> B | C
Q2.S->iEtS|iEtSeS|€, E->b
Ans: S->iEtSS’|€
S’->€|eS
E->b
Q3:S → aAd / aB
A → a / ab
B → ccd / ddc
ANS: S → aS’
S’ → Ad / B
A → aA’
A’ → b / ∈
B → ccd / ddc
ANS: S → aS’
S’ → bA / ∈
A → cB / ∈
B → d / ∈
LINK : https://www.gatevidyalay.com/left-factoring-examples-compiler-
design/