Question: please help solve this attribute-grammar question. with the following requirements: - two variables on the right side of an assignment need not be the same
with the following requirements: - two variables on the right side of an assignment need not be the same type - when the operand types are not the same, the expression type is always real. - When they are the same, the expression type is that of the operands. - The type of the left side of the assignment must match the type of the right side. With B being int, and A being real, use same process of the Attribute-Grammar example in lecture slides to analyze statement: B=B+A. Your answer will include (1) Is B=B+A valid or invalid. (2) order of the semantics rules being executed, and the reason why the statement B=B+A is valid or invalid. Hint: the following is the order of the semantics rules of the example A=A+B in the lecture notes 1. .actual_type look-up(A) (Rule 4) 2. .expected_type .actual_type (Rule 1) 3. [2].actual_type look-up(A) (Rule 4) [3].actual_type look-up(B) (Rule 4) 4. .actual_type either int or real (Rule 2) 5. .expected_type = .actual type is either TRUE or FALSE (Rule 2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
