COMS W4115
Programming Languages and Translators
Lecture 12: Syntax-Directed Translation
March 4, 2013

Lecture Outline

  1. The "dangling-else" ambiguity
  2. Syntax-directed definitions and translation schemes
  3. Synthesized and inherited attributes
  4. S-attributed SDDs
  5. L-attributed SDDs
  6. Reading

1. The "Dangling-Else" Ambiguity

2. Syntax-Directed Definitions and Translation Schemes

3. Synthesized and Inherited Attributes

4. Examples of S-Attributed SDDs

5. Example of an L-Attributed SDD

6. Practice Problems

  1. Using Yacc, implement a syntax-directed translator that translates sequences of postfix Polish expressions into infix notation. For example, your translator should map 345+* into 3*(4+5).
  2. Optimize your translator so it doesn't generate any redundant parentheses. For example, your translator should still map 345+* into 3*(4+5) but it should map 345*+ into 3+4*5.

7. Reading