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 end, end end end /∗Transforms a single typing.∗/ /∗ Arguments: ======= st: the single typing Result: ======= ValueDef: the resulting imperative version of the single typing ∗/ TRSingleTyping : SingleTyping × FUNC × TRANS → SingleTyping TRSingleTyping(st, func, trans) ≡ case binding(st) of IdBinding(id) → mk_SingleTyping( binding(st), TRTypeExpr(id, type_expr(st), func, trans)) end, /∗Transforms a type expression.∗/ /∗ Arguments: ======= id: the id of the corresponding function te: the type expression Result: ======= TypeExpr: the resulting imperative version of the type expression ∗/ TRTypeExpr : Id × TypeExpr × FUNC × TRANS → TypeExpr TRTypeExpr(id, te, func, trans) ≡ case te of TypeLiteral(literal) → te, TypeName(tid) → if (tid ∈ dom trans) then 186

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER /∗Type expression of a type of interest.∗/ TypeLiteral(UNIT) else /∗Type expression not of a type of interest.∗/ te end, TypeExprProduct(tel) → TypeExprProduct( TRTypeExprList(id, tel, func, trans)), TypeExprSet(tes) → te, TypeExprList(tel) → te, TypeExprMap(tem) → te, FunctionTypeExpr(fte, fa, rd) → TRFunctionDef(id, fte, fa, rd, func, trans), BracketedTypeExpr(bte) → BracketedTypeExpr( TRTypeExpr(id, bte, func, trans)) end, /∗Transforms a type expression list.∗/ /∗ Arguments: ======= id: the id of the corresponding function tel: the type expression list Result: ======= TypeExpr_list: the resulting imperative version of the type expression list ∗/ TRTypeExprList : Id × TypeExpr ∗ × FUNC × TRANS → TypeExpr ∗ TRTypeExprList(id, tel, func, trans) ≡ if tel = 〈〉 then 〈〉 else 〈TRTypeExpr(id, hd tel, func, trans)〉 TRTypeExprList(id, tl tel, func, trans) end, /∗Transforms a function definition.∗/ /∗ Arguments: ======= id: the id of the corresponding function 187

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

end,<br />

end<br />

end<br />

end<br />

/∗Transforms a single typing.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

st: the single typing<br />

Result:<br />

=======<br />

ValueDef: the resulting imperative version <strong>of</strong><br />

the single typing<br />

∗/<br />

TRSingleTyping :<br />

SingleTyping × FUNC × TRANS → SingleTyping<br />

TRSingleTyping(st, func, trans) ≡<br />

case binding(st) <strong>of</strong><br />

IdBinding(id) →<br />

mk_SingleTyping(<br />

binding(st),<br />

TRTypeExpr(id, type_expr(st), func, trans))<br />

end,<br />

/∗Transforms a type expression.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

id: the id <strong>of</strong> the corresponding function<br />

te: the type expression<br />

Result:<br />

=======<br />

TypeExpr: the resulting imperative version <strong>of</strong><br />

the type expression<br />

∗/<br />

TRTypeExpr :<br />

Id × TypeExpr × FUNC × TRANS → TypeExpr<br />

TRTypeExpr(id, te, func, trans) ≡<br />

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

TypeLiteral(literal) → te,<br />

TypeName(tid) →<br />

if (tid ∈ dom trans)<br />

then<br />

186

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

Saved successfully!

Ooh no, something went wrong!