summaryrefslogtreecommitdiff
path: root/src/mono_opt.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-28 15:04:37 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-28 15:04:37 -0400
commit51f2a80dac5c3cd25a27fb5abfdfa50d813ab0b2 (patch)
treee4e2246dc15a7cbbf067401a21197b6fd17ea95b /src/mono_opt.sml
parentcaf010bca085bea65037d194c3eb21ca8b83c23b (diff)
A view query works
Diffstat (limited to 'src/mono_opt.sml')
-rw-r--r--src/mono_opt.sml25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mono_opt.sml b/src/mono_opt.sml
index 19244e60..41724eb0 100644
--- a/src/mono_opt.sml
+++ b/src/mono_opt.sml
@@ -422,6 +422,31 @@ fun exp e =
EPrim (Prim.String s)
end
+ | EFfiApp ("Basis", "viewify", [(EPrim (Prim.String s), loc)]) =>
+ let
+ fun uwify (cs, acc) =
+ case cs of
+ [] => String.concat (rev acc)
+ | #"A" :: #"S" :: #" " :: #"_" :: cs => uwify (cs, "AS uw_" :: acc)
+ | #"'" :: cs =>
+ let
+ fun waitItOut (cs, acc) =
+ case cs of
+ [] => raise Fail "MonoOpt: Unterminated SQL string literal"
+ | #"'" :: cs => uwify (cs, "'" :: acc)
+ | #"\\" :: #"'" :: cs => waitItOut (cs, "\\'" :: acc)
+ | #"\\" :: #"\\" :: cs => waitItOut (cs, "\\\\" :: acc)
+ | c :: cs => waitItOut (cs, str c :: acc)
+ in
+ waitItOut (cs, "'" :: acc)
+ end
+ | c :: cs => uwify (cs, str c :: acc)
+
+ val s = uwify (String.explode s, [])
+ in
+ EPrim (Prim.String s)
+ end
+
| _ => e
and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e)