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 b: the binding Results: ===== Text: the text of the binding ∗/ getTextBinding : Binding → Text getTextBinding(b) ≡ case b of IdBinding(id) → getText(id) end, /∗**** Bindings end ****∗/ /∗**** TRANS ****∗/ /∗Checks if the id of the expected type is in the Idset.∗/ /∗ Arguments: ======= et: the expected type of the value expression idset: the set of ids, either the domain or range of TRANS Results: ===== Bool: true if the expected type is in the idset, false otherwise ∗/ checkTRANS : ExpType × Id-set → Bool checkTRANS(et, idset) ≡ case et of Known(te) → case te of TypeName(tn) → tn ∈ idset, → false end, Unknown → false end, /∗Checks if the ids of the expected type is in the Idset.∗/ /∗ Arguments: ======= 276

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER et: the expected type of the value expression idset: the set of ids, either the domain or range of TRANS Results: ===== Bool: true if the expected type is in the idset, false otherwise ∗/ containsTRANSName : ExpType × TYPINGS × Id-set → Bool containsTRANSName(et, typings, idset) ≡ case et of Known(te) → case te of TypeLiteral(tn) → false, TypeName(tn) → tn ∈ idset ∨ (idset ∩ elems typings(tn)) = {}, TypeExprProduct(tel) → containsTRANSNameList(tel, typings, idset), TypeExprSet(tes) → case tes of FiniteSetTypeExpr(fte) → containsTRANSName( Known(fte), typings, idset), InfiniteSetTypeExpr(ite) → containsTRANSName( Known(ite), typings, idset) end, TypeExprList(tel) → case tel of FiniteListTypeExpr(fte) → containsTRANSName( Known(fte), typings, idset), InfiniteListTypeExpr(ite) → containsTRANSName( Known(ite), typings, idset) end, TypeExprMap(tem) → case tem of FiniteMapTypeExpr(tedom, terange) → containsTRANSName( Known(tedom), typings, idset) ∨ containsTRANSName( 277

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

b: the binding<br />

Results:<br />

=====<br />

Text: the text <strong>of</strong> the binding<br />

∗/<br />

getTextBinding : Binding → Text<br />

getTextBinding(b) ≡<br />

case b <strong>of</strong><br />

IdBinding(id) → getText(id)<br />

end,<br />

/∗**** Bindings end ****∗/<br />

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

/∗Checks if the id <strong>of</strong> the expected type is in<br />

the Idset.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

et: the expected type <strong>of</strong> the value expression<br />

idset: the set <strong>of</strong> ids, either the domain or range<br />

<strong>of</strong> TRANS<br />

Results:<br />

=====<br />

Bool: true if the expected type is in the idset,<br />

false otherwise<br />

∗/<br />

checkTRANS : ExpType × Id-set → Bool<br />

checkTRANS(et, idset) ≡<br />

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

Known(te) →<br />

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

TypeName(tn) → tn ∈ idset,<br />

→ false<br />

end,<br />

Unknown → false<br />

end,<br />

/∗Checks if the ids <strong>of</strong> the expected type is in<br />

the Idset.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

276

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

Saved successfully!

Ooh no, something went wrong!