I have a problem in backpatching "if-else" statements, for generating 3 address codes.
The grammar rule is :
S -》 if E then M1 S1 N else M2 S2
The semantic rules are : {
backpatch(E.truelist, M1.quad)
backpatch(E.falselist, M2.quad)
S.nextlist = merge(S1.nextlist, N.nextlist,
S2.nextlist)
}
Explanation :
Merge(p1, p2) : concatinates lists pointed by p1 and p2)
Backpatch(p, i) : inserts i as the target label for each of the statements in the list pointed to by p)
S.nextlist : "goto" statements to the next instruction after this statement (s)
I don't understand why we need "N" in the semantic rules above. Why should we merge N.nextlist along with S1 and S2 nextlists for getting S.nextlist?? I mean why there is "N.nextlist" among other inputs? Tnx for answering, in advance :D
else
block? $\endgroup$