Mercurial > urweb
diff src/urweb.grm @ 749:16bfd9e244cd
INNER JOIN
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 28 Apr 2009 10:11:56 -0400 |
parents | 5f9b9972e6b8 |
children | 059074c8d2fc |
line wrap: on
line diff
--- a/src/urweb.grm Tue Apr 28 09:45:17 2009 -0400 +++ b/src/urweb.grm Tue Apr 28 10:11:56 2009 -0400 @@ -213,6 +213,7 @@ | CURRENT_TIMESTAMP | NE | LT | LE | GT | GE | CCONSTRAINT | UNIQUE | CHECK | PRIMARY | FOREIGN | KEY | ON | NO | ACTION | RESTRICT | CASCADE | REFERENCES + | JOIN | INNER | CROSS %nonterm file of decl list @@ -305,6 +306,7 @@ | query of exp | query1 of exp | tables of con list * exp + | fitem of con list * exp | tname of con | tnameW of con * con | tnames of (con * con) * (con * con) list @@ -359,6 +361,7 @@ %nonassoc DCOLON TCOLON %left UNION INTERSECT EXCEPT %right COMMA +%right JOIN INNER CROSS %right OR %right CAND %nonassoc EQ NE LT LE GT GE IS @@ -1422,17 +1425,50 @@ | query1 INTERSECT query1 (sql_relop ("intersect", query11, query12, s (query11left, query12right))) | query1 EXCEPT query1 (sql_relop ("except", query11, query12, s (query11left, query12right))) -tables : table' ([#1 table'], #2 table') - | table' COMMA tables (let - val loc = s (table'left, tablesright) +tables : fitem (fitem) + | fitem COMMA tables (let + val loc = s (fitemleft, tablesright) val e = (EVar (["Basis"], "sql_from_comma", Infer), loc) - val e = (EApp (e, #2 table'), loc) + val e = (EApp (e, #2 fitem), loc) in - (#1 table' :: #1 tables, + (#1 fitem @ #1 tables, (EApp (e, #2 tables), loc)) end) +fitem : table' ([#1 table'], #2 table') + | fitem JOIN fitem ON sqlexp (let + val loc = s (fitem1left, sqlexpright) + + val e = (EVar (["Basis"], "sql_inner_join", Infer), loc) + val e = (EApp (e, #2 fitem1), loc) + val e = (EApp (e, #2 fitem2), loc) + in + (#1 fitem1 @ #1 fitem2, + (EApp (e, sqlexp), loc)) + end) + | fitem INNER JOIN fitem ON sqlexp (let + val loc = s (fitem1left, sqlexpright) + + val e = (EVar (["Basis"], "sql_inner_join", Infer), loc) + val e = (EApp (e, #2 fitem1), loc) + val e = (EApp (e, #2 fitem2), loc) + in + (#1 fitem1 @ #1 fitem2, + (EApp (e, sqlexp), loc)) + end) + | fitem CROSS JOIN fitem (let + val loc = s (fitem1left, fitem2right) + + val e = (EVar (["Basis"], "sql_inner_join", Infer), loc) + val e = (EApp (e, #2 fitem1), loc) + val e = (EApp (e, #2 fitem2), loc) + val tru = sql_inject (EVar (["Basis"], "True", Infer), loc) + in + (#1 fitem1 @ #1 fitem2, + (EApp (e, tru), loc)) + end) + tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) | LBRACE cexp RBRACE (cexp)