aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/source_print.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-01-26 17:10:26 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-01-26 17:10:26 -0500
commitc3c7a475626786988f0a367fc3c20f903f3fcbba (patch)
tree96d21b1114d7bc1ad6bddcdd1cc009f3c8152e9d /src/source_print.sml
parent554a00c1e5a61d1a2a2767eb091777fbc2a7b811 (diff)
Parsing basic expressions
Diffstat (limited to 'src/source_print.sml')
-rw-r--r--src/source_print.sml91
1 files changed, 80 insertions, 11 deletions
diff --git a/src/source_print.sml b/src/source_print.sml
index 704d07ec..b81a82df 100644
--- a/src/source_print.sml
+++ b/src/source_print.sml
@@ -91,17 +91,17 @@ fun p_con' par (c, _) =
| CApp (c1, c2) => parenIf par (box [p_con c1,
space,
p_con' true c2])
- | CAbs (e, x, k, c) => parenIf par (box [string "fn",
- space,
- string x,
- space,
- p_explicitness e,
- space,
- p_kind k,
- space,
- string "=>",
- space,
- p_con c])
+ | CAbs (x, k, c) => parenIf par (box [string "fn",
+ space,
+ string x,
+ space,
+ string "::",
+ space,
+ p_kind k,
+ space,
+ string "=>",
+ space,
+ p_con c])
| CName s => box [string "#", string s]
@@ -121,6 +121,57 @@ fun p_con' par (c, _) =
and p_con c = p_con' false c
+fun p_exp' par (e, _) =
+ case e of
+ EAnnot (e, t) => box [string "(",
+ p_exp e,
+ space,
+ string ":",
+ space,
+ p_con t,
+ string ")"]
+
+ | EVar s => string s
+ | EApp (e1, e2) => parenIf par (box [p_exp e1,
+ space,
+ p_exp' true e2])
+ | EAbs (x, NONE, e) => parenIf par (box [string "fn",
+ space,
+ string x,
+ space,
+ string "=>",
+ space,
+ p_exp e])
+ | EAbs (x, SOME t, e) => parenIf par (box [string "fn",
+ space,
+ string x,
+ space,
+ string ":",
+ space,
+ p_con t,
+ space,
+ string "=>",
+ space,
+ p_exp e])
+ | ECApp (e, c) => parenIf par (box [p_exp e,
+ space,
+ string "[",
+ p_con c,
+ string "]"])
+ | ECAbs (exp, x, k, e) => parenIf par (box [string "fn",
+ space,
+ string x,
+ space,
+ p_explicitness exp,
+ space,
+ p_kind k,
+ space,
+ string "=>",
+ space,
+ p_exp e])
+
+and p_exp e = p_exp' false e
+
fun p_decl ((d, _) : decl) =
case d of
DCon (x, NONE, c) => box [string "con",
@@ -141,6 +192,24 @@ fun p_decl ((d, _) : decl) =
string "=",
space,
p_con c]
+ | DVal (x, NONE, e) => box [string "val",
+ space,
+ string x,
+ space,
+ string "=",
+ space,
+ p_exp e]
+ | DVal (x, SOME t, e) => box [string "val",
+ space,
+ string x,
+ space,
+ string ":",
+ space,
+ p_con t,
+ space,
+ string "=",
+ space,
+ p_exp e]
val p_file = p_list_sep newline p_decl