Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

CHAPTER 9. IMPLEMENTATION OF THE TRANSFORMER • Set expressions (ranged, enumerated, comprehended). • List expressions (ranged, enumerated, comprehended). • Map expressions (enumerated, comprehended). • Application expressions (function, list, map). • Bracketed expressions. • Value infix expressions. • Value prefix expressions. • Let expressions. • If expressions. • Case expressions. • Value literal patterns. • Name patterns. • Wildcard patterns. • Product patterns. • Record patterns. • List patterns. 9.8.5 Pretty Printing The resulting specification of a transformation is not pretty printed. No focus is put on that aspect as the RSL pretty printer can be used for that purpose. 108

Chapter 10 Examples of Transformations In order to give an idea of how the transformer works a couple of examples of transformations are given in this chapter. The first example just shows an example of applying the transformer to an applicative specification. The second example shows the development process from initial specification to imperative specification emphasizing the use of the transformer in the development process. 10.1 The Stack The stack example given in Chapter 2 is transformed by hand. In order to show that the automatic transformation done by the transformer follows the principles given in that chapter, the stack specification has been transformed using the transformer. The result can be seen in Example 10.1. For easy reference the applicative version of the stack specification is repeated here. Example 10.1 – Automatic transformation of the stack example scheme A_STACK = class type Stack = Element ∗ , Element value empty : Stack = 〈〉, is_empty : Stack → Bool is_empty(stack) ≡ stack = 〈〉, 109

Chapter 10<br />

Examples <strong>of</strong> <strong>Transformation</strong>s<br />

In order to give an idea <strong>of</strong> how the transformer works a couple <strong>of</strong> examples<br />

<strong>of</strong> transformations are given in this chapter. The first example just shows<br />

an example <strong>of</strong> applying the transformer to an applicative specification. The<br />

second example shows the development process from initial specification to<br />

imperative specification emphasizing the use <strong>of</strong> the transformer in the development<br />

process.<br />

10.1 The Stack<br />

The stack example given in Chapter 2 is transformed by hand. In order to<br />

show that the automatic transformation done by the transformer follows the<br />

principles given in that chapter, the stack specification has been transformed<br />

using the transformer. The result can be seen in Example 10.1. For easy<br />

reference the applicative version <strong>of</strong> the stack specification is repeated here.<br />

Example 10.1 – Automatic transformation <strong>of</strong> the stack example<br />

scheme A_STACK =<br />

class<br />

type<br />

Stack = Element ∗ ,<br />

Element<br />

value<br />

empty : Stack = 〈〉,<br />

is_empty : Stack → Bool<br />

is_empty(stack) ≡ stack = 〈〉,<br />

109

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!