Compiler Design Solutions: 1. What Is in The Follow (S) ?
Compiler Design Solutions: 1. What Is in The Follow (S) ?
Compiler Design Solutions: 1. What Is in The Follow (S) ?
SOLUTIONS
Explanation:
S → aSAb | bSBc
A → +AB | ε
B → *BC | ε
C → aC | d
Explanation:
b, First(B)
= {c, b, *, a, d}
1
3. Choose the False statement.
Explanation:
Explanation:
5.
X → YZ
Y → Y + Z {print (‘+’);}
T {Y.val = T.val}
Z → *Y {print (‘*’);} Z
T {Z.val = T.val}
ε
T → num {print(num.val);}
2
For 2+3*2, the above translation scheme prints
Explanation:
23 + 2*
For generating target code how many register will be required apart from accumulator A?
(a) 1 (b) 2
(c) 3 (d) 5
Explanation:
x=a*b–c*d+e
MOV A, a
MUL b
MOV R1, A
MOV A, C
MUL d
SUB R1, A
ADD R1, e
3
7. Consider the following two grammars
G1: A → A1 | 0A1 | 01
G2: A → 0A | 1
Explanation:
S → aB | aAb
A → bAb | a
B → aB | ε
How many back tracks are required to generate the string aab from the above grammar?
(a) 1 (b) 2
(c) 3 (d) 4
Explanation:
S ⇨ aB S ⇨ aAb S ⇨ aAb
⇨ aaB ⇨ abAbb ⇨ aab
⇨ aa ⇨ ababb
Backtrack Backtrack