comparison src/sql.sml @ 2048:4d64af730e35

Differentiate between HTML and normal string literals
author Adam Chlipala <adam@chlipala.net>
date Fri, 01 Aug 2014 15:44:17 -0400
parents cb0f05bdc183
children ef766ef6e242
comparison
equal deleted inserted replaced
2047:6be31671911b 2048:4d64af730e35
45 String of string 45 String of string
46 | Exp of Mono.exp 46 | Exp of Mono.exp
47 47
48 fun chunkify e = 48 fun chunkify e =
49 case #1 e of 49 case #1 e of
50 EPrim (Prim.String s) => [String s] 50 EPrim (Prim.String (_, s)) => [String s]
51 | EStrcat (e1, e2) => 51 | EStrcat (e1, e2) =>
52 let 52 let
53 val chs1 = chunkify e1 53 val chs1 = chunkify e1
54 val chs2 = chunkify e2 54 val chs2 = chunkify e2
55 in 55 in
246 (opt (const "::float8"))) #1, 246 (opt (const "::float8"))) #1,
247 wrap (follow (wrapP (keep Char.isDigit) 247 wrap (follow (wrapP (keep Char.isDigit)
248 (Option.map Prim.Int o Int64.fromString)) 248 (Option.map Prim.Int o Int64.fromString))
249 (opt (const "::int8"))) #1, 249 (opt (const "::int8"))) #1,
250 wrap (follow (opt (const "E")) (follow string (opt (const "::text")))) 250 wrap (follow (opt (const "E")) (follow string (opt (const "::text"))))
251 (Prim.String o #1 o #2)] 251 ((fn s => Prim.String (Prim.Normal, s)) o #1 o #2)]
252 252
253 fun known' chs = 253 fun known' chs =
254 case chs of 254 case chs of
255 Exp (EFfi ("Basis", "sql_known"), _) :: chs => SOME ((), chs) 255 Exp (EFfi ("Basis", "sql_known"), _) :: chs => SOME ((), chs)
256 | _ => NONE 256 | _ => NONE
261 if String.isPrefix "sqlify" f then 261 if String.isPrefix "sqlify" f then
262 SOME (e, chs) 262 SOME (e, chs)
263 else 263 else
264 NONE 264 NONE
265 | Exp (ECase (e, [((PCon (_, PConFfi {mod = "Basis", con = "True", ...}, NONE), _), 265 | Exp (ECase (e, [((PCon (_, PConFfi {mod = "Basis", con = "True", ...}, NONE), _),
266 (EPrim (Prim.String "TRUE"), _)), 266 (EPrim (Prim.String (Prim.Normal, "TRUE")), _)),
267 ((PCon (_, PConFfi {mod = "Basis", con = "False", ...}, NONE), _), 267 ((PCon (_, PConFfi {mod = "Basis", con = "False", ...}, NONE), _),
268 (EPrim (Prim.String "FALSE"), _))], _), _) :: chs => 268 (EPrim (Prim.String (Prim.Normal, "FALSE")), _))], _), _) :: chs =>
269 SOME (e, chs) 269 SOME (e, chs)
270 270
271 | _ => NONE 271 | _ => NONE
272 272
273 fun constK s = wrap (const s) (fn () => s) 273 fun constK s = wrap (const s) (fn () => s)