diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 16:38:15 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 16:38:15 -0400 |
commit | aa1b3a24913edd0dc97af0d1fc9e3dc0026a2460 (patch) | |
tree | ea20c705efe957d91b540e491ed8b7c6ff58efd9 /src/source_print.sml | |
parent | c9e2d6c9f290298c0068a72831d314793897f327 (diff) |
Parsing basic patterns
Diffstat (limited to 'src/source_print.sml')
-rw-r--r-- | src/source_print.sml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/source_print.sml b/src/source_print.sml index b69b0b58..79f3c254 100644 --- a/src/source_print.sml +++ b/src/source_print.sml @@ -162,6 +162,17 @@ and p_name (all as (c, _)) = CName s => string s | _ => p_con all +fun p_pat' par (p, _) = + case p of + PWild => string "_" + | PVar s => string s + | PCon (ms, x, NONE) => p_list_sep (string ".") string (ms @ [x]) + | PCon (ms, x, SOME p) => parenIf par (box [p_list_sep (string ".") string (ms @ [x]), + space, + p_pat' true p]) + +val p_pat = p_pat' false + fun p_exp' par (e, _) = case e of EAnnot (e, t) => box [string "(", @@ -239,6 +250,19 @@ fun p_exp' par (e, _) = p_con' true c]) | EFold => string "fold" + | ECase (e, pes) => parenIf par (box [string "case", + space, + p_exp' false e, + space, + string "of", + space, + p_list_sep (box [space, string "|", space]) + (fn (p, e) => box [p_pat p, + space, + string "=>", + space, + p_exp e]) pes]) + and p_exp e = p_exp' false e fun p_datatype (x, cons) = |