[Solved]Job Finish Three Functions Model Derivation Step Big Step Semantics Slides Class B C Step Q37200575
/* ***************************************** * * Your job is to finish the three functions below that model the derivation step * (in our big-step semantics from the slides in class) of the =>_A, =>_B, and =>_C * step functions. interp_A takes an arithmetic expression, like {form: ‘x’, x: ‘z’}, * and a state/store, like (x) => {if (x == ‘z’) return 7;}, and yields a number, like 7. * interp_B takes a boolean expression and a store to a boolean, and interp_C takes a * command and a store to a new store (i.e., the program state, a model of the heap). Note * that the current store is a javascript function that should take some variable * (program location) and yield its current value in the store. (Note the definition of * sigma[x mapsto n] in the slides.) See ast.js for a definition of some convenience * functions for producing an AST that define the different language forms as JSON objects. * ******************************************** */ exports.interp_A = interp_A; exports.interp_B = interp_B; exports.interp_C = interp_C;function interp_A(a, store) { if (a.form == ‘x’) // store should be a function that takes a variable name, like ‘x’, and returns its value return store(a.x); else if (a.form == ‘n’) // a number is just the constant stored in the AST node return a.n; else if (a.form == ‘+’) // A sum AST node is interpreted as the sum of the interpretations of each sub-expression return interp_A(a.a0, store) + interp_A(a.a1, store); // TODO: Add interpretations for ‘*’ and ‘-‘ expressions return interp_A(a.a0, store) * interp_A(a.a1, store); return interp_A(a.a0, store) – interp_A(a.a1, store); console.log(`failed to interpret: ${a} nwith store: ${store}`); } function interp_B(b, store) { // TODO: What other boolean expressions need to be handled in this function? if (b.form == ‘not’) return !interp_B(b.b, store); else if (b.form == ‘true’) return true; console.log(`failed to interpret: ${b} nwith store: ${store}`);} function interp_C(c, store) { if (c.form == ‘skip’) return store; // TODO: What other commands need to handled in this function? console.log(`failed to interpret: ${b} nwith store: ${store}`); }
Expert Answer
Answer to /* ***************************************** * * Your job is to finish the three functions below that model the derivat… . . .
OR

