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 Make_ProductBinding(pb) → let (b, ffpl ′ , env ′ , types ′ , prlet ′ ) = TRFormalFuncParam( mk_FormalFunctionParameter( binding_list(pb)), hd tel, trans, env, types, prlet), (b1, ffpl ′′ , env ′′ , types ′′ , prlet ′′ ) = TRFFPProduct( mk_FormalFunctionParameter( tl binding_list(ffpl)), tl tel, trans, env ′ , types ′ , prlet ′ ) in if binding_list(ffpl ′ ) = 〈〉 then (b ∧ b1, mk_FormalFunctionParameter( binding_list(ffpl ′′ )), env ′′ , types ′′ , prlet ′′ ) else if len binding_list(ffpl ′ ) = 1 then (b ∧ b1, mk_FormalFunctionParameter( binding_list(ffpl ′ ) binding_list(ffpl ′′ )), env ′′ , types ′′ , prlet ′′ ) else (b ∧ b1, mk_FormalFunctionParameter( 〈Make_ProductBinding( mk_ProductBinding( binding_list(ffpl ′ )))〉 binding_list(ffpl ′′ )), env ′′ , types ′′ , prlet ′′ ) end end end, → let (b, ffpl ′ , env ′ , types ′ , prlet ′ ) = TRFormalFuncParam( mk_FormalFunctionParameter( 〈hd binding_list(ffpl)〉), hd tel, 192

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER end end, trans, env, types, prlet), (b1, ffpl ′′ , env ′′ , types ′′ , prlet ′′ ) = TRFFPProduct( mk_FormalFunctionParameter( tl binding_list(ffpl)), tl tel, trans, env ′ , types ′ , prlet ′ ) in (b ∧ b1, mk_FormalFunctionParameter( binding_list(ffpl ′ ) binding_list(ffpl ′′ )), env ′′ , types ′′ , prlet ′′ ) end /∗Checks if it is necessary to establish a let expression.∗/ /∗ Arguments: ======= te: the type of the binding b: the actual binding prlet: the original value of the LetDef_list Result: ======= LetDef_list: the resulting value of the LetDef_ list ∗/ makeProductLet : TypeExpr × Binding × LetDef ∗ × TRANS → LetDef ∗ makeProductLet(te, b, prlet, trans) ≡ case te of TypeName(tn) → case b of Make_ProductBinding(pb) → prlet 〈mk_LetDef( MakeBinding(b), Make_ValueOrVariableName( mk_ValueOrVariableName(trans(tn))))〉, → prlet end 193

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

Make_ProductBinding(pb) →<br />

let<br />

(b, ffpl ′ , env ′ , types ′ , prlet ′ ) =<br />

TRFormalFuncParam(<br />

mk_FormalFunctionParameter(<br />

binding_list(pb)), hd tel, trans,<br />

env, types, prlet),<br />

(b1, ffpl ′′ , env ′′ , types ′′ , prlet ′′ ) =<br />

TRFFPProduct(<br />

mk_FormalFunctionParameter(<br />

tl binding_list(ffpl)), tl tel,<br />

trans, env ′ , types ′ , prlet ′ )<br />

in<br />

if binding_list(ffpl ′ ) = 〈〉<br />

then<br />

(b ∧ b1,<br />

mk_FormalFunctionParameter(<br />

binding_list(ffpl ′′ )), env ′′ , types ′′ ,<br />

prlet ′′ )<br />

else<br />

if len binding_list(ffpl ′ ) = 1<br />

then<br />

(b ∧ b1,<br />

mk_FormalFunctionParameter(<br />

binding_list(ffpl ′ ) <br />

binding_list(ffpl ′′ )), env ′′ ,<br />

types ′′ , prlet ′′ )<br />

else<br />

(b ∧ b1,<br />

mk_FormalFunctionParameter(<br />

〈Make_ProductBinding(<br />

mk_ProductBinding(<br />

binding_list(ffpl ′ )))〉 <br />

binding_list(ffpl ′′ )), env ′′ ,<br />

types ′′ , prlet ′′ )<br />

end<br />

end<br />

end,<br />

→<br />

let<br />

(b, ffpl ′ , env ′ , types ′ , prlet ′ ) =<br />

TRFormalFuncParam(<br />

mk_FormalFunctionParameter(<br />

〈hd binding_list(ffpl)〉), hd tel,<br />

192

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

Saved successfully!

Ooh no, something went wrong!