Back to the 2023 paper

Module 3: Semantic Analysis, Symbol Table, Run-time environment

20237m

Given the Syntax-Directed Definition below with the synthesized attribute val. Draw the annotated parse tree for the expression (3+4)(5+6)(3+4) * (5+6)

LEL \to E, L.val=E.valL.val = E.val
ETE \to T, E.val=T.valE.val = T.val
EE1+TE \to E_1 + T, E.val=E1.val+T.valE.val = E_1.val + T.val
TFT \to F, T.val=F.valT.val = F.val
TT1FT \to T_1 * F, T.val=T1.valF.valT.val = T_1.val * F.val
F(E)F \to (E), F.val=E.valF.val = E.val
FdigitF \to digit, F.val=digit.lexvalF.val = digit.lexval

Similar questions