
Ultimate access to all questions.
Answer-first summary for fast verification
Answer: Na produção 4, T.val e F.val são sintetizados.
## Explanation In syntax-directed translation, attributes can be either **synthesized** or **inherited**: - **Synthesized attributes**: Computed from child nodes to parent nodes (bottom-up) - **Inherited attributes**: Computed from parent nodes or siblings to child nodes (top-down or sideways) Let's analyze each option: **Option A**: In production 4 (T → T₁ * F), T.val is synthesized because it's computed from its children T₁.val and F.val. F.val is also synthesized because it comes from its own production rules. **This is CORRECT**. **Option B**: In production 4, T₁.val is NOT inherited - it's synthesized. T₁ is a non-terminal on the right side, and its value comes from its own subtree. **Option C**: In production 5 (T → F), T.val is synthesized from F.val, and F.val is synthesized from its own production rules. Neither is inherited. **Option D**: In production 2 (E → E₁ + T), E.val is synthesized (computed from E₁.val and T.val), but T.val is NOT inherited - it's synthesized from its own subtree. **Option E**: In production 2, E₁.val is synthesized (comes from its subtree), but T.val is NOT inherited - it's synthesized. **Key points**: - In this grammar, all attributes are **synthesized attributes** - The grammar uses only synthesized attributes, which is typical for simple arithmetic expression evaluation - Inherited attributes would be needed for more complex translations like type checking or symbol table management - The computation flows bottom-up: from leaves (digits) up to the root (L)
Author: Danyel Barboza
No comments yet.
QUESTÃO 63 – Considere o esquema de tradução dirigida pela sintaxe apresentado a seguir, no qual as produções da gramática foram numeradas:
| Produções | Ações Semânticas |
|---|---|
| 1) L → E n | L.val = E.val |
| 2) E → E₁ + T | E.val = E₁.val + T.val |
| 3) E → T | E.val = T.val |
| 4) T → T₁ * F | T.val = T₁.val * F.val |
| 5) T → F | T.val = F.val |
| 6) F → (E) | F.val = E.val |
| 7) F → digit | F.val = digit.lexval |
Assinale a alternativa correta sobre o esquema.
A
Na produção 4, T.val e F.val são sintetizados.
B
Na produção 4, T₁.val é herdado.
C
Na produção 5, T.val e F.val são herdados.
D
Na produção 2, E.val é sintetizado e T.val é herdado.
E
Na produção 2, E₁.val é sintetizado e T.val é herdado.