Mercurial > urweb
comparison src/urweb.grm @ 1425:139d019c7237
Syntactic sugar for grouping by variable numbers of columns
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 17 Feb 2011 18:05:08 -0500 |
parents | 7f6ac9f33d4d |
children | 541673c3161d |
comparison
equal
deleted
inserted
replaced
1424:7f6ac9f33d4d | 1425:139d019c7237 |
---|---|
49 Star | 49 Star |
50 | Items of select_item list | 50 | Items of select_item list |
51 | 51 |
52 datatype group_item = | 52 datatype group_item = |
53 GField of con * con | 53 GField of con * con |
54 | GFields of con * con | |
54 | 55 |
55 fun eqTnames ((c1, _), (c2, _)) = | 56 fun eqTnames ((c1, _), (c2, _)) = |
56 case (c1, c2) of | 57 case (c1, c2) of |
57 (CVar (ms1, x1), CVar (ms2, x2)) => ms1 = ms2 andalso x1 = x2 | 58 (CVar (ms1, x1), CVar (ms2, x2)) => ms1 = ms2 andalso x1 = x2 |
58 | (CName x1, CName x2) => x1 = x2 | 59 | (CName x1, CName x2) => x1 = x2 |
105 | 106 |
106 fun amend_group loc (gi, tabs) = | 107 fun amend_group loc (gi, tabs) = |
107 let | 108 let |
108 val (tx, c) = case gi of | 109 val (tx, c) = case gi of |
109 GField (tx, fx) => (tx, (CRecord ([(fx, (CWild (KType, loc), loc))]), loc)) | 110 GField (tx, fx) => (tx, (CRecord ([(fx, (CWild (KType, loc), loc))]), loc)) |
111 | GFields (tx, fxs) => (tx, fxs) | |
110 | 112 |
111 val (tabs, found) = ListUtil.foldlMap (fn ((tx', c'), found) => | 113 val (tabs, found) = ListUtil.foldlMap (fn ((tx', c'), found) => |
112 if eqTnames (tx, tx') then | 114 if eqTnames (tx, tx') then |
113 ((tx', (CConcat (c, c'), loc)), true) | 115 ((tx', (CConcat (c, c'), loc)), true) |
114 else | 116 else |
115 ((tx', c'), found)) | 117 ((tx', c'), found)) |
116 false tabs | 118 false tabs |
117 in | 119 in |
118 if found then | 120 if found then |
119 () | 121 () |
120 else | 122 else |
121 ErrorMsg.errorAt loc "Select of field from unbound table"; | 123 ErrorMsg.errorAt loc "Select of field from unbound table"; |
1869 wopt : (sql_inject (EVar (["Basis"], "True", Infer), | 1871 wopt : (sql_inject (EVar (["Basis"], "True", Infer), |
1870 dummy)) | 1872 dummy)) |
1871 | CWHERE sqlexp (sqlexp) | 1873 | CWHERE sqlexp (sqlexp) |
1872 | 1874 |
1873 groupi : tident DOT fident (GField (tident, fident)) | 1875 groupi : tident DOT fident (GField (tident, fident)) |
1876 | tident DOT LBRACE LBRACE cexp RBRACE RBRACE (GFields (tident, cexp)) | |
1874 | 1877 |
1875 groupis: groupi ([groupi]) | 1878 groupis: groupi ([groupi]) |
1876 | groupi COMMA groupis (groupi :: groupis) | 1879 | groupi COMMA groupis (groupi :: groupis) |
1877 | 1880 |
1878 gopt : (NONE) | 1881 gopt : (NONE) |