Question
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:
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:
{ { Sketch the decorated parse tree for the following assignment statement: Since the grammar for expressions is ambiguous, you may assume that the parser somehow 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: 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. if (a then d = b a else d = a b
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: alpha = 42*(alpha beta) + 57
--> | [1] else [2] [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.) 3. Now, sketch the decorated parse tree to produce the three-address code for the following statement if (a
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