Mercurial > urweb
comparison src/lacweb.grm @ 229:016d71e878c1
Relational operators; string literals for SQL
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 21 Aug 2008 15:27:04 -0400 |
parents | 524e10c91478 |
children | 87d41ac28b30 |
comparison
equal
deleted
inserted
replaced
228:19e5791923d0 | 229:016d71e878c1 |
---|---|
127 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) | 127 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) |
128 in | 128 in |
129 (EApp (e, sqlexp), loc) | 129 (EApp (e, sqlexp), loc) |
130 end | 130 end |
131 | 131 |
132 fun sql_relop (oper, sqlexp1, sqlexp2, loc) = | |
133 let | |
134 val e = (EVar (["Basis"], "sql_relop"), loc) | |
135 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) | |
136 val e = (EApp (e, sqlexp1), loc) | |
137 in | |
138 (EApp (e, sqlexp2), loc) | |
139 end | |
140 | |
132 %% | 141 %% |
133 %header (functor LacwebLrValsFn(structure Token : TOKEN)) | 142 %header (functor LacwebLrValsFn(structure Token : TOKEN)) |
134 | 143 |
135 %term | 144 %term |
136 EOF | 145 EOF |
151 | XML_BEGIN of string | XML_END | 160 | XML_BEGIN of string | XML_END |
152 | NOTAGS of string | 161 | NOTAGS of string |
153 | BEGIN_TAG of string | END_TAG of string | 162 | BEGIN_TAG of string | END_TAG of string |
154 | 163 |
155 | SELECT | FROM | AS | CWHERE | GROUP | BY | HAVING | 164 | SELECT | FROM | AS | CWHERE | GROUP | BY | HAVING |
165 | UNION | INTERSECT | EXCEPT | |
156 | TRUE | FALSE | CAND | OR | NOT | 166 | TRUE | FALSE | CAND | OR | NOT |
157 | NE | LT | LE | GT | GE | 167 | NE | LT | LE | GT | GE |
158 | 168 |
159 %nonterm | 169 %nonterm |
160 file of decl list | 170 file of decl list |
245 | 255 |
246 %nonassoc IF THEN ELSE | 256 %nonassoc IF THEN ELSE |
247 %nonassoc DARROW | 257 %nonassoc DARROW |
248 %nonassoc COLON | 258 %nonassoc COLON |
249 %nonassoc DCOLON TCOLON | 259 %nonassoc DCOLON TCOLON |
260 %left UNION INTERSECT EXCEPT | |
250 %right COMMA | 261 %right COMMA |
251 %right OR | 262 %right OR |
252 %right CAND | 263 %right CAND |
253 %nonassoc EQ NE LT LE GT GE | 264 %nonassoc EQ NE LT LE GT GE |
254 %right ARROW LARROW | 265 %right ARROW LARROW |
642 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) | 653 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) |
643 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) | 654 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright)) |
644 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) | 655 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) |
645 | LBRACE eexp RBRACE (eexp) | 656 | LBRACE eexp RBRACE (eexp) |
646 | 657 |
647 query : query1 (query1) | 658 query : query1 (let |
659 val loc = s (query1left, query1right) | |
660 in | |
661 (EApp ((EVar (["Basis"], "sql_query"), loc), query1), loc) | |
662 end) | |
648 | 663 |
649 query1 : SELECT select FROM tables wopt gopt hopt | 664 query1 : SELECT select FROM tables wopt gopt hopt |
650 (let | 665 (let |
651 val loc = s (SELECTleft, tablesright) | 666 val loc = s (SELECTleft, tablesright) |
652 | 667 |
689 in | 704 in |
690 (ECApp ((EVar (["Basis"], "sql_subset"), loc), | 705 (ECApp ((EVar (["Basis"], "sql_subset"), loc), |
691 (CRecord tabs, loc)), loc) | 706 (CRecord tabs, loc)), loc) |
692 end | 707 end |
693 | 708 |
694 val e = (EVar (["Basis"], "sql_query"), loc) | 709 val e = (EVar (["Basis"], "sql_query1"), loc) |
695 val re = (ERecord [((CName "From", loc), | 710 val re = (ERecord [((CName "From", loc), |
696 (ERecord tables, loc)), | 711 (ERecord tables, loc)), |
697 ((CName "Where", loc), | 712 ((CName "Where", loc), |
698 wopt), | 713 wopt), |
699 ((CName "GroupBy", loc), | 714 ((CName "GroupBy", loc), |
706 | 721 |
707 val e = (EApp (e, re), loc) | 722 val e = (EApp (e, re), loc) |
708 in | 723 in |
709 e | 724 e |
710 end) | 725 end) |
726 | query1 UNION query1 (sql_relop ("union", query11, query12, s (query11left, query12right))) | |
727 | query1 INTERSECT query1 (sql_relop ("intersect", query11, query12, s (query11left, query12right))) | |
728 | query1 EXCEPT query1 (sql_relop ("except", query11, query12, s (query11left, query12right))) | |
711 | 729 |
712 tables : table ([table]) | 730 tables : table ([table]) |
713 | table COMMA tables (table :: tables) | 731 | table COMMA tables (table :: tables) |
714 | 732 |
715 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) | 733 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright)) |
746 EVar (["Basis"], "sql_int"), | 764 EVar (["Basis"], "sql_int"), |
747 s (INTleft, INTright))) | 765 s (INTleft, INTright))) |
748 | FLOAT (sql_inject (EPrim (Prim.Float FLOAT), | 766 | FLOAT (sql_inject (EPrim (Prim.Float FLOAT), |
749 EVar (["Basis"], "sql_float"), | 767 EVar (["Basis"], "sql_float"), |
750 s (FLOATleft, FLOATright))) | 768 s (FLOATleft, FLOATright))) |
769 | STRING (sql_inject (EPrim (Prim.String STRING), | |
770 EVar (["Basis"], "sql_string"), | |
771 s (STRINGleft, STRINGright))) | |
751 | 772 |
752 | tident DOT fident (let | 773 | tident DOT fident (let |
753 val loc = s (tidentleft, fidentright) | 774 val loc = s (tidentleft, fidentright) |
754 val e = (EVar (["Basis"], "sql_field"), loc) | 775 val e = (EVar (["Basis"], "sql_field"), loc) |
755 val e = (ECApp (e, tident), loc) | 776 val e = (ECApp (e, tident), loc) |