Question: Consider a simple imperitive programming language. The syntax of this programming langauge is similar to C. The expression and statement syntax is shown as follows:


Consider a simple imperitive programming language. The syntax of this programming langauge is similar to C. The expression and statement syntax is shown as follows: The language has simple arithmetic operations, equal comparison, and logical operations including "\&\&" (and), "II" (or), and "!" (not). Like other imperitive programming languages, it has assignment statements and if statements. Multiple statements will be separated by ";" and be executed sequentially. This langauge has only integer values. Similar to C, it uses zero to represent false and non-zero to represent true for boolean conditions and operations. To formally define the semantics of the programming language, we use the notation we introduced in the class. Specifically, a program in the langauge operates with an execution environment E=vn,. defined as a list of entries saperated by comas. Each entry binds a variable to an integer. We use notation E+en to denote that under the enviroment E, an expression e in the language will evaluate to the integer value n. We use notation EsE to denote under the environment E, the execution of the statement s will produce a new environment E. We can write down the operational semantics for variable reference, integer constant, addition, substraction, multiplication, variable assignment, and sequential execution as the following inference rules: E+nnnZE+vnE(v)=nE+e1+e2n1+n2E+e1n1E+e2n2E+e1e2n1n2E+e1n1E+e2n2E+e1e2n1n2E+e1n1E+e2n2E+v=eEEen1E=vn1,EE+s1;s2EEs1EEs2E Part (b) [4 MARKS] The following rules define the operational semantics for the equal comparison, the boolean not operator, and the boolean and operator: Similar to C, our programming language will treat input operands with zero as false and non-zero as true. But the result of boolean operations will be either zero or one, e.g., in our language 2&&3 would produce the result of 1 . Please write down inference rules to define the semantics of the boolean or operator. Note that both the boolean or and the boolean and operators should be short-circuited
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
