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, /∗Gets an id list to the TYPINGS map from a name or wildcard.∗/ /∗ Arguments: ======= nw: the name or wildcard Results: ===== Id_list: the resulting list of ids ∗/ getTYPINGSNameWildcard : NameOrWildcard → Id ∗ getTYPINGSNameWildcard(nw) ≡ case nw of Name(var) → 〈id(var)〉, Wildcard → 〈〉 end, /∗Gets an id list to the TYPINGS map from a type expr.∗/ /∗ Arguments: ======= te: the type expression Results: ===== Id_list: the resulting list of ids ∗/ getTYPINGSTypeExpr : TypeExpr → Id ∗ getTYPINGSTypeExpr(te) ≡ case te of TypeLiteral(tn) → 〈〉, TypeName(id) → 〈id〉, TypeExprProduct(tep) → getTYPINGSTypeExprList(tep), TypeExprSet(tes) → case tes of FiniteSetTypeExpr(fse) → getTYPINGSTypeExpr(fse), InfiniteSetTypeExpr(ise) → getTYPINGSTypeExpr(ise) end, TypeExprList(les) → 284

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER case les of FiniteListTypeExpr(fle) → getTYPINGSTypeExpr(fle), InfiniteListTypeExpr(ile) → getTYPINGSTypeExpr(ile) end, TypeExprMap(tem) → case tem of FiniteMapTypeExpr(tedom, terange) → removeDupletsId( getTYPINGSTypeExpr(tedom) getTYPINGSTypeExpr(terange)), InfiniteMapTypeExpr(tedom, terange) → removeDupletsId( getTYPINGSTypeExpr(tedom) getTYPINGSTypeExpr(terange)) end, FunctionTypeExpr(arg, fa, res) → removeDupletsId( getTYPINGSTypeExpr(arg) getTYPINGSTypeExpr(type_expr(res))), SubtypeExpr(st, ve) → getTYPINGSTypeExpr(type_expr(st)), BracketedTypeExpr(bte) → getTYPINGSTypeExpr(bte) end, /∗Gets an id list to the TYPINGS map from a type expression list.∗/ /∗ Arguments: ======= tel: the type expression list Results: ===== Id_list: the resulting list of ids ∗/ getTYPINGSTypeExprList : TypeExpr ∗ → Id ∗ getTYPINGSTypeExprList(tel) ≡ if tel = 〈〉 then 〈〉 else removeDupletsId( getTYPINGSTypeExpr(hd tel) getTYPINGSTypeExprList(tl tel)) end, 285

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

case les <strong>of</strong><br />

FiniteListTypeExpr(fle) →<br />

getTYPINGSTypeExpr(fle),<br />

InfiniteListTypeExpr(ile) →<br />

getTYPINGSTypeExpr(ile)<br />

end,<br />

TypeExprMap(tem) →<br />

case tem <strong>of</strong><br />

FiniteMapTypeExpr(tedom, terange) →<br />

removeDupletsId(<br />

getTYPINGSTypeExpr(tedom) <br />

getTYPINGSTypeExpr(terange)),<br />

InfiniteMapTypeExpr(tedom, terange) →<br />

removeDupletsId(<br />

getTYPINGSTypeExpr(tedom) <br />

getTYPINGSTypeExpr(terange))<br />

end,<br />

FunctionTypeExpr(arg, fa, res) →<br />

removeDupletsId(<br />

getTYPINGSTypeExpr(arg) <br />

getTYPINGSTypeExpr(type_expr(res))),<br />

SubtypeExpr(st, ve) →<br />

getTYPINGSTypeExpr(type_expr(st)),<br />

BracketedTypeExpr(bte) → getTYPINGSTypeExpr(bte)<br />

end,<br />

/∗Gets an id list to the TYPINGS map from a type<br />

expression list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

tel: the type expression list<br />

Results:<br />

=====<br />

Id_list: the resulting list <strong>of</strong> ids<br />

∗/<br />

getTYPINGSTypeExprList : TypeExpr ∗ → Id ∗<br />

getTYPINGSTypeExprList(tel) ≡<br />

if tel = 〈〉 then 〈〉<br />

else<br />

removeDupletsId(<br />

getTYPINGSTypeExpr(hd tel) <br />

getTYPINGSTypeExprList(tl tel))<br />

end,<br />

285

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

Saved successfully!

Ooh no, something went wrong!