Apply all applicable optimizations to:
x = 3;
y = x;
z = x + 5;
a = y * 2;
b = 8;
c = b / 2;
d = a + 0;
if (a < b && c > d || e == f)
x = 1;
else
x = 0;
a = b * (-c) + d / e
E → E + T | T
T → T * F | F
F → (E) | id
Show the handle at each step for reducing the string: id + id * id
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;
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):
Parse the string id + id * id using this table.
Share this link via
Or copy link