Mercurial > urweb
diff src/source_print.sml @ 170:a158f8c5aa55
Parsing basic patterns
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 29 Jul 2008 16:38:15 -0400 |
parents | 34ccd7d2bea8 |
children | c7a6e6dbc318 |
line wrap: on
line diff
--- a/src/source_print.sml Tue Jul 29 16:02:02 2008 -0400 +++ b/src/source_print.sml Tue Jul 29 16:38:15 2008 -0400 @@ -162,6 +162,17 @@ 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 @@ 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) =