COMS W4115
Programming Languages and Translators
Lecture 18: Translating Statements into Three-Address Code
March 31, 2014

Lecture Outline

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

1. Three-Address Code

2. Translation of Assignments

3. Translation of Arrays

4. Translation of Boolean Expressions

5. Translation of If-statements

6. Translation of While-statements

7. 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
      

8. Reading



aho@cs.columbia.edu