From aa1b3a24913edd0dc97af0d1fc9e3dc0026a2460 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 29 Jul 2008 16:38:15 -0400 Subject: Parsing basic patterns --- src/source_print.sml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/source_print.sml') 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) = -- cgit v1.2.3