comparison 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
comparison
equal deleted inserted replaced
748:5f9b9972e6b8 749:16bfd9e244cd
211 | ASC | DESC 211 | ASC | DESC
212 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS 212 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS
213 | CURRENT_TIMESTAMP 213 | CURRENT_TIMESTAMP
214 | NE | LT | LE | GT | GE 214 | NE | LT | LE | GT | GE
215 | CCONSTRAINT | UNIQUE | CHECK | PRIMARY | FOREIGN | KEY | ON | NO | ACTION | RESTRICT | CASCADE | REFERENCES 215 | CCONSTRAINT | UNIQUE | CHECK | PRIMARY | FOREIGN | KEY | ON | NO | ACTION | RESTRICT | CASCADE | REFERENCES
216 | JOIN | INNER | CROSS
216 217
217 %nonterm 218 %nonterm
218 file of decl list 219 file of decl list
219 | decls of decl list 220 | decls of decl list
220 | decl of decl list 221 | decl of decl list
303 | attrv of exp 304 | attrv of exp
304 305
305 | query of exp 306 | query of exp
306 | query1 of exp 307 | query1 of exp
307 | tables of con list * exp 308 | tables of con list * exp
309 | fitem of con list * exp
308 | tname of con 310 | tname of con
309 | tnameW of con * con 311 | tnameW of con * con
310 | tnames of (con * con) * (con * con) list 312 | tnames of (con * con) * (con * con) list
311 | tnames' of (con * con) * (con * con) list 313 | tnames' of (con * con) * (con * con) list
312 | table of con * exp 314 | table of con * exp
357 %nonassoc DARROW 359 %nonassoc DARROW
358 %nonassoc COLON 360 %nonassoc COLON
359 %nonassoc DCOLON TCOLON 361 %nonassoc DCOLON TCOLON
360 %left UNION INTERSECT EXCEPT 362 %left UNION INTERSECT EXCEPT
361 %right COMMA 363 %right COMMA
364 %right JOIN INNER CROSS
362 %right OR 365 %right OR
363 %right CAND 366 %right CAND
364 %nonassoc EQ NE LT LE GT GE IS 367 %nonassoc EQ NE LT LE GT GE IS
365 %right ARROW 368 %right ARROW
366 %right CARET PLUSPLUS MINUSMINUS MINUSMINUSMINUS 369 %right CARET PLUSPLUS MINUSMINUS MINUSMINUSMINUS
1420 end) 1423 end)
1421 | query1 UNION query1 (sql_relop ("union", query11, query12, s (query11left, query12right))) 1424 | query1 UNION query1 (sql_relop ("union", query11, query12, s (query11left, query12right)))
1422 | query1 INTERSECT query1 (sql_relop ("intersect", query11, query12, s (query11left, query12right))) 1425 | query1 INTERSECT query1 (sql_relop ("intersect", query11, query12, s (query11left, query12right)))
1423 | query1 EXCEPT query1 (sql_relop ("except", query11, query12, s (query11left, query12right))) 1426 | query1 EXCEPT query1 (sql_relop ("except", query11, query12, s (query11left, query12right)))
1424 1427
1425 tables : table' ([#1 table'], #2 table') 1428 tables : fitem (fitem)
1426 | table' COMMA tables (let 1429 | fitem COMMA tables (let
1427 val loc = s (table'left, tablesright) 1430 val loc = s (fitemleft, tablesright)
1428 1431
1429 val e = (EVar (["Basis"], "sql_from_comma", Infer), loc) 1432 val e = (EVar (["Basis"], "sql_from_comma", Infer), loc)
1430 val e = (EApp (e, #2 table'), loc) 1433 val e = (EApp (e, #2 fitem), loc)
1431 in 1434 in
1432 (#1 table' :: #1 tables, 1435 (#1 fitem @ #1 tables,
1433 (EApp (e, #2 tables), loc)) 1436 (EApp (e, #2 tables), loc))
1437 end)
1438
1439 fitem : table' ([#1 table'], #2 table')
1440 | fitem JOIN fitem ON sqlexp (let
1441 val loc = s (fitem1left, sqlexpright)
1442
1443 val e = (EVar (["Basis"], "sql_inner_join", Infer), loc)
1444 val e = (EApp (e, #2 fitem1), loc)
1445 val e = (EApp (e, #2 fitem2), loc)
1446 in
1447 (#1 fitem1 @ #1 fitem2,
1448 (EApp (e, sqlexp), loc))
1449 end)
1450 | fitem INNER JOIN fitem ON sqlexp (let
1451 val loc = s (fitem1left, sqlexpright)
1452
1453 val e = (EVar (["Basis"], "sql_inner_join", Infer), loc)
1454 val e = (EApp (e, #2 fitem1), loc)
1455 val e = (EApp (e, #2 fitem2), loc)
1456 in
1457 (#1 fitem1 @ #1 fitem2,
1458 (EApp (e, sqlexp), loc))
1459 end)
1460 | fitem CROSS JOIN fitem (let
1461 val loc = s (fitem1left, fitem2right)
1462
1463 val e = (EVar (["Basis"], "sql_inner_join", Infer), loc)
1464 val e = (EApp (e, #2 fitem1), loc)
1465 val e = (EApp (e, #2 fitem2), loc)
1466 val tru = sql_inject (EVar (["Basis"], "True", Infer), loc)
1467 in
1468 (#1 fitem1 @ #1 fitem2,
1469 (EApp (e, tru), loc))
1434 end) 1470 end)
1435 1471
1436 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) 1472 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
1437 | LBRACE cexp RBRACE (cexp) 1473 | LBRACE cexp RBRACE (cexp)
1438 1474