Question: Write an attribute grammar whose BNF basis is that of the example pictured below but whose language rules are as follows: Data types cannot be

Write an attribute grammar whose BNF basis is that of the example pictured below 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

Write an attribute grammar whose BNF basis is that of the example

EXAMPLE 3.6 An Attribute Grammar for Simple Assignment Statements 1. Syntax rule: 5 Semantic rule: .actual_type 2. Syntax rule: [2] + .actual_type if ([2].actual_type = int) and ([3].actual_type = int) then int else real end if Predicate: .actual_type == Semantic rule: .actual_type + .actual_type Predicate: .actual_type -- .expected_type 4. Syntax rule: ABC Semantic rule: .actual_type + look-up (.string) The look-up function looks up a given variable name in the symbol table and returns the variable's type

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!