Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Consider the following partial grammar with denotational semantics for a stat

ID: 3736209 • Letter: 2

Question

2. Consider the following partial grammar with denotational semantics for a statement list [1]; | { Ms(, s) = case of [1]; => M,(«stmt>, Msl([1], s)) => Ms(, s) x = ,s)--error) then error else s' = ki,v/>,' for k = 1,2, ,n ,«inNn,») where if(i,-=x) then vk' = Me(«expr>,s) else vk' = VARMAP(ik,s) y + z (Me(«expr>,s) = if(VARMAP(y,s)--undef OR VARMAP(z,s)--undef) then error else VARMAP(y) VARMAP(z) y * z (Me(«expr>,s) = if(VARMAP(y,s)-=under OR VARMAP(z,s)=undef) then error else VARMAP(y) VARMAPz) Assuming the current state is (, ,), compute the state after the following assignment statements: a=a*b; b = a + c;

Explanation / Answer

Let us first create a VARMAP TABLE for a,b,c:-

a = a * b. This we can write as:-

Me(a,s) = VARMAP (a) * VARMAP (b) = 15 * 40 = 600. Thus the latest VARMAP(a) = 600.

Next we have, b = a + c. This we can write as:-

Me(b,s) = VARMAP (a) + VARMAP (c) = 600 + 52 = 652.

Thus finally after execution of the following assignment statements, we have the state of a,b,c as:-

{ <a, 600>, <b, 652>, <c, 52> } [Ans]

Please let me know in case of any clarifications required. Thanks!

Variable VARMAP a 15 b 40 c 52