Question: Modify Type Rule 6.5 so that it checks the validity of an ArrayRef (see Figure 2.14) Must also show code!!! Please let me know if

Modify Type Rule 6.5 so that it checks the validity of an ArrayRef (see Figure 2.14) Must also show code!!! Please let me know if more information is needed. The answer from the book from this site is not good enough.

1. A Value is valid.

2. A Variable is valid if its id appears in the type map.

3. A Binary is valid if all the following are true:

* Its Expressions term1 and term2 are valid

* If its BinaryOp op is arithmetic (+, -, *, /), then both its Expressions must be either int or float.

* If op is relational (==, !=, <, <=, >, >=), then both its Expressions must have the same type.

* If op is boolean (&&, ||), then both its expressions must be bool.

4. A Unary is valid if all the following are true:

* Its Expression term is valid.

* If its UnaryOp op is !, then term must be bool.

* If op is -, then term must be int or float.

* If op is the type conversion float ( ) or char ( ), then term must be int.

* If op is the type conversion int ( ), then term must be float or char.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!