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:

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

1 Expert Approved Answer
Step: 1 Unlock

Replace the second sema... View full answer

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 Concepts of Programming Languages Questions!