Informal semantics can be imprecise, which can lead to different compilers generating different code. For example, take the C expression f(i++, --i), the order of execution of i++ and --i (the parameters of functions) is not specified in the definition of the C language.

One approach to give a precise, formal description is in terms of an abstract machine, which is a transition system which specifies an interpreter for the programming language.

Abstract Syntax

Programs

Commands

Integer Expressions

  • where (integers)
  • where (locations or variables) denotes the value stored in

Boolean Expressions

Tree Representation

Consider if 5 > 0 then skip else (skip; I := 0):

Example Problems

Swap the contents of the variables and :

z := !x; x := !y; y := !z

Assuming variable contains a natural number , compute factorial of :

factorial := 1;
while !I > 0 do
	(factorial := !factorial * !I;
	 I := !I - 1)