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 /∗**** ExpType end ****∗/ /∗**** ValueExpr ****∗/ /∗Turns a value expression list into a value expression. ∗/ /∗ Arguments: ======= vel: the value expression list Result: ======= ValueExpr: the resulting value expression ∗/ toValueExpr : ValueExpr ∗ → ValueExpr toValueExpr(vel) ≡ if len vel = 1 then hd vel else ProductExpr(vel) end, /∗Removes proper Tgenerators from a value expression list.∗/ /∗ Arguments: ======= vel: the value expression list etl: the corresponding list of expected types vl: the value expression list which is shortened Results: ===== ValueExpr_list: the corresponding value expression list ∗/ makeValueExprList : ValueExpr ∗ × ExpType ∗ × ValueExpr ∗ × TRANS × FUNC → ValueExpr ∗ makeValueExprList(vel, etl, vl, trans, func) ≡ if vel = 〈〉 then 〈〉 else if isGen(hd vel, hd etl, trans, func) ∧ ∼ returnsNonTOI(hd vel, hd etl, trans, func) then makeValueExprList( tl vel, tl etl, tl vl, trans, func) 236

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER else 〈hd vl〉 makeValueExprList( tl vel, tl etl, tl vl, trans, func) end end, /∗Establishes sequencing expression when appropriate. ∗/ /∗ Arguments: ======= ve: the value expression te: the type of the value expression et: the expected type of the value expression Results: ===== ValueExpr: the resulting value expression list ∗/ makeSequencingExpr : ValueExpr × TypeExpr × ExpType × TRANS × FUNC → ValueExpr makeSequencingExpr(ve, te, et, trans, func) ≡ if isGen(ve, et, trans, func) ∧ ∼ returnsNonTOI(ve, et, trans, func) ∧ ∼ equalsType(te, et) then BracketedExpr( SequencingExpr( ve, toValueExpr(getTOIReturnsList(te, trans)))) else ve end, /∗**** ValueExpr end ****∗/ /∗**** Generators and observers ****∗/ /∗Returns true if the value expression list contains generators, false otherwise. ∗/ /∗ Arguments: 237

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

else<br />

〈hd vl〉 <br />

makeValueExprList(<br />

tl vel, tl etl, tl vl, trans, func)<br />

end<br />

end,<br />

/∗Establishes sequencing expression when appropriate.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

ve: the value expression<br />

te: the type <strong>of</strong> the value expression<br />

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

Results:<br />

=====<br />

ValueExpr: the resulting value expression list<br />

∗/<br />

makeSequencingExpr :<br />

ValueExpr × TypeExpr × ExpType × TRANS × FUNC →<br />

ValueExpr<br />

makeSequencingExpr(ve, te, et, trans, func) ≡<br />

if<br />

isGen(ve, et, trans, func) ∧<br />

∼ returnsNonTOI(ve, et, trans, func) ∧<br />

∼ equalsType(te, et)<br />

then<br />

BracketedExpr(<br />

SequencingExpr(<br />

ve,<br />

toValueExpr(getTOIReturnsList(te, trans))))<br />

else ve<br />

end,<br />

/∗**** ValueExpr end ****∗/<br />

/∗**** Generators and observers ****∗/<br />

/∗Returns true if the value expression list contains<br />

generators, false otherwise.<br />

∗/<br />

/∗<br />

Arguments:<br />

237

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

Saved successfully!

Ooh no, something went wrong!