S → ACB | CbB | Ba
A → da | BC
B → g | ε
C → h | ε
Construct the LL(1) parsing table. Is this grammar LL(1)? Justify your answer.
Start state: A
Final states: {D, F}
Transitions:
δ(A, 0) = B, δ(A, 1) = C
δ(B, 0) = D, δ(B, 1) = E
δ(C, 0) = E, δ(C, 1) = D
δ(D, 0) = D, δ(D, 1) = D
δ(E, 0) = F, δ(E, 1) = F
δ(F, 0) = F, δ(F, 1) = F
Show all steps clearly including partition refinement.
S → aS | bA
A → bA | c
Show how it parses the string “aabc”.
(a|b)*a(a|b)
Then convert this NFA to DFA using subset construction method. Finally, minimize the DFA using state minimization algorithm.
while (a < b) {
if (c < d)
x = y + z;
else
x = y – z;
}
Also show the quadruples and explain how backpatch function works.
Construct the LL(1) parsing table for the following grammar (after removing left recursion if needed):
E → E + T | T
T → T * F | F
F → (E) | id
Parse the string id + id * id using this table.
Share this link via
Or copy link