annotate src/source_print.sml @ 625:47947d6e9750

Turned off termination checking, for now
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Feb 2009 16:33:55 -0500
parents 588b9d16b00a
children 12b73f3c108e
rev   line source
adamc@1 1 (* Copyright (c) 2008, Adam Chlipala
adamc@1 2 * All rights reserved.
adamc@1 3 *
adamc@1 4 * Redistribution and use in source and binary forms, with or without
adamc@1 5 * modification, are permitted provided that the following conditions are met:
adamc@1 6 *
adamc@1 7 * - Redistributions of source code must retain the above copyright notice,
adamc@1 8 * this list of conditions and the following disclaimer.
adamc@1 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@1 10 * this list of conditions and the following disclaimer in the documentation
adamc@1 11 * and/or other materials provided with the distribution.
adamc@1 12 * - The names of contributors may not be used to endorse or promote products
adamc@1 13 * derived from this software without specific prior written permission.
adamc@1 14 *
adamc@1 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@1 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@1 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@1 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@1 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@1 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@1 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@1 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@1 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@1 26 *)
adamc@1 27
adamc@244 28 (* Pretty-printing Ur/Web *)
adamc@1 29
adamc@4 30 structure SourcePrint :> SOURCE_PRINT = struct
adamc@1 31
adamc@1 32 open Print.PD
adamc@1 33 open Print
adamc@1 34
adamc@4 35 open Source
adamc@1 36
adamc@1 37 fun p_kind' par (k, _) =
adamc@1 38 case k of
adamc@1 39 KType => string "Type"
adamc@1 40 | KArrow (k1, k2) => parenIf par (box [p_kind' true k1,
adamc@1 41 space,
adamc@1 42 string "->",
adamc@1 43 space,
adamc@1 44 p_kind k2])
adamc@1 45 | KName => string "Name"
adamc@1 46 | KRecord k => box [string "{", p_kind k, string "}"]
adamc@82 47 | KUnit => string "Unit"
adamc@18 48 | KWild => string "_"
adamc@207 49 | KTuple ks => box [string "(",
adamc@207 50 p_list_sep (box [space, string "*", space]) p_kind ks,
adamc@207 51 string ")"]
adamc@1 52
adamc@623 53 | KVar x => string x
adamc@623 54 | KFun (x, k) => box [string x,
adamc@623 55 space,
adamc@623 56 string "-->",
adamc@623 57 space,
adamc@623 58 p_kind k]
adamc@623 59
adamc@1 60 and p_kind k = p_kind' false k
adamc@1 61
adamc@1 62 fun p_explicitness e =
adamc@1 63 case e of
adamc@1 64 Explicit => string "::"
adamc@1 65 | Implicit => string ":::"
adamc@1 66
adamc@1 67 fun p_con' par (c, _) =
adamc@1 68 case c of
adamc@1 69 CAnnot (c, k) => box [string "(",
adamc@1 70 p_con c,
adamc@1 71 space,
adamc@1 72 string "::",
adamc@1 73 space,
adamc@1 74 p_kind k,
adamc@1 75 string ")"]
adamc@1 76
adamc@1 77 | TFun (t1, t2) => parenIf par (box [p_con' true t1,
adamc@1 78 space,
adamc@1 79 string "->",
adamc@1 80 space,
adamc@1 81 p_con t2])
adamc@1 82 | TCFun (e, x, k, c) => parenIf par (box [string x,
adamc@1 83 space,
adamc@1 84 p_explicitness e,
adamc@1 85 space,
adamc@1 86 p_kind k,
adamc@1 87 space,
adamc@1 88 string "->",
adamc@1 89 space,
adamc@1 90 p_con c])
adamc@1 91 | TRecord (CRecord xcs, _) => box [string "{",
adamc@1 92 p_list (fn (x, c) =>
adamc@20 93 box [p_name x,
adamc@1 94 space,
adamc@1 95 string ":",
adamc@1 96 space,
adamc@1 97 p_con c]) xcs,
adamc@1 98 string "}"]
adamc@1 99 | TRecord c => box [string "$",
adamc@1 100 p_con' true c]
adamc@1 101
adamc@34 102 | CVar (ss, s) => p_list_sep (string ".") string (ss @ [s])
adamc@1 103 | CApp (c1, c2) => parenIf par (box [p_con c1,
adamc@1 104 space,
adamc@1 105 p_con' true c2])
adamc@67 106 | CAbs (x, NONE, c) => parenIf par (box [string "fn",
adamc@67 107 space,
adamc@67 108 string x,
adamc@67 109 space,
adamc@67 110 string "=>",
adamc@67 111 space,
adamc@67 112 p_con c])
adamc@67 113 | CAbs (x, SOME k, c) => parenIf par (box [string "fn",
adamc@67 114 space,
adamc@67 115 string x,
adamc@67 116 space,
adamc@67 117 string "::",
adamc@67 118 space,
adamc@67 119 p_kind k,
adamc@67 120 space,
adamc@67 121 string "=>",
adamc@67 122 space,
adamc@67 123 p_con c])
adamc@84 124 | CDisjoint (c1, c2, c3) => parenIf par (box [p_con c1,
adamc@84 125 space,
adamc@84 126 string "~",
adamc@84 127 space,
adamc@84 128 p_con c2,
adamc@84 129 space,
adamc@84 130 string "=>",
adamc@84 131 space,
adamc@84 132 p_con c3])
adamc@1 133
adamc@1 134 | CName s => box [string "#", string s]
adamc@1 135
adamc@1 136 | CRecord xcs => box [string "[",
adamc@1 137 p_list (fn (x, c) =>
adamc@1 138 box [p_con x,
adamc@1 139 space,
adamc@1 140 string "=",
adamc@1 141 space,
adamc@1 142 p_con c]) xcs,
adamc@1 143 string "]"]
adamc@1 144 | CConcat (c1, c2) => parenIf par (box [p_con' true c1,
adamc@1 145 space,
adamc@1 146 string "++",
adamc@1 147 space,
adamc@1 148 p_con c2])
adamc@621 149 | CMap => string "map"
adamc@82 150
adamc@82 151 | CUnit => string "()"
adamc@82 152
adamc@18 153 | CWild k => box [string "(_",
adamc@18 154 space,
adamc@18 155 string "::",
adamc@18 156 space,
adamc@223 157 p_kind k,
adamc@223 158 string ")"]
adamc@207 159
adamc@207 160 | CTuple cs => box [string "(",
adamc@207 161 p_list p_con cs,
adamc@207 162 string ")"]
adamc@207 163 | CProj (c, n) => box [p_con c,
adamc@207 164 string ".",
adamc@207 165 string (Int.toString n)]
adamc@623 166
adamc@623 167 | CKAbs (x, c) => box [string x,
adamc@623 168 space,
adamc@623 169 string "==>",
adamc@623 170 space,
adamc@623 171 p_con c]
adamc@623 172 | TKFun (x, c) => box [string x,
adamc@623 173 space,
adamc@623 174 string "-->",
adamc@623 175 space,
adamc@623 176 p_con c]
adamc@1 177
adamc@1 178 and p_con c = p_con' false c
adamc@1 179
adamc@20 180 and p_name (all as (c, _)) =
adamc@20 181 case c of
adamc@20 182 CName s => string s
adamc@20 183 | _ => p_con all
adamc@20 184
adamc@170 185 fun p_pat' par (p, _) =
adamc@170 186 case p of
adamc@170 187 PWild => string "_"
adamc@170 188 | PVar s => string s
adamc@173 189 | PPrim p => Prim.p_t p
adamc@170 190 | PCon (ms, x, NONE) => p_list_sep (string ".") string (ms @ [x])
adamc@170 191 | PCon (ms, x, SOME p) => parenIf par (box [p_list_sep (string ".") string (ms @ [x]),
adamc@170 192 space,
adamc@170 193 p_pat' true p])
adamc@174 194 | PRecord (xps, flex) =>
adamc@174 195 let
adamc@175 196 val pps = map (fn (x, p) => box [string x, space, string "=", space, p_pat p]) xps
adamc@174 197 in
adamc@174 198 box [string "{",
adamc@174 199 p_list_sep (box [string ",", space]) (fn x => x)
adamc@174 200 (if flex then
adamc@175 201 pps @ [string "..."]
adamc@174 202 else
adamc@175 203 pps),
adamc@174 204 string "}"]
adamc@174 205 end
adamc@170 206
adamc@174 207 and p_pat x = p_pat' false x
adamc@170 208
adamc@8 209 fun p_exp' par (e, _) =
adamc@8 210 case e of
adamc@8 211 EAnnot (e, t) => box [string "(",
adamc@8 212 p_exp e,
adamc@8 213 space,
adamc@8 214 string ":",
adamc@8 215 space,
adamc@8 216 p_con t,
adamc@8 217 string ")"]
adamc@8 218
adamc@14 219 | EPrim p => Prim.p_t p
adamc@403 220 | EVar (ss, s, _) => p_list_sep (string ".") string (ss @ [s])
adamc@8 221 | EApp (e1, e2) => parenIf par (box [p_exp e1,
adamc@8 222 space,
adamc@8 223 p_exp' true e2])
adamc@8 224 | EAbs (x, NONE, e) => parenIf par (box [string "fn",
adamc@8 225 space,
adamc@8 226 string x,
adamc@8 227 space,
adamc@8 228 string "=>",
adamc@8 229 space,
adamc@8 230 p_exp e])
adamc@8 231 | EAbs (x, SOME t, e) => parenIf par (box [string "fn",
adamc@8 232 space,
adamc@8 233 string x,
adamc@8 234 space,
adamc@8 235 string ":",
adamc@8 236 space,
adamc@8 237 p_con t,
adamc@8 238 space,
adamc@8 239 string "=>",
adamc@8 240 space,
adamc@8 241 p_exp e])
adamc@8 242 | ECApp (e, c) => parenIf par (box [p_exp e,
adamc@8 243 space,
adamc@8 244 string "[",
adamc@8 245 p_con c,
adamc@8 246 string "]"])
adamc@8 247 | ECAbs (exp, x, k, e) => parenIf par (box [string "fn",
adamc@8 248 space,
adamc@8 249 string x,
adamc@8 250 space,
adamc@8 251 p_explicitness exp,
adamc@8 252 space,
adamc@8 253 p_kind k,
adamc@8 254 space,
adamc@8 255 string "=>",
adamc@8 256 space,
adamc@8 257 p_exp e])
adamc@85 258 | EDisjoint (c1, c2, e) => parenIf par (box [p_con c1,
adamc@85 259 space,
adamc@85 260 string "~",
adamc@85 261 space,
adamc@85 262 p_con c2,
adamc@85 263 space,
adamc@85 264 string "=>",
adamc@85 265 space,
adamc@85 266 p_exp e])
adamc@8 267
adamc@12 268 | ERecord xes => box [string "{",
adamc@12 269 p_list (fn (x, e) =>
adamc@21 270 box [p_name x,
adamc@12 271 space,
adamc@12 272 string "=",
adamc@12 273 space,
adamc@12 274 p_exp e]) xes,
adamc@12 275 string "}"]
adamc@12 276 | EField (e, c) => box [p_exp' true e,
adamc@12 277 string ".",
adamc@12 278 p_con' true c]
adamc@445 279 | EConcat (e1, e2) => parenIf par (box [p_exp' true e1,
adamc@445 280 space,
adamc@445 281 string "++",
adamc@445 282 space,
adamc@445 283 p_exp' true e2])
adamc@149 284 | ECut (e, c) => parenIf par (box [p_exp' true e,
adamc@149 285 space,
adamc@149 286 string "--",
adamc@149 287 space,
adamc@149 288 p_con' true c])
adamc@493 289 | ECutMulti (e, c) => parenIf par (box [p_exp' true e,
adamc@493 290 space,
adamc@493 291 string "---",
adamc@493 292 space,
adamc@493 293 p_con' true c])
adamc@170 294 | ECase (e, pes) => parenIf par (box [string "case",
adamc@170 295 space,
adamc@171 296 p_exp e,
adamc@170 297 space,
adamc@170 298 string "of",
adamc@170 299 space,
adamc@170 300 p_list_sep (box [space, string "|", space])
adamc@170 301 (fn (p, e) => box [p_pat p,
adamc@170 302 space,
adamc@170 303 string "=>",
adamc@170 304 space,
adamc@170 305 p_exp e]) pes])
adamc@170 306
adamc@219 307 | EWild => string "_"
adamc@210 308
adamc@446 309 | ELet (ds, e) => box [string "let",
adamc@446 310 newline,
adamc@446 311 box [p_list_sep newline p_edecl ds],
adamc@446 312 newline,
adamc@446 313 string "in",
adamc@446 314 newline,
adamc@446 315 box [p_exp e],
adamc@446 316 newline,
adamc@446 317 string "end"]
adamc@446 318
adamc@623 319 | EKAbs (x, e) => box [string x,
adamc@623 320 space,
adamc@623 321 string "-->",
adamc@623 322 space,
adamc@623 323 p_exp e]
adamc@623 324
adamc@8 325 and p_exp e = p_exp' false e
adamc@8 326
adamc@446 327 and p_edecl (d, _) =
adamc@446 328 case d of
adamc@446 329 EDVal vi => box [string "val",
adamc@446 330 space,
adamc@446 331 p_vali vi]
adamc@446 332 | EDValRec vis => box [string "val",
adamc@446 333 space,
adamc@446 334 string "rec",
adamc@446 335 space,
adamc@446 336 p_list_sep (box [newline, string "and", space]) p_vali vis]
adamc@446 337
adamc@446 338 and p_vali (x, co, e) =
adamc@446 339 case co of
adamc@446 340 NONE => box [string x,
adamc@446 341 space,
adamc@446 342 string "=",
adamc@446 343 space,
adamc@446 344 p_exp e]
adamc@446 345 | SOME t => box [string x,
adamc@446 346 space,
adamc@446 347 string ":",
adamc@446 348 space,
adamc@446 349 p_con t,
adamc@446 350 space,
adamc@446 351 string "=",
adamc@446 352 space,
adamc@446 353 p_exp e]
adamc@446 354
adamc@446 355
adamc@191 356 fun p_datatype (x, xs, cons) =
adamc@156 357 box [string "datatype",
adamc@156 358 space,
adamc@156 359 string x,
adamc@191 360 p_list_sep (box []) (fn x => box [space, string x]) xs,
adamc@156 361 space,
adamc@156 362 string "=",
adamc@156 363 space,
adamc@156 364 p_list_sep (box [space, string "|", space])
adamc@156 365 (fn (x, NONE) => string x
adamc@156 366 | (x, SOME t) => box [string x, space, string "of", space, p_con t])
adamc@156 367 cons]
adamc@156 368
adamc@30 369 fun p_sgn_item (sgi, _) =
adamc@30 370 case sgi of
adamc@30 371 SgiConAbs (x, k) => box [string "con",
adamc@30 372 space,
adamc@30 373 string x,
adamc@30 374 space,
adamc@30 375 string "::",
adamc@30 376 space,
adamc@30 377 p_kind k]
adamc@30 378 | SgiCon (x, NONE, c) => box [string "con",
adamc@30 379 space,
adamc@30 380 string x,
adamc@30 381 space,
adamc@30 382 string "=",
adamc@30 383 space,
adamc@30 384 p_con c]
adamc@30 385 | SgiCon (x, SOME k, c) => box [string "con",
adamc@30 386 space,
adamc@30 387 string x,
adamc@30 388 space,
adamc@30 389 string "::",
adamc@30 390 space,
adamc@30 391 p_kind k,
adamc@30 392 space,
adamc@30 393 string "=",
adamc@30 394 space,
adamc@30 395 p_con c]
adamc@156 396 | SgiDatatype x => p_datatype x
adamc@156 397 | SgiDatatypeImp (x, ms, x') =>
adamc@156 398 box [string "datatype",
adamc@156 399 space,
adamc@156 400 string x,
adamc@156 401 space,
adamc@156 402 string "=",
adamc@156 403 space,
adamc@156 404 string "datatype",
adamc@156 405 space,
adamc@156 406 p_list_sep (string ".") string (ms @ [x'])]
adamc@30 407 | SgiVal (x, c) => box [string "val",
adamc@30 408 space,
adamc@30 409 string x,
adamc@30 410 space,
adamc@30 411 string ":",
adamc@30 412 space,
adamc@30 413 p_con c]
adamc@30 414 | SgiStr (x, sgn) => box [string "structure",
adamc@30 415 space,
adamc@30 416 string x,
adamc@30 417 space,
adamc@30 418 string ":",
adamc@30 419 space,
adamc@30 420 p_sgn sgn]
adamc@59 421 | SgiSgn (x, sgn) => box [string "signature",
adamc@59 422 space,
adamc@59 423 string x,
adamc@59 424 space,
adamc@59 425 string "=",
adamc@59 426 space,
adamc@59 427 p_sgn sgn]
adamc@58 428 | SgiInclude sgn => box [string "include",
adamc@58 429 space,
adamc@58 430 p_sgn sgn]
adamc@88 431 | SgiConstraint (c1, c2) => box [string "constraint",
adamc@88 432 space,
adamc@88 433 p_con c1,
adamc@88 434 space,
adamc@88 435 string "~",
adamc@88 436 space,
adamc@88 437 p_con c2]
adamc@563 438 | SgiClassAbs (x, k) => box [string "class",
adamc@563 439 space,
adamc@563 440 string x,
adamc@563 441 space,
adamc@563 442 string "::",
adamc@563 443 space,
adamc@563 444 p_kind k]
adamc@563 445 | SgiClass (x, k, c) => box [string "class",
adamc@563 446 space,
adamc@563 447 string x,
adamc@563 448 space,
adamc@563 449 string "::",
adamc@563 450 space,
adamc@563 451 p_kind k,
adamc@563 452 space,
adamc@563 453 string "=",
adamc@563 454 space,
adamc@563 455 p_con c]
adamc@563 456
adamc@30 457 and p_sgn (sgn, _) =
adamc@30 458 case sgn of
adamc@30 459 SgnConst sgis => box [string "sig",
adamc@30 460 newline,
adamc@30 461 p_list_sep newline p_sgn_item sgis,
adamc@30 462 newline,
adamc@30 463 string "end"]
adamc@30 464 | SgnVar x => string x
adamc@40 465 | SgnFun (x, sgn, sgn') => box [string "functor",
adamc@40 466 space,
adamc@40 467 string "(",
adamc@40 468 string x,
adamc@40 469 space,
adamc@40 470 string ":",
adamc@40 471 p_sgn sgn,
adamc@40 472 string ")",
adamc@40 473 space,
adamc@40 474 string ":",
adamc@40 475 space,
adamc@40 476 p_sgn sgn']
adamc@42 477 | SgnWhere (sgn, x, c) => box [p_sgn sgn,
adamc@42 478 space,
adamc@42 479 string "where",
adamc@42 480 space,
adamc@42 481 string "con",
adamc@42 482 space,
adamc@42 483 string x,
adamc@42 484 space,
adamc@42 485 string "=",
adamc@42 486 space,
adamc@42 487 p_con c]
adamc@59 488 | SgnProj (m, ms, x) => p_list_sep (string ".") string (m :: ms @ [x])
adamc@59 489
adamc@42 490
adamc@123 491
adamc@1 492 fun p_decl ((d, _) : decl) =
adamc@1 493 case d of
adamc@1 494 DCon (x, NONE, c) => box [string "con",
adamc@1 495 space,
adamc@1 496 string x,
adamc@1 497 space,
adamc@1 498 string "=",
adamc@1 499 space,
adamc@1 500 p_con c]
adamc@1 501 | DCon (x, SOME k, c) => box [string "con",
adamc@1 502 space,
adamc@1 503 string x,
adamc@1 504 space,
adamc@1 505 string "::",
adamc@1 506 space,
adamc@1 507 p_kind k,
adamc@1 508 space,
adamc@1 509 string "=",
adamc@1 510 space,
adamc@1 511 p_con c]
adamc@156 512 | DDatatype x => p_datatype x
adamc@156 513 | DDatatypeImp (x, ms, x') =>
adamc@156 514 box [string "datatype",
adamc@156 515 space,
adamc@156 516 string x,
adamc@156 517 space,
adamc@156 518 string "=",
adamc@156 519 space,
adamc@156 520 string "datatype",
adamc@156 521 space,
adamc@156 522 p_list_sep (string ".") string (ms @ [x'])]
adamc@123 523 | DVal vi => box [string "val",
adamc@123 524 space,
adamc@123 525 p_vali vi]
adamc@123 526 | DValRec vis => box [string "val",
adamc@123 527 space,
adamc@123 528 string "rec",
adamc@123 529 space,
adamc@123 530 p_list_sep (box [newline, string "and", space]) p_vali vis]
adamc@1 531
adamc@30 532 | DSgn (x, sgn) => box [string "signature",
adamc@30 533 space,
adamc@30 534 string x,
adamc@30 535 space,
adamc@30 536 string "=",
adamc@30 537 space,
adamc@30 538 p_sgn sgn]
adamc@30 539 | DStr (x, NONE, str) => box [string "structure",
adamc@30 540 space,
adamc@30 541 string x,
adamc@30 542 space,
adamc@30 543 string "=",
adamc@30 544 space,
adamc@30 545 p_str str]
adamc@30 546 | DStr (x, SOME sgn, str) => box [string "structure",
adamc@30 547 space,
adamc@30 548 string x,
adamc@30 549 space,
adamc@30 550 string ":",
adamc@30 551 space,
adamc@30 552 p_sgn sgn,
adamc@30 553 space,
adamc@30 554 string "=",
adamc@30 555 space,
adamc@30 556 p_str str]
adamc@48 557 | DFfiStr (x, sgn) => box [string "extern",
adamc@48 558 space,
adamc@48 559 string "structure",
adamc@48 560 space,
adamc@48 561 string x,
adamc@48 562 space,
adamc@48 563 string ":",
adamc@48 564 space,
adamc@48 565 p_sgn sgn]
adamc@61 566 | DOpen (m, ms) => box [string "open",
adamc@61 567 space,
adamc@61 568 p_list_sep (string ".") string (m :: ms)]
adamc@88 569 | DConstraint (c1, c2) => box [string "constraint",
adamc@88 570 space,
adamc@88 571 p_con c1,
adamc@88 572 space,
adamc@88 573 string "~",
adamc@88 574 space,
adamc@88 575 p_con c2]
adamc@88 576 | DOpenConstraints (m, ms) => box [string "open",
adamc@88 577 space,
adamc@88 578 string "constraints",
adamc@88 579 space,
adamc@88 580 p_list_sep (string ".") string (m :: ms)]
adamc@30 581
adamc@109 582 | DExport str => box [string "export",
adamc@109 583 space,
adamc@109 584 p_str str]
adamc@203 585 | DTable (x, c) => box [string "table",
adamc@203 586 space,
adamc@203 587 string x,
adamc@203 588 space,
adamc@203 589 string ":",
adamc@203 590 space,
adamc@203 591 p_con c]
adamc@338 592 | DSequence x => box [string "sequence",
adamc@338 593 space,
adamc@338 594 string x]
adamc@563 595 | DClass (x, k, c) => box [string "class",
adamc@563 596 space,
adamc@563 597 string x,
adamc@563 598 space,
adamc@563 599 string "=",
adamc@563 600 space,
adamc@563 601 p_con c]
adamc@100 602
adamc@271 603 | DDatabase s => box [string "database",
adamc@271 604 space,
adamc@271 605 string s]
adamc@271 606
adamc@459 607 | DCookie (x, c) => box [string "cookie",
adamc@459 608 space,
adamc@459 609 string x,
adamc@459 610 space,
adamc@459 611 string ":",
adamc@459 612 space,
adamc@459 613 p_con c]
adamc@459 614
adamc@30 615 and p_str (str, _) =
adamc@30 616 case str of
adamc@30 617 StrConst ds => box [string "struct",
adamc@30 618 newline,
adamc@30 619 p_list_sep newline p_decl ds,
adamc@30 620 newline,
adamc@30 621 string "end"]
adamc@30 622 | StrVar x => string x
adamc@34 623 | StrProj (str, x) => box [p_str str,
adamc@34 624 string ".",
adamc@34 625 string x]
adamc@40 626 | StrFun (x, sgn, NONE, str) => box [string "functor",
adamc@40 627 space,
adamc@40 628 string "(",
adamc@40 629 string x,
adamc@40 630 space,
adamc@40 631 string ":",
adamc@40 632 p_sgn sgn,
adamc@40 633 string ")",
adamc@40 634 space,
adamc@40 635 string "=>",
adamc@40 636 space,
adamc@40 637 p_str str]
adamc@40 638 | StrFun (x, sgn, SOME sgn', str) => box [string "functor",
adamc@40 639 space,
adamc@40 640 string "(",
adamc@40 641 string x,
adamc@40 642 space,
adamc@40 643 string ":",
adamc@40 644 p_sgn sgn,
adamc@40 645 string ")",
adamc@40 646 space,
adamc@40 647 string ":",
adamc@40 648 space,
adamc@40 649 p_sgn sgn',
adamc@40 650 space,
adamc@40 651 string "=>",
adamc@40 652 space,
adamc@40 653 p_str str]
adamc@44 654 | StrApp (str1, str2) => box [p_str str1,
adamc@44 655 string "(",
adamc@44 656 p_str str2,
adamc@44 657 string ")"]
adamc@30 658
adamc@1 659 val p_file = p_list_sep newline p_decl
adamc@1 660
adamc@1 661 end