26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

=======<br />

vel: the original value expression list<br />

etl: the corresponding list <strong>of</strong> expected types<br />

Result:<br />

=======<br />

Bool: the result<br />

∗/<br />

containsGen :<br />

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

Bool<br />

containsGen(vel, etl, trans, func) ≡<br />

if vel = 〈〉 then false<br />

else<br />

if<br />

isGen(hd vel, hd etl, trans, func) ∧<br />

∼ returnsNonTOI(hd vel, hd etl, trans, func)<br />

then true<br />

else containsGen(tl vel, tl etl, trans, func)<br />

end<br />

end,<br />

/∗Checks if a value expression is a generator.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

ve: the value expression<br />

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

Result:<br />

=======<br />

Bool: true if the value expression is a generator,<br />

false otherwise<br />

∗/<br />

isGen : ValueExpr × ExpType × TRANS × FUNC → Bool<br />

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

case ve <strong>of</strong><br />

ApplicationExpr(vea, vel) →<br />

case vea <strong>of</strong><br />

Make_ValueOrVariableName(vn) →<br />

write_list(func(id(vn))) = 〈〉,<br />

→ false<br />

end,<br />

→<br />

case et <strong>of</strong><br />

238

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

Saved successfully!

Ooh no, something went wrong!