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 (fve ′ , types ′ ) = TRValueExpr(fve, et, func, trans, types), (sve ′ , types ′′ ) = TRValueExpr(sve, et, func, trans, types ′ ) in (RangedListExpr(fve ′ , sve ′ ), types ′′ ) end, EnumeratedListExpr(ovel) → let (ovel ′ , types ′ ) = TROptValueExprList( ovel, et, func, trans, types) in (EnumeratedListExpr(ovel ′ ), types ′ ) end, ComprehendedListExpr(ve1, b, ve2, or) → let (ve1 ′ , types1) = TRValueExpr(ve1, et, func, trans, types), (ve2 ′ , types2) = TRValueExpr(ve2, et, func, trans, types1), (or ′ , types3) = TROptRestriction( or, Known(TypeLiteral(BOOL)), func, trans, types2) in (ComprehendedListExpr(ve1 ′ , b, ve2 ′ , or ′ ), types3) end end, /∗Transforms a map expression.∗/ /∗ Arguments: ======= me: the map expression et: the expected type the components of the map expression Result: ======= MapExpr: the imperative version of the map expression ∗/ TRMapExpr : MapExpr × MapType × FUNC × TRANS × TYPES → 202

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER MapExpr × TYPES TRMapExpr(me, et, func, trans, types) ≡ case me of EnumeratedMapExpr(ovel) → let (ovel ′ , types ′ ) = TROptValueExprPairList( ovel, et, func, trans, types) in (EnumeratedMapExpr(ovel ′ ), types ′ ) end, ComprehendedMapExpr(ve, typlist, or) → let (vedom, types1) = TRValueExpr( first(ve), tedom(et), func, trans, types), (verange, types2) = TRValueExpr( second(ve), terange(et), func, trans, types1), (or ′ , types3) = TROptRestriction( or, Known(TypeLiteral(BOOL)), func, trans, types2) in (ComprehendedMapExpr( mk_ValueExprPair(vedom, verange), typlist, or ′ ), types3) end end, /∗Transforms an optional value expression list. ∗/ /∗ Arguments: ======= ovel: the optional value expression list et: the expected type the components of the set expression Result: ======= OptionalValueExprList: the imperative version of the optional value expression list ∗/ 203

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

(fve ′ , types ′ ) =<br />

TRValueExpr(fve, et, func, trans, types),<br />

(sve ′ , types ′′ ) =<br />

TRValueExpr(sve, et, func, trans, types ′ )<br />

in<br />

(RangedListExpr(fve ′ , sve ′ ), types ′′ )<br />

end,<br />

EnumeratedListExpr(ovel) →<br />

let<br />

(ovel ′ , types ′ ) =<br />

TROptValueExprList(<br />

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

in<br />

(EnumeratedListExpr(ovel ′ ), types ′ )<br />

end,<br />

ComprehendedListExpr(ve1, b, ve2, or) →<br />

let<br />

(ve1 ′ , types1) =<br />

TRValueExpr(ve1, et, func, trans, types),<br />

(ve2 ′ , types2) =<br />

TRValueExpr(ve2, et, func, trans, types1),<br />

(or ′ , types3) =<br />

TROptRestriction(<br />

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

trans, types2)<br />

in<br />

(ComprehendedListExpr(ve1 ′ , b, ve2 ′ , or ′ ),<br />

types3)<br />

end<br />

end,<br />

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

/∗<br />

Arguments:<br />

=======<br />

me: the map expression<br />

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

expression<br />

Result:<br />

=======<br />

MapExpr: the imperative version <strong>of</strong> the map expression<br />

∗/<br />

TRMapExpr :<br />

MapExpr × MapType × FUNC × TRANS × TYPES →<br />

202

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

Saved successfully!

Ooh no, something went wrong!