26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 8. SPECIFICATIONS<br />

8.5.2 Changing from Maps to Lists<br />

The idea is illustrated in the case <strong>of</strong> CONC1 being a map. The map type has<br />

to be changed <strong>into</strong> a list type as done several times in the actual translation<br />

<strong>of</strong> the transformer specification from RSL <strong>into</strong> RSL1. The operators on maps<br />

are turned <strong>into</strong> functions. Only the operators used in the specifications <strong>of</strong><br />

the transformer are considered here.<br />

As the type <strong>of</strong> the elements in the map is not important at this stage the<br />

elements <strong>of</strong> the map are defined as sorts, see Specification 8.3.<br />

Specification 8.3 – Specification <strong>of</strong> an element<br />

scheme ELEMENT = class type Elem end<br />

The concrete specification <strong>of</strong> the map CONC_MAP can be found in<br />

Specification 8.4. The functions are defined using map operators.<br />

Specification 8.4 – Concrete specification <strong>of</strong> a map<br />

scheme CONC_MAP(T1 : ELEMENT, T2 : ELEMENT) =<br />

class<br />

type Map = T1.Elem ∼ →m T2.Elem<br />

value<br />

/∗ generators ∗/<br />

empty : Map = [ ],<br />

override : Map × Map → Map<br />

override(m1, m2) ≡ m1 † m2,<br />

restrict_by : Map × T1.Elem-infset → Map<br />

restrict_by(m, t1) ≡ m \ t1,<br />

/∗ observers ∗/<br />

domain : Map → T1.Elem-infset<br />

domain(m) ≡ dom m,<br />

range : Map → T2.Elem-infset<br />

range(m) ≡ rng m,<br />

get_map_value : Map × T1.Elem ∼ → T2.Elem<br />

90

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

Saved successfully!

Ooh no, something went wrong!