Mercurial > urweb
comparison src/lacweb.grm @ 220:2b665e822e9a
SQL boolean operators
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 16 Aug 2008 17:35:28 -0400 |
parents | 5292c0113024 |
children | 79819a6346e2 |
comparison
equal
deleted
inserted
replaced
219:5292c0113024 | 220:2b665e822e9a |
---|---|
84 val e = (EVar (["Basis"], "sql_comparison"), loc) | 84 val e = (EVar (["Basis"], "sql_comparison"), loc) |
85 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) | 85 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) |
86 val e = (EApp (e, sqlexp1), loc) | 86 val e = (EApp (e, sqlexp1), loc) |
87 val e = (EApp (e, sqlexp2), loc) | 87 val e = (EApp (e, sqlexp2), loc) |
88 in | 88 in |
89 (EApp (e, (EWild, loc)), loc) | 89 (EApp (e, (EWild, loc)), loc) |
90 end | |
91 | |
92 fun sql_binary (oper, sqlexp1, sqlexp2, loc) = | |
93 let | |
94 val e = (EVar (["Basis"], "sql_binary"), loc) | |
95 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) | |
96 val e = (EApp (e, sqlexp1), loc) | |
97 in | |
98 (EApp (e, sqlexp2), loc) | |
99 end | |
100 | |
101 fun sql_unary (oper, sqlexp, loc) = | |
102 let | |
103 val e = (EVar (["Basis"], "sql_unary"), loc) | |
104 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) | |
105 in | |
106 (EApp (e, sqlexp), loc) | |
90 end | 107 end |
91 | 108 |
92 %% | 109 %% |
93 %header (functor LacwebLrValsFn(structure Token : TOKEN)) | 110 %header (functor LacwebLrValsFn(structure Token : TOKEN)) |
94 | 111 |
111 | XML_BEGIN of string | XML_END | 128 | XML_BEGIN of string | XML_END |
112 | NOTAGS of string | 129 | NOTAGS of string |
113 | BEGIN_TAG of string | END_TAG of string | 130 | BEGIN_TAG of string | END_TAG of string |
114 | 131 |
115 | SELECT | FROM | AS | CWHERE | 132 | SELECT | FROM | AS | CWHERE |
116 | TRUE | FALSE | 133 | TRUE | FALSE | CAND | OR | NOT |
117 | NE | LT | LE | GT | GE | 134 | NE | LT | LE | GT | GE |
118 | 135 |
119 %nonterm | 136 %nonterm |
120 file of decl list | 137 file of decl list |
121 | decls of decl list | 138 | decls of decl list |
201 %nonassoc IF THEN ELSE | 218 %nonassoc IF THEN ELSE |
202 %nonassoc DARROW | 219 %nonassoc DARROW |
203 %nonassoc COLON | 220 %nonassoc COLON |
204 %nonassoc DCOLON TCOLON | 221 %nonassoc DCOLON TCOLON |
205 %right COMMA | 222 %right COMMA |
223 %right OR | |
224 %right CAND | |
206 %nonassoc EQ NE LT LE GT GE | 225 %nonassoc EQ NE LT LE GT GE |
207 %right ARROW LARROW | 226 %right ARROW LARROW |
208 %right PLUSPLUS MINUSMINUS | 227 %right PLUSPLUS MINUSMINUS |
209 %right STAR | 228 %right STAR |
229 %left NOT | |
210 %nonassoc TWIDDLE | 230 %nonassoc TWIDDLE |
211 %nonassoc DOLLAR | 231 %nonassoc DOLLAR |
212 %left DOT | 232 %left DOT |
213 | 233 |
214 %% | 234 %% |
668 | sqlexp LT sqlexp (sql_compare ("lt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | 688 | sqlexp LT sqlexp (sql_compare ("lt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) |
669 | sqlexp LE sqlexp (sql_compare ("le", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | 689 | sqlexp LE sqlexp (sql_compare ("le", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) |
670 | sqlexp GT sqlexp (sql_compare ("gt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | 690 | sqlexp GT sqlexp (sql_compare ("gt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) |
671 | sqlexp GE sqlexp (sql_compare ("ge", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | 691 | sqlexp GE sqlexp (sql_compare ("ge", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) |
672 | 692 |
693 | sqlexp CAND sqlexp (sql_binary ("and", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | |
694 | sqlexp OR sqlexp (sql_binary ("or", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right))) | |
695 | NOT sqlexp (sql_unary ("not", sqlexp, s (NOTleft, sqlexpright))) | |
696 | |
673 | LBRACE eexp RBRACE (sql_inject (#1 eexp, | 697 | LBRACE eexp RBRACE (sql_inject (#1 eexp, |
674 EWild, | 698 EWild, |
675 s (LBRACEleft, RBRACEright))) | 699 s (LBRACEleft, RBRACEright))) |
700 | LPAREN sqlexp RPAREN (sqlexp) | |
676 | 701 |
677 wopt : (sql_inject (EVar (["Basis"], "True"), | 702 wopt : (sql_inject (EVar (["Basis"], "True"), |
678 EVar (["Basis"], "sql_bool"), | 703 EVar (["Basis"], "sql_bool"), |
679 ErrorMsg.dummySpan)) | 704 ErrorMsg.dummySpan)) |
680 | CWHERE sqlexp (sqlexp) | 705 | CWHERE sqlexp (sqlexp) |