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 for transformability of a map expression. ∗/ /∗ Arguments: ======= me: the map expression et: the expected type of the components of the map expression Results: ===== Bool: true if the map expression is transformable, false otherwise ∗/ CheckMapExpr : MapExpr × MapType × TYPINGS × FUNC × TRANS × ENV × TYPES → Bool × ENV × TYPES CheckMapExpr(me, et, typings, func, trans, env, types) ≡ case me of EnumeratedMapExpr(ovel) → CheckOptValueExprPairList( ovel, et, typings, func, trans, env, types), ComprehendedMapExpr(vep, typlist, or) → let (b1, env1, types1) = CheckValueExprList( 〈first(vep), second(vep)〉, 〈tedom(et), terange(et)〉, typings, func, trans, env, types), (b2, env2, types2) = CheckOptRestriction( or, Known(TypeLiteral(BOOL)), typings, func, trans, env1, types1) in (b1 ∧ b2, env2, types2) end end, /∗Checks for transformability of an optional value expression list.∗/ /∗ Arguments: ======= 168

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER ovel: the optional value expression list et: the expected type of the components of the value expression list Results: ===== Bool: true if the optional value expression list is transformable, false otherwise ∗/ CheckOptValueExprList : OptionalValueExprList × ExpType × TYPINGS × FUNC × TRANS × ENV × TYPES → Bool × ENV × TYPES CheckOptValueExprList( ovel, et, typings, func, trans, env, types) ≡ case ovel of ValueExprList(vel) → CheckValueExprList( vel, toExpTypeList(et, len vel), typings, func, trans, env, types), NoValueExprList → (true, env, types) end, /∗Checks for transformability of an optional value expression pair list.∗/ /∗ Arguments: ======= ovel: the optional value expression pair list et: the expected type of the components of the value expression pair list Results: ===== Bool: true if the optional value expression pair list is transformable, false otherwise ∗/ CheckOptValueExprPairList : OptionalValueExprPairList × MapType × TYPINGS × FUNC × TRANS × ENV × TYPES → Bool × ENV × TYPES CheckOptValueExprPairList( ovel, et, typings, func, trans, env, types) ≡ case ovel of ValueExprPairList(vel) → CheckValueExprPairList( 169

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

/∗Checks for transformability <strong>of</strong> a map expression.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

me: the map expression<br />

et: the expected type <strong>of</strong> the components <strong>of</strong> the<br />

map expression<br />

Results:<br />

=====<br />

Bool: true if the map expression is transformable,<br />

false otherwise<br />

∗/<br />

CheckMapExpr :<br />

MapExpr × MapType × TYPINGS × FUNC × TRANS ×<br />

ENV × TYPES →<br />

Bool × ENV × TYPES<br />

CheckMapExpr(me, et, typings, func, trans, env, types) ≡<br />

case me <strong>of</strong><br />

EnumeratedMapExpr(ovel) →<br />

CheckOptValueExprPairList(<br />

ovel, et, typings, func, trans, env, types),<br />

ComprehendedMapExpr(vep, typlist, or) →<br />

let<br />

(b1, env1, types1) =<br />

CheckValueExprList(<br />

〈first(vep), second(vep)〉,<br />

〈tedom(et), terange(et)〉, typings,<br />

func, trans, env, types),<br />

(b2, env2, types2) =<br />

CheckOptRestriction(<br />

or, Known(TypeLiteral(BOOL)), typings,<br />

func, trans, env1, types1)<br />

in<br />

(b1 ∧ b2, env2, types2)<br />

end<br />

end,<br />

/∗Checks for transformability <strong>of</strong> an optional value<br />

expression list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

168

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

Saved successfully!

Ooh no, something went wrong!