
Ultimate access to all questions.
Deep dive into the quiz with AI chat providers.
We prepare a focused prompt with your quiz and certificate details so each AI can offer a more tailored, in-depth explanation.
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.
Explanation:
In syntax-directed translation, attributes can be either synthesized or inherited:
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: