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 The operational semantics for the integer division is shown as the following rule: E+e1/e2n12E+e1n1E+e2n2n2=0 Explain why we have the condition n2=0. How can we handle the divide-by-zero runtime error case with our semantics if we have only this rule for the division
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
