Course: Compilers Date: 2025-09-12 topics: syntax compilers
Syntax Directed Translation
- Syntax Directed Definition
- Attributes
- Evaluation Orders
- Applications of SDT
- Syntax Directed Translation Schemes
- Implementing L-Attributed SDD’s
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
production | semantic rule |
---|---|
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 |
this table doesn’t make much sense though so take lightly |
Attributes
flowchart TB A[Attributes] B[Inherited] C[Synthesized] A --> B A --> C
- synthesized: passed up the syntax tree
- inherited: passed down the syntax tree