Complete the code to define a syntax-directed translation scheme that associates semantic rules with grammar productions.
production [1] expression semantic_ruleThe symbol ::= is used in grammar productions to define the right-hand side of a production rule, which can be associated with semantic rules in syntax-directed translation.
Complete the semantic rule to compute the value of an addition expression in syntax-directed translation.
E -> E1 + T { E.val = E1.val [1] T.val }.val attribute.The semantic rule for addition sets the value of E as the sum of the values of E1 and T.
Fix the error in the semantic rule for multiplication in syntax-directed translation.
E -> E1 * T { E.val = E1.val [1] T.val }The semantic rule for multiplication must multiply the values of E1 and T using the * operator.
Fill both blanks to define a semantic rule that assigns the value of a number token to a non-terminal.
F -> num { F.val = [1].[2] }val instead of value for the token attribute.token which is not the attribute name.The semantic rule assigns the attribute value of the token num to F.val.
Fill all three blanks to define a semantic rule that computes the value of a subtraction expression.
E -> E1 - T { E.val = [1].[2] [3] T.val }val attribute of E1.The semantic rule sets E.val as the value of E1 minus the value of T.
