Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started