Spring 2011 CSCI 565 - Compiler Design
Spring 2011 CSCI 565 - Compiler Design
Spring 2011 CSCI 565 - Compiler Design
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Pedro Diniz<br />
pedro@isi.edu<br />
E → E 1 or E 2 ‖ E.place = newtemp()<br />
<strong>CSCI</strong> <strong>565</strong> - <strong>Compiler</strong> <strong>Design</strong><br />
<strong>Spring</strong> <strong>2011</strong><br />
Arithmetic Scheme: Grammar and Actions<br />
E.code = append(E 1 .code,E 2 .code,gen(E.place = E 1 .place or E 2 .place)<br />
E 1 .nextstat = E.nexstat<br />
E 2 .nextstat = E 1 .laststat<br />
E.laststat = E 2 .laststat + 1<br />
E → E 1 and E 2 ‖ E.place = newtemp()<br />
E.code = append(E 1 .code,E 2 .code,gen(E.place = E 1 .place and E 2 .place)<br />
E 1 .nextstat = E.nexstat<br />
E 2 .nextstat = E 1 .laststat<br />
E.laststat = E 2 .laststat + 1<br />
E → id 1 relop id 2 ‖ E.place = newtemp()<br />
E.code = gen(if id1.place relop id2.place goto E.nextstat+3)<br />
E.code = append(E.code,gen(E.place = 0))<br />
E.code = append(E.code,gen(goto E.nextstat+2))<br />
E.code = append(E.code,gen(E.place = 1))<br />
E.laststat = E.nextstat + 4