Question: 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

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

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

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!