COMS W4115
Programming Languages and Translators
Lecture 16: Translating Statements into Three-Address Code
March 25, 2015

Lecture Outline

  1. Types
  2. Three-address code
  3. Translation of assignments
  4. Arrays
  5. Boolean expressions
  6. If-statements
  7. While-statements

1. Types

2. Three-Address Code

3. Translation of Assignments

4. Translation of Arrays

5. Translation of Boolean Expressions

6. Translation of If-statements

7. Translation of While-statements

8. Practice Problems

  1. Use the SDD of Fig. 6.22 (ALSU, p. 383) to translate the assignment x = a[i][j] + b[i][j].
  2. Add rules to the SDD in Fig. 6.36 (ALSU, p. 402) to translate do-while statements of the form:
  3.    Sdo S while B
    Show the code your SDD would generate for the program
    
         do
           do
             assign1
           while a < b
         while c < d
      

9. Reading



aho@cs.columbia.edu