Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS end, /∗Returns the length of a let binding.∗/ /∗ Arguments: ======= lb: the let binding Results: ======= Int: the length of the let binding ∗/ getLengthLetBinding : LetBinding → Int getLengthLetBinding(lb) ≡ case lb of MakeBinding(b) → getLengthBinding(b), MakeRecordPattern(vn, p) → 1, MakeListPatternLet(lp) → 1 end, /∗Returns the length of a binding.∗/ /∗ Arguments: ======= b: the binding Results: ======= Int: the length of the binding ∗/ getLengthBinding : Binding → Int getLengthBinding(b) ≡ case b of IdBinding(id) → 1, Make_ProductBinding(pb) → getLengthBindingList(binding_list(pb)) end, /∗Returns the number of parameters of a binding list.∗/ /∗ Arguments: ======= bl: the binding list Results: ===== 274
C.1. FORMAL SPECIFICATION OF THE TRANSFORMER Int: the number of parameters ∗/ getLengthBindingList : Binding ∗ → Int getLengthBindingList(bl) ≡ if bl = 〈〉 then 0 else case hd bl of IdBinding(id) → 1 + getLengthBindingList(tl bl), Make_ProductBinding(pb) → getLengthBindingList(binding_list(pb)) + getLengthBindingList(tl bl) end end, /∗Checks if a binding is in a binding set.∗/ /∗ Arguments: ======= b: the binding bl: the binding set Results: ===== Bool: true if the binding is in the binding set, false otherwise ∗/ isinBinding : Binding × Binding-set → Bool isinBinding(b, bl) ≡ if bl = {} then false else case hd bl of IdBinding(id) → if getText(id) = getTextBinding(b) then true else isinBinding(b, bl \ {hd bl}) end, Make_ProductBinding(pb) → isinBinding(b, elems binding_list(pb)) ∨ isinBinding(b, bl \ {hd bl}) end end, /∗Returns the text of an id binding.∗/ /∗ Arguments: ======= 275
- Page 240 and 241: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 242 and 243: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 244 and 245: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 246 and 247: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 248 and 249: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 250 and 251: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 252 and 253: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 254 and 255: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 256 and 257: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 258 and 259: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 260 and 261: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 262 and 263: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 264 and 265: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 266 and 267: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 268 and 269: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 270 and 271: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 272 and 273: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 274 and 275: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 276 and 277: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 278 and 279: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 280 and 281: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 282 and 283: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 284 and 285: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 286 and 287: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 288 and 289: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 292 and 293: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 294 and 295: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 296 and 297: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 298 and 299: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 300 and 301: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 302 and 303: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 304 and 305: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 306 and 307: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 308 and 309: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 310 and 311: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 312 and 313: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 314 and 315: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 316 and 317: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 318 and 319: APPENDIX D. SPECIFICATION OF TRANSF
- Page 320 and 321: APPENDIX D. SPECIFICATION OF TRANSF
- Page 322 and 323: APPENDIX D. SPECIFICATION OF TRANSF
- Page 324 and 325: APPENDIX D. SPECIFICATION OF TRANSF
- Page 326 and 327: APPENDIX D. SPECIFICATION OF TRANSF
- Page 328 and 329: APPENDIX D. SPECIFICATION OF TRANSF
- Page 330 and 331: APPENDIX D. SPECIFICATION OF TRANSF
- Page 332 and 333: APPENDIX D. SPECIFICATION OF TRANSF
- Page 334 and 335: APPENDIX D. SPECIFICATION OF TRANSF
- Page 336 and 337: APPENDIX D. SPECIFICATION OF TRANSF
- Page 338 and 339: APPENDIX D. SPECIFICATION OF TRANSF
C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />
Int: the number <strong>of</strong> parameters<br />
∗/<br />
getLengthBindingList : Binding ∗ → Int<br />
getLengthBindingList(bl) ≡<br />
if bl = 〈〉 then 0<br />
else<br />
case hd bl <strong>of</strong><br />
IdBinding(id) → 1 + getLengthBindingList(tl bl),<br />
Make_ProductBinding(pb) →<br />
getLengthBindingList(binding_list(pb)) +<br />
getLengthBindingList(tl bl)<br />
end<br />
end,<br />
/∗Checks if a binding is in a binding set.∗/<br />
/∗<br />
Arguments:<br />
=======<br />
b: the binding<br />
bl: the binding set<br />
Results:<br />
=====<br />
Bool: true if the binding is in the binding set,<br />
false otherwise<br />
∗/<br />
isinBinding : Binding × Binding-set → Bool<br />
isinBinding(b, bl) ≡<br />
if bl = {} then false<br />
else<br />
case hd bl <strong>of</strong><br />
IdBinding(id) →<br />
if getText(id) = getTextBinding(b) then true<br />
else isinBinding(b, bl \ {hd bl})<br />
end,<br />
Make_ProductBinding(pb) →<br />
isinBinding(b, elems binding_list(pb)) ∨<br />
isinBinding(b, bl \ {hd bl})<br />
end<br />
end,<br />
/∗Returns the text <strong>of</strong> an id binding.∗/<br />
/∗<br />
Arguments:<br />
=======<br />
275