Mercurial > urweb
comparison src/monoize.sml @ 261:ee51e9d35c9b
Monoize ORDER BY
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 31 Aug 2008 16:03:43 -0400 |
parents | 645d0e8da643 |
children | a6cb33f49366 |
comparison
equal
deleted
inserted
replaced
260:645d0e8da643 | 261:ee51e9d35c9b |
---|---|
553 in | 553 in |
554 ((L'.EAbs ("r", | 554 ((L'.EAbs ("r", |
555 (L'.TRecord [("Rows", s), ("OrderBy", s), ("Limit", s), ("Offset", s)], loc), | 555 (L'.TRecord [("Rows", s), ("OrderBy", s), ("Limit", s), ("Offset", s)], loc), |
556 s, | 556 s, |
557 strcat loc [gf "Rows", | 557 strcat loc [gf "Rows", |
558 gf "OrderBy", | 558 (L'.ECase (gf "OrderBy", |
559 [((L'.PPrim (Prim.String ""), loc), sc ""), | |
560 ((L'.PWild, loc), | |
561 strcat loc [sc " ORDER BY ", | |
562 gf "OrderBy"])], | |
563 {disc = s, result = s}), loc), | |
559 gf "Limit", | 564 gf "Limit", |
560 gf "Offset"]), loc), fm) | 565 gf "Offset"]), loc), fm) |
561 end | 566 end |
562 | 567 |
563 | L.ECApp ( | 568 | L.ECApp ( |
610 ("SelectFields", un), | 615 ("SelectFields", un), |
611 ("SelectExps", (L'.TRecord (map (fn (x, _) => (x, s)) sexps), loc))], | 616 ("SelectExps", (L'.TRecord (map (fn (x, _) => (x, s)) sexps), loc))], |
612 loc), | 617 loc), |
613 s, | 618 s, |
614 strcat loc [sc "SELECT ", | 619 strcat loc [sc "SELECT ", |
615 strcatR loc (gf "SelectExps") sexps, | 620 strcatComma loc (map (fn (x, t) => |
621 strcat loc [ | |
622 (L'.EField (gf "SelectExps", x), loc), | |
623 sc (" AS _" ^ x) | |
624 ]) sexps), | |
616 case sexps of | 625 case sexps of |
617 [] => sc "" | 626 [] => sc "" |
618 | _ => sc ", ", | 627 | _ => sc ", ", |
619 strcatComma loc (map (fn (x, xts) => | 628 strcatComma loc (map (fn (x, xts) => |
620 strcatComma loc | 629 strcatComma loc |
701 | L.ECApp ((L.EFfi ("Basis", "sql_subset_all"), _), _) => | 710 | L.ECApp ((L.EFfi ("Basis", "sql_subset_all"), _), _) => |
702 ((L'.ERecord [], loc), fm) | 711 ((L'.ERecord [], loc), fm) |
703 | 712 |
704 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_order_by_Nil"), _), _), _), _) => | 713 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_order_by_Nil"), _), _), _), _) => |
705 ((L'.EPrim (Prim.String ""), loc), fm) | 714 ((L'.EPrim (Prim.String ""), loc), fm) |
715 | L.ECApp ( | |
716 (L.ECApp ( | |
717 (L.ECApp ( | |
718 (L.EFfi ("Basis", "sql_order_by_Cons"), _), | |
719 _), _), | |
720 _), _), | |
721 _) => | |
722 let | |
723 val s = (L'.TFfi ("Basis", "string"), loc) | |
724 fun sc s = (L'.EPrim (Prim.String s), loc) | |
725 in | |
726 ((L'.EAbs ("e1", s, (L'.TFun (s, s), loc), | |
727 (L'.EAbs ("e2", s, s, | |
728 (L'.ECase ((L'.ERel 0, loc), | |
729 [((L'.PPrim (Prim.String ""), loc), | |
730 (L'.ERel 1, loc)), | |
731 ((L'.PWild, loc), | |
732 strcat loc [(L'.ERel 1, loc), | |
733 sc ", ", | |
734 (L'.ERel 0, loc), | |
735 sc ")"])], | |
736 {disc = s, result = s}), loc)), loc)), loc), | |
737 fm) | |
738 end | |
706 | 739 |
707 | L.EFfi ("Basis", "sql_no_limit") => | 740 | L.EFfi ("Basis", "sql_no_limit") => |
708 ((L'.EPrim (Prim.String ""), loc), fm) | 741 ((L'.EPrim (Prim.String ""), loc), fm) |
709 | L.EFfi ("Basis", "sql_no_offset") => | 742 | L.EFfi ("Basis", "sql_no_offset") => |
710 ((L'.EPrim (Prim.String ""), loc), fm) | 743 ((L'.EPrim (Prim.String ""), loc), fm) |
793 _), _), | 826 _), _), |
794 _), _), | 827 _), _), |
795 _), _), | 828 _), _), |
796 (L.CName tab, _)), _), | 829 (L.CName tab, _)), _), |
797 (L.CName field, _)) => ((L'.EPrim (Prim.String (tab ^ "." ^ field)), loc), fm) | 830 (L.CName field, _)) => ((L'.EPrim (Prim.String (tab ^ "." ^ field)), loc), fm) |
831 | |
832 | L.ECApp ( | |
833 (L.ECApp ( | |
834 (L.ECApp ( | |
835 (L.ECApp ( | |
836 (L.ECApp ( | |
837 (L.EFfi ("Basis", "sql_exp"), _), | |
838 _), _), | |
839 _), _), | |
840 _), _), | |
841 _), _), | |
842 (L.CName nm, _)) => ((L'.EPrim (Prim.String ("_" ^ nm)), loc), fm) | |
798 | 843 |
799 | L.ECApp ( | 844 | L.ECApp ( |
800 (L.ECApp ( | 845 (L.ECApp ( |
801 (L.ECApp ( | 846 (L.ECApp ( |
802 (L.ECApp ( | 847 (L.ECApp ( |