summaryrefslogtreecommitdiff
path: root/src/cjr_print.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 11:33:13 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-07 11:33:13 -0400
commit5cf1d4d086475575a31f57413c57c22bd6fda378 (patch)
treeab36ce67d2931f2c715b5b734930139c53adc670 /src/cjr_print.sml
parent42c284b9204ef5dfc249cc7273ff2eaa9304e9e6 (diff)
Converting string to int
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r--src/cjr_print.sml67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 25a84b9c..8ca7c09d 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -90,6 +90,12 @@ fun p_typ' par env (t, loc) =
string ("__lwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")]
handle CjrEnv.UnboundNamed _ => string ("__lwd_UNBOUND__" ^ Int.toString n))
| TFfi (m, x) => box [string "lw_", string m, string "_", string x]
+ | TOption t =>
+ (case #1 t of
+ TDatatype _ => p_typ' par env t
+ | TFfi ("Basis", "string") => p_typ' par env t
+ | _ => box [p_typ' par env t,
+ string "*"])
and p_typ env = p_typ' false env
@@ -127,6 +133,8 @@ fun p_pat_preamble env (p, _) =
in
(box [pp', pp], env)
end) (box [], env) xps
+ | PNone _ => (box [], env)
+ | PSome (_, p) => p_pat_preamble env p
fun p_patCon env pc =
case pc of
@@ -293,6 +301,65 @@ fun p_pat (env, exit, depth) (p, _) =
env)
end
+ | PNone t =>
+ (box [string "if",
+ space,
+ string "(disc",
+ string (Int.toString depth),
+ space,
+ string "!=",
+ space,
+ string "NULL)",
+ space,
+ exit,
+ newline],
+ env)
+
+ | PSome (t, p) =>
+ let
+ val (p, env) =
+ let
+ val (p, env) = p_pat (env, exit, depth + 1) p
+ in
+ (box [string "{",
+ newline,
+ p_typ env t,
+ space,
+ string "disc",
+ string (Int.toString (depth + 1)),
+ space,
+ string "=",
+ space,
+ case #1 t of
+ TDatatype _ => box [string "disc",
+ string (Int.toString depth)]
+ | TFfi ("Basis", "string") => box [string "disc",
+ string (Int.toString depth)]
+ | _ => box [string "*disc",
+ string (Int.toString depth)],
+ string ";",
+ newline,
+ p,
+ newline,
+ string "}"],
+ env)
+ end
+ in
+ (box [string "if",
+ space,
+ string "(disc",
+ string (Int.toString depth),
+ space,
+ string "==",
+ space,
+ string "NULL)",
+ space,
+ exit,
+ newline,
+ p],
+ env)
+ end
+
local
val count = ref 0
in