Spread Knowledge

Virtual University of Pakistan Video Lectures, Handouts, PPT, Quizzes, Assignments & Papers

CS606 - Compiler Construction - Lecture Handout 38

User Rating:  / 0

Related Content: CS606 - VU Lectures, Handouts, PPT Slides, Assignments, Quizzes, Papers & Books of Compiler Construction

Three-Address Statement Types

Prior to proceeding with flow-of-control construct, here are the types of three-Address statements that we will use

CS606 - Compiler Construction - Lecture Handout 37

User Rating:  / 0

Related Content: CS606 - VU Lectures, Handouts, PPT Slides, Assignments, Quizzes, Papers & Books of Compiler Construction

Here is the bottom-up parse of the assignment statement a = b*-c + b*-c and the syntax-directed translation into three-address code.

Parser action attribute Three- address code
id=id ∗ –id + id ∗ –id    
id=E1 ∗ –id + id ∗ –id E1.place = b  
id=E1 ∗ –E2 + id ∗ –id E2.place = c  
id=E1 ∗ E2 + id ∗ –id E2.place = t1 t1 = – c
id=E1 + id ∗ –id E1.place = t2 t2 = b∗t1
id=E1 + E2 ∗ –id E2.place = b  
id=E1 + E2 ∗ –E3 E3.place = c  
id=E1 + E2 ∗ E3 E3.place = t3 t3 = – c
id=E1 + E2 E2.place = t4 t4 = b∗t3
id=E1 E1.place = t5 t5 = t2+t4
S   a = t5

Read more: CS606 - Compiler Construction - Lecture Handout 37