Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS /∗Checks if one of the ids of the type expression list is in the Idset.∗/ /∗ Arguments: ======= tel: the type expression list idset: the set of ids, either the domain or range of TRANS Results: ===== Bool: true if on of the ids of the type expression list is in the idset, false otherwise ∗/ includesTRANSNameList : TypeExpr ∗ × Id-set → Bool includesTRANSNameList(tel, idset) ≡ if tel = 〈〉 then false else includesTRANSName(Known(hd tel), idset) ∨ includesTRANSNameList(tl tel, idset) end, /∗Gets the variable name corresponding to a type of interest. Pre_condition: et = Known(TypeName(id)).∗/ /∗ Arguments: ======= et: the expected type Result: ======= ValueExpr: the corresponding ValueOrVariableName ∗/ getTRANS : ExpType × TRANS → ValueExpr getTRANS(et, trans) ≡ case et of Known(te) → case te of TypeName(tn) → Make_ValueOrVariableName( mk_ValueOrVariableName(trans(tn))) end end, 280

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER /∗Gets the id corresponding to a type of interest. Pre_condition: et = Known(TypeName(id)).∗/ /∗ Arguments: ======= et: the expected type Result: ======= Id: the corresponding Id ∗/ getTRANSId : ExpType × TRANS → Id getTRANSId(et, trans) ≡ case et of Known(te) → case te of TypeName(tn) → trans(tn) end end, /∗**** TRANS end ****∗/ /∗**** TYPINGS ****∗/ /∗Makes a TYPINGS map from a type definition list. ∗/ /∗ Arguments: ======= tdl: the type definition list ∗/ makeTYPINGSMap : TypeDef ∗ → TYPINGS makeTYPINGSMap(tdl) ≡ if tdl = 〈〉 then [ ] else makeTYPINGSEntrance(hd tdl) † makeTYPINGSMap(tl tdl) end, /∗Makes a TYPINGS map entrance from a type definition. ∗/ /∗ Arguments: ======= td: the type definition 281

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />

/∗Gets the id corresponding to a type <strong>of</strong> interest.<br />

Pre_condition: et = Known(TypeName(id)).∗/<br />

/∗<br />

Arguments:<br />

=======<br />

et: the expected type<br />

Result:<br />

=======<br />

Id: the corresponding Id<br />

∗/<br />

getTRANSId : ExpType × TRANS → Id<br />

getTRANSId(et, trans) ≡<br />

case et <strong>of</strong><br />

Known(te) →<br />

case te <strong>of</strong><br />

TypeName(tn) → trans(tn)<br />

end<br />

end,<br />

/∗**** TRANS end ****∗/<br />

/∗**** TYPINGS ****∗/<br />

/∗Makes a TYPINGS map from a type definition list.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

tdl: the type definition list<br />

∗/<br />

makeTYPINGSMap : TypeDef ∗ → TYPINGS<br />

makeTYPINGSMap(tdl) ≡<br />

if tdl = 〈〉 then [ ]<br />

else<br />

makeTYPINGSEntrance(hd tdl) †<br />

makeTYPINGSMap(tl tdl)<br />

end,<br />

/∗Makes a TYPINGS map entrance from a type definition.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

td: the type definition<br />

281

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

Saved successfully!

Ooh no, something went wrong!