SDT
2026-11-18
notes / Compilers
Course: Compilers Date: 2025-09-12
Syntax Directed Translation
Slides
The role of Syntax Directed Translation is
- To associate rules with productions
- To associate attributes with non-terminals
- To create implicit or explicit syntax-tree
- To perform semantic analysis
Syntax Directed Definitions
- a CFG with attributes and rules
- attributes are associated with grammar symbols
- rules are associated with productions
- specifies the semantics of productions
- does not enforce a way of achieving the semantics
You basically create an annotated grammar: where beside every production you have the semantic rule associate with it
| T -> FT' |
T'.inh = F.val T.val = T'.syn |
| T' -> *FT' |
T'.inh = T'.inh x F.val T'.syn = T'.syn |
| T' -> eps |
T'.syn = T'.inh |
| F -> digit |
F.val = digit.lexval |
Attributes

- synthesized: passed up the syntax tree
- inherited: passed down the syntax tree
Evaluation Orders of SDD
Important SDDs
Computing Types and Their Width

3 Address Codes


Backpatching


linked from