Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following shows an Attribute Grammar. Syntax rule: rightarrow = Semantic rule: .expected_type leftarrow .actual_type Syntax rule: rightarrow [2) + [3] Semantic rule: .actual_type leftarrow
The following shows an Attribute Grammar. Syntax rule: rightarrow = Semantic rule: .expected_type leftarrow .actual_type Syntax rule: rightarrow [2) + [3] Semantic rule: .actual_type leftarrow if ( [2].actual_type = int) and ( [3].actual_type = int) then int else real end if Predicate: .actual_type == .expected_type Syntax rule: rightarrow Semantic rule: .actual_type leftarrow .actual_type Predicate: .actual_type = = .expected_type Syntax rule: rightarrow A | B | C Semantic rule: .actual_type leftarrow look-up( .string) The look-up function looks up a given variable name in the symbol table and returns the variables type. Syntax portion of this example AG is: rightarrow = rightarrow A | B | C rightarrow + | rightarrow () | Answer the following questions for the statement B = A + E + C Show the leftmost derivation Draw the parse tree Suppose, B is real_tpe, A and C are int_type, decorate the parse tree
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