



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Boolean Expressions, Backpatching, Quadruples, Recall, Reduction, Semantic Actions, Control Statements are basic concepts discussed of course.
Typology: Slides
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































2
{ backpatch(E1.truelist, M.quad); E.truelist = E 2 .truelist; E.falselist = merge(E 1 .falselist, E 2 .falselist);}
So the target for E 1 .truelist must be the beginning of code generated for E (^2)
4
{ backpatch(E1.truelist, M.quad); E.truelist = E 2 .truelist; E.falselist = merge(E 1 .falselist, E 2 .falselist);}
M.quad records the number of the first statement of E 2 .code.
5
backpatch(E1.falselist, M.quad); E.truelist = merge(E 1 .truelist, E 2 .truelist); E.falselist = E 2 .falselist; } If E1 is false, need to test E 2
7
Boolean Experssions
E → ( E 1 ) { E.truelist = E 1 .truelist; E.falselist = E 1 .falselist; }
8
Boolean Experssions
E → id 1 relop id 2 { E.truelist = makelist(nextquad()); E.falselist = makelist(nextquad()+1); emit(‘if’ id 1 relop id 2 ‘goto _’) ; emit(‘goto _’ ); }
10
Boolean Experssions
E → false { E.falselist = makelist(nextquad()); emit(‘goto _’ ); }
11
M → ε { M.quad = nextquad(); }
13
In response to reduction of a < b to E, the two quadruples
are generated
14
Recall
E → id 1 relop id 2 { E.truelist = makelist(nextquad()); E.falselist = makelist(nextquad()+1); emit(‘if’ id 1 relop id 2 ‘goto _’) ; emit(‘goto _’ ); } View this in a parse tree
16
The marker non-terminal M in the production
records the value of nextquad which at this time is 102.
17
E.t = {100} E.f = {101}
c < d
a < b
e < f
M.q = 102
or and
ε
19
E.t = {100} E.f = {101}
E.t = {102} E.f = {103} c < d
a < b
e < f
M.q = 102
or and
ε
20
The marker non-terminal M in the production
records the value of nextquad which at this time is 104.