comparison src/elab_print.sml @ 123:e3041657d653

Parsing and elaborating (non-mutual) 'val rec'
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Jul 2008 10:09:34 -0400
parents 3739af9e727a
children eb16f2aadbe9
comparison
equal deleted inserted replaced
122:f7c6ceb87bbd 123:e3041657d653
389 in 389 in
390 p_list_sep (string ".") string (m1x :: ms @ [x]) 390 p_list_sep (string ".") string (m1x :: ms @ [x])
391 end 391 end
392 | SgnError => string "<ERROR>" 392 | SgnError => string "<ERROR>"
393 393
394 fun p_decl env ((d, _) : decl) = 394 fun p_vali env (x, n, t, e) = box [p_named x n,
395 space,
396 string ":",
397 space,
398 p_con env t,
399 space,
400 string "=",
401 space,
402 p_exp env e]
403
404 fun p_decl env (dAll as (d, _) : decl) =
395 case d of 405 case d of
396 DCon (x, n, k, c) => box [string "con", 406 DCon (x, n, k, c) => box [string "con",
397 space, 407 space,
398 p_named x n, 408 p_named x n,
399 space, 409 space,
402 p_kind k, 412 p_kind k,
403 space, 413 space,
404 string "=", 414 string "=",
405 space, 415 space,
406 p_con env c] 416 p_con env c]
407 | DVal (x, n, t, e) => box [string "val", 417 | DVal vi => box [string "val",
408 space, 418 space,
409 p_named x n, 419 p_vali env vi]
410 space, 420 | DValRec vis =>
411 string ":", 421 let
412 space, 422 val env = E.declBinds env dAll
413 p_con env t, 423 in
414 space, 424 box [string "val",
415 string "=", 425 space,
416 space, 426 string "rec",
417 p_exp env e] 427 space,
428 p_list_sep (box [newline, string "and", space]) (p_vali env) vis]
429 end
418 430
419 | DSgn (x, n, sgn) => box [string "signature", 431 | DSgn (x, n, sgn) => box [string "signature",
420 space, 432 space,
421 p_named x n, 433 p_named x n,
422 space, 434 space,