annotate src/core_print.sml @ 976:68eda5b0636d

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