Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operational Semantics Homework For these exercises, we will expand the grammar and operational semantics for expressions given in the slides to include subtraction and integer

image text in transcribed
image text in transcribed
Operational Semantics Homework For these exercises, we will expand the grammar and operational semantics for expressions given in the slides to include subtraction and integer division as follows: . place . code { newTemp) [ 2 ] . code I l [ 3 ] . code II .place [2] .place .placenewTemp) .codeE[2].code II .placeE> [2] .place I3] place 1. Sketch the decorated parse tree for the following assignment statement: alpha 42* (alpha beta) 57 Since the grammar for expressions is ambiguous, you may assume that the parser somehovw enforces the normal order of operations (so that multiplication and division take precedence over addition and subtraction, and all operations are left-associative). Suppose we enhance the grammar for statements to include if-then-else statements in addition to the grammars and operational semantics for assignment statements and while loops given in the slides. In particular, we now have the following: 2. if (id[1] relop id[2]) then [1] else [2] The grammar and operational semantics for assignments and while loops are as given in the slides (with the enhancement for expressions to include subtraction and division). Write operational semantics for if-then-else statements. (Hint: in addition to the attribute .code, you may need attributes for labels for the then-part, the else-part and the end of the if-then-else statement. See the operational semantics for loops for a hint on how to do this.) Now, sketch the decorated parse tree to produce the three-address code for the following statement. 3. if (a

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago