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.

CHAPTER 8. SPECIFICATIONS<br />

constructs <strong>into</strong> corresponding imperative constructs according to the transformation<br />

rules given in Chapter 6. An interesting example <strong>of</strong> this can be<br />

seen in Specification 8.2, which shows some parts <strong>of</strong> the main function TR-<br />

ValueExpr for transforming value expressions.<br />

Specification 8.2 – <strong>Transformation</strong> <strong>of</strong> a value expression<br />

TRValueExpr :<br />

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

ValueExpr × TYPES<br />

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

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

Make_ValueLiteral(vl) →<br />

(makeAssignExpr(ve, et, trans), types),<br />

Make_ValueOrVariableName(vn) →<br />

if ∼ isinBinding(IdBinding(id(vn)), dom types)<br />

then<br />

if id(vn) ∈ dom func<br />

then /∗Constant <strong>of</strong> the type <strong>of</strong> interest.∗/<br />

TRValueExpr(<br />

ApplicationExpr(ve, 〈〉), et, func,<br />

trans, types)<br />

else (ve, types)<br />

end<br />

else<br />

if<br />

checkTRANS(<br />

types(IdBinding(id(vn))), dom trans)<br />

then<br />

/∗The value expression is <strong>of</strong> a type <strong>of</strong> interest.<br />

∗/<br />

(makeAssignExpr(<br />

getTRANS(types(IdBinding(id(vn))), trans),<br />

et, trans), types)<br />

else<br />

/∗The value expression is not <strong>of</strong> a type <strong>of</strong> interest.<br />

∗/<br />

(makeAssignExpr(ve, et, trans), types)<br />

end<br />

end,<br />

.<br />

ValueInfixExpr(first, op, second) →<br />

80

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

Saved successfully!

Ooh no, something went wrong!