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 makeVariables(dlres, trans))), DL_not_transformable → Class_not_transformable end end, → Class_not_transformable end, /∗Transforms a declaration list if possible.∗/ /∗ Arguments: ======= dl: the declaration list dlres: the resulting declaration list Results: ===== DLResult: the result of the transformation ∗/ TRDeclList : Decl ∗ × TYPINGS × FUNC × TRANS × Decl ∗ → DLResult TRDeclList(dl, typings, func, trans, dlres) ≡ if dl = 〈〉 then DL_transformable(dlres) else case TRDecl(hd dl, typings, func, trans) of Decl_transformable(decl) → TRDeclList( tl dl, typings, func, trans, dlres 〈decl〉), Decl_not_transformable → DL_not_transformable end end, /∗Transforms a declaration if possible.∗/ /∗ Arguments: ======= d: the declaration Results: ===== DeclResult: the result of the transformation ∗/ TRDecl : Decl × TYPINGS × FUNC × TRANS → DeclResult 144

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER TRDecl(d, typings, func, trans) ≡ case d of TypeDecl(tdl) → case TRTypeDecl(tdl, typings, func, trans) of Transformable(decl) → Decl_transformable(decl), Not_transformable → Decl_not_transformable end, ValueDecl(vd) → case TRValueDecl(vd, typings, func, trans) of Transformable(decl) → Decl_transformable(decl), Not_transformable → Decl_not_transformable end, → Decl_not_transformable end, /∗Makes a variable declaration according to the trans map.∗/ /∗ Arguments: ======= decl: the original declaration list Results: ===== Decl_list: the resulting declaration list ∗/ makeVariables : Decl ∗ × TRANS → Decl ∗ makeVariables(decl, trans) ≡ if decl = 〈〉 then 〈VariableDecl(makeVariableDeclList(trans))〉 else case hd decl of TypeDecl(tdl) → 〈hd decl〉 makeVariables(tl decl, trans), ValueDecl(vdl) → 〈VariableDecl(makeVariableDeclList(trans))〉 decl end end, /∗Makes a variable definition list according to the trans map.∗/ /∗ 145

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

makeVariables(dlres, trans))),<br />

DL_not_transformable →<br />

Class_not_transformable<br />

end<br />

end,<br />

→ Class_not_transformable<br />

end,<br />

/∗Transforms a declaration list if possible.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

dl: the declaration list<br />

dlres: the resulting declaration list<br />

Results:<br />

=====<br />

DLResult: the result <strong>of</strong> the transformation<br />

∗/<br />

TRDeclList :<br />

Decl ∗ × TYPINGS × FUNC × TRANS × Decl ∗ →<br />

DLResult<br />

TRDeclList(dl, typings, func, trans, dlres) ≡<br />

if dl = 〈〉 then DL_transformable(dlres)<br />

else<br />

case TRDecl(hd dl, typings, func, trans) <strong>of</strong><br />

Decl_transformable(decl) →<br />

TRDeclList(<br />

tl dl, typings, func, trans,<br />

dlres 〈decl〉),<br />

Decl_not_transformable → DL_not_transformable<br />

end<br />

end,<br />

/∗Transforms a declaration if possible.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

d: the declaration<br />

Results:<br />

=====<br />

DeclResult: the result <strong>of</strong> the transformation<br />

∗/<br />

TRDecl :<br />

Decl × TYPINGS × FUNC × TRANS → DeclResult<br />

144

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

Saved successfully!

Ooh no, something went wrong!