Question: Write an attribute grammar whose BNF basis is that of Example 3.6 in Section 3.4.5 but whose language rules are as follows: Data types cannot
Write an attribute grammar whose BNF basis is that of Example 3.6 in Section 3.4.5 but whose language rules are as follows: Data types cannot be mixed in expressions, but assignment statements need not have the same types on both sides of the assignment operator.
Data from Example 3.6:
![1. Syntax rule: Semantic rule: .expected_type .actual_type 2. Syntax rule: → [2] + [3] Semantic rule: .actual_type - → = if ([2].actual_type = int) and ([3].actual_type = int) then int else real end if Predicate: .actual_type %33D .expected_type 3. Syntax rule: Semantic rule: .actual_type .actual_type Predicate:](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1607/4/9/7/9455fd078d954efc1607497951163.jpg)
1. Syntax rule: Semantic rule: .expected_type .actual_type 2. Syntax rule: [2] + [3] Semantic rule: .actual_type - = if ( [2].actual_type = int) and ( [3].actual_type = int) then int else real end if Predicate: .actual_type %33D .expected_type 3. Syntax rule: Semantic rule: .actual_type .actual_type Predicate: .actual_ty %3D3D .expected_type A | BIC 4. Syntax rule: Semantic rule: .actual_type look-up ( .string)
Step by Step Solution
3.41 Rating (173 Votes )
There are 3 Steps involved in it
Replace the second sema... View full answer
Get step-by-step solutions from verified subject matter experts
