Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1 end end, CheckOptRestriction : OptionalRestriction × ExpType × TYPINGS × FUNC × TRANS × ENV × TYPES → BOOL_ENV_TYPES CheckOptRestriction( optr, et, typings, func, trans, env, types) ≡ case optr of Restriction(ve) → CheckValueExpr( ve, et, typings, func, trans, env, types), NoRestriction → mk_BOOL_ENV_TYPES(true, env, types) end, CheckApplicationExpr : ValueExpr × ValueExpr ∗ × ExpType × TYPINGS × FUNC × TRANS × ENV × TYPES → BOOL_ENV_TYPES CheckApplicationExpr( ve, vel, et, typings, func, trans, env, types) ≡ case ve of Make_ValueOrVariableName(vn) → if isinId(id(vn), domainFUNC(func)) then /∗The application expression is a function application. ∗/ case type_expr(getMapValueFUNC(func, id(vn))) of FunctionTypeExpr(arg, fa, res) → CheckFunctionAppl( ve, vel, typeExprToExpTypeList(arg), typings, func, trans, env, types) end else /∗The application expression is a list or map application.∗/ CheckListMapAppl( ve, vel, et, typings, func, trans, env, types) end, 338

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1 end, → CheckListMapAppl( ve, vel, et, typings, func, trans, env, types) CheckFunctionAppl : ValueExpr × ValueExpr ∗ × ExpType ∗ × TYPINGS × FUNC × TRANS × ENV × TYPES → BOOL_ENV_TYPES CheckFunctionAppl( ve, vel, etl, typings, func, trans, env, types) ≡ case ve of Make_ValueOrVariableName(vn) → mk_BOOL_ENV_TYPES( and( bool( CheckValueExprList( vel, etl, typings, func, trans, env, types)), greaterEqual( lengthVE(vel), lengthET(etl), 0)), setEnv( write_list(getMapValueFUNC(func, id(vn))), envMap( CheckValueExprList( vel, etl, typings, func, trans, env, types))), typesMap( CheckValueExprList( vel, etl, typings, func, trans, env, types))) end, CheckListMapAppl : ValueExpr × ValueExpr ∗ × ExpType × TYPINGS × FUNC × TRANS × ENV × TYPES → BOOL_ENV_TYPES CheckListMapAppl( ve, vel, et, typings, func, trans, env, types) ≡ case ve of Make_ValueOrVariableName(vn) → if checkTRANS( getMapValueTYPES(types, IdBinding(id(vn))), 339

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1<br />

end<br />

end,<br />

CheckOptRestriction :<br />

OptionalRestriction × ExpType × TYPINGS × FUNC ×<br />

TRANS × ENV × TYPES →<br />

BOOL_ENV_TYPES<br />

CheckOptRestriction(<br />

optr, et, typings, func, trans, env, types) ≡<br />

case optr <strong>of</strong><br />

Restriction(ve) →<br />

CheckValueExpr(<br />

ve, et, typings, func, trans, env, types),<br />

NoRestriction →<br />

mk_BOOL_ENV_TYPES(true, env, types)<br />

end,<br />

CheckApplicationExpr :<br />

ValueExpr × ValueExpr ∗ × ExpType × TYPINGS ×<br />

FUNC × TRANS × ENV × TYPES →<br />

BOOL_ENV_TYPES<br />

CheckApplicationExpr(<br />

ve, vel, et, typings, func, trans, env, types) ≡<br />

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

Make_ValueOrVariableName(vn) →<br />

if isinId(id(vn), domainFUNC(func))<br />

then<br />

/∗The application expression is a function application.<br />

∗/<br />

case<br />

type_expr(getMapValueFUNC(func, id(vn)))<br />

<strong>of</strong><br />

FunctionTypeExpr(arg, fa, res) →<br />

CheckFunctionAppl(<br />

ve, vel, typeExprToExpTypeList(arg),<br />

typings, func, trans, env, types)<br />

end<br />

else<br />

/∗The application expression is a list or map<br />

application.∗/<br />

CheckListMapAppl(<br />

ve, vel, et, typings, func, trans, env,<br />

types)<br />

end,<br />

338

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

Saved successfully!

Ooh no, something went wrong!