Programming Language Semantics Using Miranda

Date Added: Aug 2009
Format: PDF

This paper explains the use of the functional programming language Miranda as a vehicle for describing the semantics of imperative programming languages. It gives a concise description of various semantic features of Pascal-like languages (Pascal, Modula-2, Modula-3, Ada and so on) written using Miranda programming language. The paper is intended to provide a reference document for the Miranda semantics rather than a general introduction to programming language semantics. The paper provides a full description in Miranda concentrating on the main features of the semantics, and ignoring some of the more mundane operations. They will go through three stages - identifying the data types; identifying the types of semantic functions; and defining the semantic functions themselves. The approach which is adopted to semantics is best described by Tennent which gives an excellent overview of the way in which programming languages work. Tennent discusses two kinds of value for a variable name: the l-value (is the storage location denoted by the variable), and the r-value (is the value stored in the location). This presented semantics is a familiar language which makes a clear distinction between the functional description of the imperative (which this semantics gives) and a domain-theoretic description of recursion. This paper shows that compiler for this language into a simple stack machine, which is itself modeled in Miranda.