comparison src/mono_opt.sml @ 754:8688e01ae469

A view query works
author Adam Chlipala <adamc@hcoop.net>
date Tue, 28 Apr 2009 15:04:37 -0400
parents f7e2026dd5ae
children efceae06df17
comparison
equal deleted inserted replaced
753:d484df4e841a 754:8688e01ae469
420 | cs => uwify (cs, []) 420 | cs => uwify (cs, [])
421 in 421 in
422 EPrim (Prim.String s) 422 EPrim (Prim.String s)
423 end 423 end
424 424
425 | EFfiApp ("Basis", "viewify", [(EPrim (Prim.String s), loc)]) =>
426 let
427 fun uwify (cs, acc) =
428 case cs of
429 [] => String.concat (rev acc)
430 | #"A" :: #"S" :: #" " :: #"_" :: cs => uwify (cs, "AS uw_" :: acc)
431 | #"'" :: cs =>
432 let
433 fun waitItOut (cs, acc) =
434 case cs of
435 [] => raise Fail "MonoOpt: Unterminated SQL string literal"
436 | #"'" :: cs => uwify (cs, "'" :: acc)
437 | #"\\" :: #"'" :: cs => waitItOut (cs, "\\'" :: acc)
438 | #"\\" :: #"\\" :: cs => waitItOut (cs, "\\\\" :: acc)
439 | c :: cs => waitItOut (cs, str c :: acc)
440 in
441 waitItOut (cs, "'" :: acc)
442 end
443 | c :: cs => uwify (cs, str c :: acc)
444
445 val s = uwify (String.explode s, [])
446 in
447 EPrim (Prim.String s)
448 end
449
425 | _ => e 450 | _ => e
426 451
427 and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e) 452 and optExp e = #1 (U.Exp.map {typ = typ, exp = exp} e)
428 453
429 val optimize = U.File.map {typ = typ, exp = exp, decl = decl} 454 val optimize = U.File.map {typ = typ, exp = exp, decl = decl}