tax rule: ® = Semantic rule: .expected_type ¬ .actual_type 2. Syntax rule: ® Semantic rule: .actual_type ¬ .actual_type Predicate: .actual_type == . expected_type 3. Syntax rule: ® + Semantic rule: .actual_type ¬ .actual_type Predicate: .actual_type == . expected_type 4. Syntax rule: ® Semantic rule: .actual_type ¬ .actual_type 5. Syntax rule: ® [2] + [3] Semantic rule: .actual_type ¬ [2].actual_type Predicate: [2].actual_type == [3].actual_type 6. Syntax rule: ®A|B|C
question 3:
1. Syntax rule: <assign> ® <var> = <expr>
Semantic rule: <expr>.expected_type ¬ <var>.actual_type
2. Syntax rule: <expr> ® <var>
Semantic rule: <expr>.actual_type ¬ <var>.actual_type
Predicate: <expr>.actual_type == <expr>. expected_type
3. Syntax rule: <expr> ® <var> + <term>
Semantic rule: <expr>.actual_type ¬ <term>.actual_type
Predicate: <expr>.actual_type == <expr>. expected_type
4. Syntax rule: <term> ® <var>
Semantic rule: <term>.actual_type ¬ <var>.actual_type
5. Syntax rule: <term> ® <var>[2] + <var>[3]
Semantic rule: <term>.actual_type ¬ <var>[2].actual_type
Predicate: <var>[2].actual_type == <var>[3].actual_type
6. Syntax rule: <var> ®A|B|C
Semantic rule: <var>.actual_type ¬ look-up(<var>.string)
Answer the following questions according to the grammatical rules specified.
a. Create the parser tree structure for the C = B + C + A sentence.
b. Is this a correct sentence according to this grammar
Step by step
Solved in 2 steps with 1 images