comparison src/monoize.sml @ 1195:aff5e661b5f8

Make SELECT FROM clauses optional
author Adam Chlipala <adamc@hcoop.net>
date Sun, 28 Mar 2010 10:10:35 -0400
parents 9c82548c97e9
children 134da5110bf7
comparison
equal deleted inserted replaced
1194:601a77af0477 1195:aff5e661b5f8
1889 (map (fn (x', _) => 1889 (map (fn (x', _) =>
1890 sc ("T_" ^ x 1890 sc ("T_" ^ x
1891 ^ ".uw_" 1891 ^ ".uw_"
1892 ^ x')) 1892 ^ x'))
1893 xts)) stables), 1893 xts)) stables),
1894 sc " FROM ", 1894 (L'.ECase (gf "From",
1895 gf "From", 1895 [((L'.PPrim (Prim.String ""), loc),
1896 sc ""),
1897 ((L'.PVar ("x", s), loc),
1898 strcat [sc " FROM ",
1899 (L'.ERel 0, loc)])],
1900 {disc = s,
1901 result = s}), loc),
1896 (L'.ECase (gf "Where", 1902 (L'.ECase (gf "Where",
1897 [((L'.PPrim (Prim.String "TRUE"), loc), 1903 [((L'.PPrim (Prim.String "TRUE"), loc),
1898 sc ""), 1904 sc ""),
1899 ((L'.PWild, loc), 1905 ((L'.PWild, loc),
1900 strcat [sc " WHERE ", gf "Where"])], 1906 strcat [sc " WHERE ", gf "Where"])],
2046 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "fieldsOf_table"), _), _), _), _) => 2052 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "fieldsOf_table"), _), _), _), _) =>
2047 ((L'.ERecord [], loc), fm) 2053 ((L'.ERecord [], loc), fm)
2048 | L.ECApp ((L.EFfi ("Basis", "fieldsOf_view"), _), _) => 2054 | L.ECApp ((L.EFfi ("Basis", "fieldsOf_view"), _), _) =>
2049 ((L'.ERecord [], loc), fm) 2055 ((L'.ERecord [], loc), fm)
2050 2056
2057 | L.ECApp ((L.EFfi ("Basis", "sql_from_nil"), _), _) =>
2058 ((L'.EPrim (Prim.String ""), loc), fm)
2051 | L.ECApp ((L.EApp ((L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_from_table"), _), _), 2059 | L.ECApp ((L.EApp ((L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_from_table"), _), _),
2052 _), _), _), _), _), _), _), 2060 _), _), _), _), _), _), _),
2053 (L.CName name, _)) => 2061 (L.CName name, _)) =>
2054 let 2062 let
2055 val s = (L'.TFfi ("Basis", "string"), loc) 2063 val s = (L'.TFfi ("Basis", "string"), loc)
2076 let 2084 let
2077 val s = (L'.TFfi ("Basis", "string"), loc) 2085 val s = (L'.TFfi ("Basis", "string"), loc)
2078 in 2086 in
2079 ((L'.EAbs ("tab1", s, (L'.TFun (s, s), loc), 2087 ((L'.EAbs ("tab1", s, (L'.TFun (s, s), loc),
2080 (L'.EAbs ("tab2", s, s, 2088 (L'.EAbs ("tab2", s, s,
2081 strcat [(L'.ERel 1, loc), 2089 (L'.ECase ((L'.ERecord [("1", (L'.ERel 1, loc), s),
2082 (L'.EPrim (Prim.String ", "), loc), 2090 ("2", (L'.ERel 0, loc), s)], loc),
2083 (L'.ERel 0, loc)]), loc)), loc), 2091 [((L'.PRecord [("1", (L'.PPrim (Prim.String ""), loc), s)], loc),
2092 (L'.ERel 0, loc)),
2093 ((L'.PRecord [("2", (L'.PPrim (Prim.String ""), loc), s)], loc),
2094 (L'.ERel 1, loc)),
2095 ((L'.PWild, loc),
2096 strcat [(L'.ERel 1, loc),
2097 (L'.EPrim (Prim.String ", "), loc),
2098 (L'.ERel 0, loc)])],
2099 {disc = (L'.TRecord [("1", s), ("2", s)], loc),
2100 result = s}), loc)), loc)), loc),
2084 fm) 2101 fm)
2085 end 2102 end
2086 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_inner_join"), _), _), _), _), _), _) => 2103 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_inner_join"), _), _), _), _), _), _) =>
2087 let 2104 let
2088 val s = (L'.TFfi ("Basis", "string"), loc) 2105 val s = (L'.TFfi ("Basis", "string"), loc)
2089 in 2106 in
2090 ((L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), 2107 ((L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
2091 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc), 2108 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc),
2092 (L'.EAbs ("on", s, s, 2109 (L'.EAbs ("on", s, s,
2093 strcat [(L'.EPrim (Prim.String "("), loc), 2110 (L'.ECase ((L'.ERecord [("1", (L'.ERel 2, loc), s),
2094 (L'.ERel 2, loc), 2111 ("2", (L'.ERel 1, loc), s)], loc),
2095 (L'.EPrim (Prim.String " JOIN "), loc), 2112 [((L'.PRecord [("1", (L'.PPrim (Prim.String ""), loc), s)], loc),
2096 (L'.ERel 1, loc), 2113 (L'.ERel 1, loc)),
2097 (L'.EPrim (Prim.String " ON "), loc), 2114 ((L'.PRecord [("2", (L'.PPrim (Prim.String ""), loc), s)], loc),
2098 (L'.ERel 0, loc), 2115 (L'.ERel 2, loc)),
2099 (L'.EPrim (Prim.String ")"), loc)]), loc)), loc)), loc), 2116 ((L'.PWild, loc),
2117 strcat [(L'.EPrim (Prim.String "("), loc),
2118 (L'.ERel 2, loc),
2119 (L'.EPrim (Prim.String " JOIN "), loc),
2120 (L'.ERel 1, loc),
2121 (L'.EPrim (Prim.String " ON "), loc),
2122 (L'.ERel 0, loc),
2123 (L'.EPrim (Prim.String ")"), loc)])],
2124 {disc = (L'.TRecord [("1", s), ("2", s)], loc),
2125 result = s}), loc)), loc)), loc)), loc),
2100 fm) 2126 fm)
2101 end 2127 end
2102 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_left_join"), _), _), _), _), _), 2128 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_left_join"), _), _), _), _), _),
2103 (L.CRecord (_, right), _)) => 2129 (L.CRecord (_, right), _)) =>
2104 let 2130 let
2107 ((L'.EAbs ("_", outerRec right, 2133 ((L'.EAbs ("_", outerRec right,
2108 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc), 2134 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc),
2109 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), 2135 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
2110 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc), 2136 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc),
2111 (L'.EAbs ("on", s, s, 2137 (L'.EAbs ("on", s, s,
2112 strcat [(L'.EPrim (Prim.String "("), loc), 2138 (L'.ECase ((L'.ERecord [("1", (L'.ERel 2, loc), s),
2113 (L'.ERel 2, loc), 2139 ("2", (L'.ERel 1, loc), s)], loc),
2114 (L'.EPrim (Prim.String " LEFT JOIN "), loc), 2140 [((L'.PRecord [("1", (L'.PPrim (Prim.String ""),
2115 (L'.ERel 1, loc), 2141 loc), s)], loc),
2116 (L'.EPrim (Prim.String " ON "), loc), 2142 (L'.ERel 1, loc)),
2117 (L'.ERel 0, loc), 2143 ((L'.PRecord [("2", (L'.PPrim (Prim.String ""),
2118 (L'.EPrim (Prim.String ")"), loc)]), 2144 loc), s)], loc),
2119 loc)), loc)), loc)), loc), 2145 (L'.ERel 2, loc)),
2146 ((L'.PWild, loc),
2147 strcat [(L'.EPrim (Prim.String "("), loc),
2148 (L'.ERel 2, loc),
2149 (L'.EPrim (Prim.String " LEFT JOIN "), loc),
2150 (L'.ERel 1, loc),
2151 (L'.EPrim (Prim.String " ON "), loc),
2152 (L'.ERel 0, loc),
2153 (L'.EPrim (Prim.String ")"), loc)])],
2154 {disc = (L'.TRecord [("1", s), ("2", s)], loc),
2155 result = s}), loc)), loc)), loc)), loc)), loc),
2120 fm) 2156 fm)
2121 end 2157 end
2122 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_right_join"), _), (L.CRecord (_, left), _)), 2158 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_right_join"), _), (L.CRecord (_, left), _)),
2123 _), _), _), _) => 2159 _), _), _), _) =>
2124 let 2160 let
2127 ((L'.EAbs ("_", outerRec left, 2163 ((L'.EAbs ("_", outerRec left,
2128 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc), 2164 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc),
2129 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), 2165 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
2130 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc), 2166 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc),
2131 (L'.EAbs ("on", s, s, 2167 (L'.EAbs ("on", s, s,
2132 strcat [(L'.EPrim (Prim.String "("), loc), 2168 (L'.ECase ((L'.ERecord [("1", (L'.ERel 2, loc), s),
2133 (L'.ERel 2, loc), 2169 ("2", (L'.ERel 1, loc), s)], loc),
2134 (L'.EPrim (Prim.String " RIGHT JOIN "), loc), 2170 [((L'.PRecord [("1", (L'.PPrim (Prim.String ""),
2135 (L'.ERel 1, loc), 2171 loc), s)], loc),
2136 (L'.EPrim (Prim.String " ON "), loc), 2172 (L'.ERel 1, loc)),
2137 (L'.ERel 0, loc), 2173 ((L'.PRecord [("2", (L'.PPrim (Prim.String ""),
2138 (L'.EPrim (Prim.String ")"), loc)]), 2174 loc), s)], loc),
2139 loc)), loc)), loc)), loc), 2175 (L'.ERel 2, loc)),
2176 ((L'.PWild, loc),
2177 strcat [(L'.EPrim (Prim.String "("), loc),
2178 (L'.ERel 2, loc),
2179 (L'.EPrim (Prim.String " RIGHT JOIN "), loc),
2180 (L'.ERel 1, loc),
2181 (L'.EPrim (Prim.String " ON "), loc),
2182 (L'.ERel 0, loc),
2183 (L'.EPrim (Prim.String ")"), loc)])],
2184 {disc = (L'.TRecord [("1", s), ("2", s)], loc),
2185 result = s}), loc)), loc)), loc)), loc)), loc),
2140 fm) 2186 fm)
2141 end 2187 end
2142 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_full_join"), _), (L.CRecord (_, left), _)), _), 2188 | L.ECApp ((L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_full_join"), _), (L.CRecord (_, left), _)), _),
2143 (L.CRecord (_, right), _)), _), _) => 2189 (L.CRecord (_, right), _)), _), _) =>
2144 let 2190 let
2147 ((L'.EAbs ("_", outerRec (left @ right), 2193 ((L'.EAbs ("_", outerRec (left @ right),
2148 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc), 2194 (L'.TFun (s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc)), loc),
2149 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), 2195 (L'.EAbs ("tab1", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
2150 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc), 2196 (L'.EAbs ("tab2", s, (L'.TFun (s, s), loc),
2151 (L'.EAbs ("on", s, s, 2197 (L'.EAbs ("on", s, s,
2152 strcat [(L'.EPrim (Prim.String "("), loc), 2198 (L'.ECase ((L'.ERecord [("1", (L'.ERel 2, loc), s),
2153 (L'.ERel 2, loc), 2199 ("2", (L'.ERel 1, loc), s)], loc),
2154 (L'.EPrim (Prim.String " FULL JOIN "), loc), 2200 [((L'.PRecord [("1", (L'.PPrim (Prim.String ""),
2155 (L'.ERel 1, loc), 2201 loc), s)], loc),
2156 (L'.EPrim (Prim.String " ON "), loc), 2202 (L'.ERel 1, loc)),
2157 (L'.ERel 0, loc), 2203 ((L'.PRecord [("2", (L'.PPrim (Prim.String ""),
2158 (L'.EPrim (Prim.String ")"), loc)]), 2204 loc), s)], loc),
2159 loc)), loc)), loc)), loc), 2205 (L'.ERel 2, loc)),
2206 ((L'.PWild, loc),
2207 strcat [(L'.EPrim (Prim.String "("), loc),
2208 (L'.ERel 2, loc),
2209 (L'.EPrim (Prim.String " FULL JOIN "), loc),
2210 (L'.ERel 1, loc),
2211 (L'.EPrim (Prim.String " ON "), loc),
2212 (L'.ERel 0, loc),
2213 (L'.EPrim (Prim.String ")"), loc)])],
2214 {disc = (L'.TRecord [("1", s), ("2", s)], loc),
2215 result = s}), loc)), loc)), loc)), loc)), loc),
2160 fm) 2216 fm)
2161 end 2217 end
2162 2218
2163 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_order_by_Nil"), _), _), _), _) => 2219 | L.ECApp ((L.ECApp ((L.EFfi ("Basis", "sql_order_by_Nil"), _), _), _), _) =>
2164 ((L'.EPrim (Prim.String ""), loc), fm) 2220 ((L'.EPrim (Prim.String ""), loc), fm)