Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. (20pt) Consider the following SLR(1) grammar G for arithmetic expressions: E EAT E T T TMF T F F -F F (E) A +

image text in transcribed

5. (20pt) Consider the following SLR(1) grammar G for arithmetic expressions: E EAT E T T TMF T F F -F F (E) A + - M F id (1) (15pt) Construct an attributed grammar, based on G, that computes the type and value of an expression assuming that id's have, form the scanner, two attributes: type, which can be int or float and val, which is a number. In any operation, if one operand is a float, then both operands are converted to float using the operation n= float(n); e.g., float(2) = 2.0; the operation can be performed only between operands of the same type. The grammar does not have to be L-attributed. (2) (5pt) Using this attributed grammar, draw a decorated parse tree for the following expres- sion: (4 + -2.0) * 3. Show all attributes and arrows indicated what attributes are used to compute each value. 5. (20pt) Consider the following SLR(1) grammar G for arithmetic expressions: E EAT E T T TMF T F F -F F (E) A + - M F id (1) (15pt) Construct an attributed grammar, based on G, that computes the type and value of an expression assuming that id's have, form the scanner, two attributes: type, which can be int or float and val, which is a number. In any operation, if one operand is a float, then both operands are converted to float using the operation n= float(n); e.g., float(2) = 2.0; the operation can be performed only between operands of the same type. The grammar does not have to be L-attributed. (2) (5pt) Using this attributed grammar, draw a decorated parse tree for the following expres- sion: (4 + -2.0) * 3. Show all attributes and arrows indicated what attributes are used to compute each value

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

5. Arranging for the training facility and room.

Answered: 1 week ago

Question

1. Discuss the five types of learner outcomes.

Answered: 1 week ago