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 in (LetExpr(ldl, ve ′ ), types ′′ ) end, Make_IfExpr(ie) → TRIfExpr(ie, et, func, trans, types), CaseExpr(cond, cbl) → let (cond ′ , types ′ ) = TRValueExpr( cond, Unknown, func, trans, types), (cbl ′ , types ′′ ) = TRCaseBranchList( cbl, et, func, trans, types ′ ) in (CaseExpr(cond ′ , cbl ′ ), types ′′ ) end end, /∗Transforms a value expression list.∗/ /∗ Arguments: ======= vel: the value expression list et: the expected type of the value expression list Result: ======= ValueExpr_list: the imperative version of the value expression list ∗/ TRValueExprList : ValueExpr ∗ × ExpType × FUNC × TRANS × TYPES → ValueExpr ∗ × TYPES TRValueExprList(vel, et, func, trans, types) ≡ if vel = 〈〉 then (〈〉, types) else let (ve, types ′ ) = TRValueExpr( hd vel, getHead(et), func, trans, types), (vel ′ , types ′′ ) = TRValueExprList( tl vel, getTail(et), func, trans, types ′ ) in 198

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER (〈ve〉 vel ′ , types ′′ ) end end, /∗Transforms a value expression list of a product expression or function application.∗/ /∗ Arguments: ======= vel: the value expression list et: the expected type of the value expression list Result: ======= ValueExpr_list: the imperative version of the value expression list ∗/ TRValueExprListProductFunc : ValueExpr ∗ × ExpType ∗ × FUNC × TRANS × TYPES → ValueExpr ∗ × TYPES TRValueExprListProductFunc( vel, etl, func, trans, types) ≡ if vel = 〈〉 then (〈〉, types) else let (ve, types ′ ) = TRValueExpr(hd vel, hd etl, func, trans, types), (vel ′ , types ′′ ) = TRValueExprListProductFunc( tl vel, tl etl, func, trans, types ′ ) in (〈ve〉 vel ′ , types ′′ ) end end, /∗Transforms a product expression.∗/ /∗ Arguments: ======= vel: the value expression etl: the expected types of the value expression in the list et: the expected type of the product expression 199

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

in<br />

(LetExpr(ldl, ve ′ ), types ′′ )<br />

end,<br />

Make_IfExpr(ie) →<br />

TRIfExpr(ie, et, func, trans, types),<br />

CaseExpr(cond, cbl) →<br />

let<br />

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

TRValueExpr(<br />

cond, Unknown, func, trans, types),<br />

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

TRCaseBranchList(<br />

cbl, et, func, trans, types ′ )<br />

in<br />

(CaseExpr(cond ′ , cbl ′ ), types ′′ )<br />

end<br />

end,<br />

/∗Transforms a value expression list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

vel: the value expression list<br />

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

list<br />

Result:<br />

=======<br />

ValueExpr_list: the imperative version <strong>of</strong> the<br />

value expression list<br />

∗/<br />

TRValueExprList :<br />

ValueExpr ∗ × ExpType × FUNC × TRANS × TYPES →<br />

ValueExpr ∗ × TYPES<br />

TRValueExprList(vel, et, func, trans, types) ≡<br />

if vel = 〈〉 then (〈〉, types)<br />

else<br />

let<br />

(ve, types ′ ) =<br />

TRValueExpr(<br />

hd vel, getHead(et), func, trans, types),<br />

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

TRValueExprList(<br />

tl vel, getTail(et), func, trans, types ′ )<br />

in<br />

198

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

Saved successfully!

Ooh no, something went wrong!