This document discusses inherited and synthesized attributes in semantic analysis using syntax-directed translation (SDT). It covers:
- Synthesized attributes are defined by semantic rules associated with productions and rely only on child nodes, while inherited attributes rely on parent/sibling nodes.
- Terminals can have synthesized attributes from lexing but not inherited attributes. Nonterminals can have both.
- Annotated parse trees show attribute values, while dependency graphs determine evaluation order.
- S-attributed definitions rely only on synthesized attributes and evaluate bottom-up. L-attributed definitions restrict inherited attributes to avoid cycles.
- SDTs can construct syntax trees during parsing to decouple parsing from translation