annotate 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
rev   line source
adamc@1 1 (* Copyright (c) 2008, Adam Chlipala
adamc@1 2 * All rights reserved.
adamc@1 3 *
adamc@1 4 * Redistribution and use in source and binary forms, with or without
adamc@1 5 * modification, are permitted provided that the following conditions are met:
adamc@1 6 *
adamc@1 7 * - Redistributions of source code must retain the above copyright notice,
adamc@1 8 * this list of conditions and the following disclaimer.
adamc@1 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@1 10 * this list of conditions and the following disclaimer in the documentation
adamc@1 11 * and/or other materials provided with the distribution.
adamc@1 12 * - The names of contributors may not be used to endorse or promote products
adamc@1 13 * derived from this software without specific prior written permission.
adamc@1 14 *
adamc@1 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@1 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@1 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@1 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@1 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@1 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@1 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@1 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@1 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@1 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@1 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@1 26 *)
adamc@1 27
adamc@1 28 (* Grammar for Laconic/Web programs *)
adamc@1 29
adamc@4 30 open Source
adamc@1 31
adamc@1 32 val s = ErrorMsg.spanOf
adamc@1 33
adamc@204 34 fun capitalize "" = ""
adamc@204 35 | capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
adamc@104 36
adamc@203 37 fun entable t =
adamc@203 38 case #1 t of
adamc@203 39 TRecord c => c
adamc@203 40 | _ => t
adamc@203 41
adamc@207 42 datatype select_item =
adamc@207 43 Field of con * con
adamc@207 44
adamc@207 45 datatype select =
adamc@207 46 Star
adamc@207 47 | Items of select_item list
adamc@207 48
adamc@226 49 datatype group_item =
adamc@226 50 GField of con * con
adamc@226 51
adamc@207 52 fun eqTnames ((c1, _), (c2, _)) =
adamc@207 53 case (c1, c2) of
adamc@207 54 (CVar (ms1, x1), CVar (ms2, x2)) => ms1 = ms2 andalso x1 = x2
adamc@207 55 | (CName x1, CName x2) => x1 = x2
adamc@207 56 | _ => false
adamc@207 57
adamc@207 58 fun amend_select loc (si, tabs) =
adamc@207 59 let
adamc@207 60 val (tx, c) = case si of
adamc@207 61 Field (tx, fx) => (tx, (CRecord ([(fx, (CWild (KType, loc), loc))]), loc))
adamc@207 62
adamc@207 63 val (tabs, found) = ListUtil.foldlMap (fn ((tx', c'), found) =>
adamc@207 64 if eqTnames (tx, tx') then
adamc@207 65 ((tx', (CConcat (c, c'), loc)), true)
adamc@207 66 else
adamc@207 67 ((tx', c'), found))
adamc@207 68 false tabs
adamc@207 69 in
adamc@207 70 if found then
adamc@207 71 ()
adamc@207 72 else
adamc@207 73 ErrorMsg.errorAt loc "Select of field from unbound table";
adamc@207 74
adamc@207 75 tabs
adamc@207 76 end
adamc@207 77
adamc@226 78 fun amend_group loc (gi, tabs) =
adamc@226 79 let
adamc@226 80 val (tx, c) = case gi of
adamc@226 81 GField (tx, fx) => (tx, (CRecord ([(fx, (CWild (KType, loc), loc))]), loc))
adamc@226 82
adamc@226 83 val (tabs, found) = ListUtil.foldlMap (fn ((tx', c'), found) =>
adamc@226 84 if eqTnames (tx, tx') then
adamc@226 85 ((tx', (CConcat (c, c'), loc)), true)
adamc@226 86 else
adamc@226 87 ((tx', c'), found))
adamc@226 88 false tabs
adamc@226 89 in
adamc@226 90 if found then
adamc@226 91 ()
adamc@226 92 else
adamc@226 93 ErrorMsg.errorAt loc "Select of field from unbound table";
adamc@226 94
adamc@226 95 tabs
adamc@226 96 end
adamc@226 97
adamc@209 98 fun sql_inject (v, t, loc) =
adamc@209 99 let
adamc@209 100 val e = (EApp ((EVar (["Basis"], "sql_inject"), loc), (v, loc)), loc)
adamc@209 101 in
adamc@209 102 (EApp (e, (t, loc)), loc)
adamc@209 103 end
adamc@209 104
adamc@219 105 fun sql_compare (oper, sqlexp1, sqlexp2, loc) =
adamc@219 106 let
adamc@219 107 val e = (EVar (["Basis"], "sql_comparison"), loc)
adamc@219 108 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc)
adamc@219 109 val e = (EApp (e, sqlexp1), loc)
adamc@219 110 val e = (EApp (e, sqlexp2), loc)
adamc@219 111 in
adamc@220 112 (EApp (e, (EWild, loc)), loc)
adamc@220 113 end
adamc@220 114
adamc@220 115 fun sql_binary (oper, sqlexp1, sqlexp2, loc) =
adamc@220 116 let
adamc@220 117 val e = (EVar (["Basis"], "sql_binary"), loc)
adamc@220 118 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc)
adamc@220 119 val e = (EApp (e, sqlexp1), loc)
adamc@220 120 in
adamc@220 121 (EApp (e, sqlexp2), loc)
adamc@220 122 end
adamc@220 123
adamc@220 124 fun sql_unary (oper, sqlexp, loc) =
adamc@220 125 let
adamc@220 126 val e = (EVar (["Basis"], "sql_unary"), loc)
adamc@220 127 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc)
adamc@220 128 in
adamc@220 129 (EApp (e, sqlexp), loc)
adamc@219 130 end
adamc@219 131
adamc@229 132 fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
adamc@229 133 let
adamc@229 134 val e = (EVar (["Basis"], "sql_relop"), loc)
adamc@229 135 val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc)
adamc@229 136 val e = (EApp (e, sqlexp1), loc)
adamc@229 137 in
adamc@229 138 (EApp (e, sqlexp2), loc)
adamc@229 139 end
adamc@229 140
adamc@1 141 %%
adamc@1 142 %header (functor LacwebLrValsFn(structure Token : TOKEN))
adamc@1 143
adamc@1 144 %term
adamc@1 145 EOF
adamc@14 146 | STRING of string | INT of Int64.int | FLOAT of Real64.real
adamc@1 147 | SYMBOL of string | CSYMBOL of string
adamc@1 148 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
adamc@156 149 | EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER | BAR
adamc@219 150 | DIVIDE | DOTDOTDOT
adamc@211 151 | CON | LTYPE | VAL | REC | AND | FOLD | UNIT | KUNIT | CLASS
adamc@156 152 | DATATYPE | OF
adamc@7 153 | TYPE | NAME
adamc@195 154 | ARROW | LARROW | DARROW | STAR
adamc@149 155 | FN | PLUSPLUS | MINUSMINUS | DOLLAR | TWIDDLE
adamc@88 156 | STRUCTURE | SIGNATURE | STRUCT | SIG | END | FUNCTOR | WHERE | EXTERN
adamc@203 157 | INCLUDE | OPEN | CONSTRAINT | CONSTRAINTS | EXPORT | TABLE
adamc@190 158 | CASE | IF | THEN | ELSE
adamc@1 159
adamc@91 160 | XML_BEGIN of string | XML_END
adamc@91 161 | NOTAGS of string
adamc@91 162 | BEGIN_TAG of string | END_TAG of string
adamc@91 163
adamc@227 164 | SELECT | FROM | AS | CWHERE | GROUP | BY | HAVING
adamc@229 165 | UNION | INTERSECT | EXCEPT
adamc@220 166 | TRUE | FALSE | CAND | OR | NOT
adamc@219 167 | NE | LT | LE | GT | GE
adamc@204 168
adamc@30 169 %nonterm
adamc@1 170 file of decl list
adamc@1 171 | decls of decl list
adamc@1 172 | decl of decl
adamc@123 173 | vali of string * con option * exp
adamc@123 174 | valis of (string * con option * exp) list
adamc@1 175
adamc@191 176 | dargs of string list
adamc@156 177 | barOpt of unit
adamc@156 178 | dcons of (string * con option) list
adamc@156 179 | dcon of string * con option
adamc@156 180
adamc@30 181 | sgn of sgn
adamc@42 182 | sgntm of sgn
adamc@30 183 | sgi of sgn_item
adamc@30 184 | sgis of sgn_item list
adamc@30 185
adamc@30 186 | str of str
adamc@30 187
adamc@1 188 | kind of kind
adamc@207 189 | ktuple of kind list
adamc@1 190 | kcolon of explicitness
adamc@1 191
adamc@34 192 | path of string list * string
adamc@156 193 | cpath of string list * string
adamc@34 194 | spath of str
adamc@59 195 | mpath of string list
adamc@34 196
adamc@1 197 | cexp of con
adamc@1 198 | capps of con
adamc@1 199 | cterm of con
adamc@195 200 | ctuple of con list
adamc@207 201 | ctuplev of con list
adamc@1 202 | ident of con
adamc@200 203 | idents of con list
adamc@1 204 | rcon of (con * con) list
adamc@83 205 | rconn of (con * con) list
adamc@1 206 | rcone of (con * con) list
adamc@1 207
adamc@8 208 | eexp of exp
adamc@8 209 | eapps of exp
adamc@8 210 | eterm of exp
adamc@195 211 | etuple of exp list
adamc@12 212 | rexp of (con * exp) list
adamc@91 213 | xml of exp
adamc@91 214 | xmlOne of exp
adamc@141 215 | tag of string * exp
adamc@141 216 | tagHead of string * exp
adamc@8 217
adamc@170 218 | branch of pat * exp
adamc@170 219 | branchs of (pat * exp) list
adamc@170 220 | pat of pat
adamc@170 221 | pterm of pat
adamc@174 222 | rpat of (string * pat) list * bool
adamc@195 223 | ptuple of pat list
adamc@170 224
adamc@104 225 | attrs of (con * exp) list
adamc@104 226 | attr of con * exp
adamc@104 227 | attrv of exp
adamc@104 228
adamc@204 229 | query of exp
adamc@226 230 | query1 of exp
adamc@204 231 | tables of (con * exp) list
adamc@204 232 | tname of con
adamc@204 233 | table of con * exp
adamc@207 234 | tident of con
adamc@207 235 | fident of con
adamc@207 236 | seli of select_item
adamc@207 237 | selis of select_item list
adamc@207 238 | select of select
adamc@209 239 | sqlexp of exp
adamc@209 240 | wopt of exp
adamc@226 241 | groupi of group_item
adamc@226 242 | groupis of group_item list
adamc@226 243 | gopt of group_item list option
adamc@227 244 | hopt of exp
adamc@207 245
adamc@204 246
adamc@1 247 %verbose (* print summary of errors *)
adamc@1 248 %pos int (* positions *)
adamc@1 249 %start file
adamc@1 250 %pure
adamc@1 251 %eop EOF
adamc@1 252 %noshift EOF
adamc@1 253
adamc@1 254 %name Lacweb
adamc@1 255
adamc@195 256 %nonassoc IF THEN ELSE
adamc@1 257 %nonassoc DARROW
adamc@1 258 %nonassoc COLON
adamc@6 259 %nonassoc DCOLON TCOLON
adamc@229 260 %left UNION INTERSECT EXCEPT
adamc@1 261 %right COMMA
adamc@220 262 %right OR
adamc@220 263 %right CAND
adamc@219 264 %nonassoc EQ NE LT LE GT GE
adamc@1 265 %right ARROW LARROW
adamc@149 266 %right PLUSPLUS MINUSMINUS
adamc@195 267 %right STAR
adamc@220 268 %left NOT
adamc@84 269 %nonassoc TWIDDLE
adamc@1 270 %nonassoc DOLLAR
adamc@1 271 %left DOT
adamc@221 272 %nonassoc LBRACE RBRACE
adamc@1 273
adamc@1 274 %%
adamc@1 275
adamc@1 276 file : decls (decls)
adamc@54 277 | SIG sgis ([(DSgn ("?", (SgnConst sgis, s (SIGleft, sgisright))),
adamc@54 278 s (SIGleft, sgisright))])
adamc@1 279
adamc@1 280 decls : ([])
adamc@1 281 | decl decls (decl :: decls)
adamc@1 282
adamc@1 283 decl : CON SYMBOL EQ cexp (DCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@1 284 | CON SYMBOL DCOLON kind EQ cexp (DCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@7 285 | LTYPE SYMBOL EQ cexp (DCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@7 286 s (LTYPEleft, cexpright))
adamc@191 287 | DATATYPE SYMBOL dargs EQ barOpt dcons(DDatatype (SYMBOL, dargs, dcons), s (DATATYPEleft, dconsright))
adamc@191 288 | DATATYPE SYMBOL dargs EQ DATATYPE CSYMBOL DOT path
adamc@191 289 (case dargs of
adamc@191 290 [] => (DDatatypeImp (SYMBOL, CSYMBOL :: #1 path, #2 path), s (DATATYPEleft, pathright))
adamc@191 291 | _ => raise Fail "Arguments specified for imported datatype")
adamc@123 292 | VAL vali (DVal vali, s (VALleft, valiright))
adamc@123 293 | VAL REC valis (DValRec valis, s (VALleft, valisright))
adamc@1 294
adamc@30 295 | SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@30 296 | STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright))
adamc@30 297 | STRUCTURE CSYMBOL COLON sgn EQ str (DStr (CSYMBOL, SOME sgn, str), s (STRUCTUREleft, strright))
adamc@42 298 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN EQ str
adamc@42 299 (DStr (CSYMBOL1, NONE,
adamc@42 300 (StrFun (CSYMBOL2, sgn1, NONE, str), s (FUNCTORleft, strright))),
adamc@42 301 s (FUNCTORleft, strright))
adamc@42 302 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn EQ str
adamc@42 303 (DStr (CSYMBOL1, NONE,
adamc@42 304 (StrFun (CSYMBOL2, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))),
adamc@42 305 s (FUNCTORleft, strright))
adamc@48 306 | EXTERN STRUCTURE CSYMBOL COLON sgn (DFfiStr (CSYMBOL, sgn), s (EXTERNleft, sgnright))
adamc@61 307 | OPEN mpath (case mpath of
adamc@61 308 [] => raise Fail "Impossible mpath parse [1]"
adamc@61 309 | m :: ms => (DOpen (m, ms), s (OPENleft, mpathright)))
adamc@88 310 | OPEN CONSTRAINTS mpath (case mpath of
adamc@88 311 [] => raise Fail "Impossible mpath parse [3]"
adamc@88 312 | m :: ms => (DOpenConstraints (m, ms), s (OPENleft, mpathright)))
adamc@88 313 | CONSTRAINT cterm TWIDDLE cterm (DConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@109 314 | EXPORT spath (DExport spath, s (EXPORTleft, spathright))
adamc@203 315 | TABLE SYMBOL COLON cexp (DTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
adamc@211 316 | CLASS SYMBOL EQ cexp (DClass (SYMBOL, cexp), s (CLASSleft, cexpright))
adamc@211 317 | CLASS SYMBOL SYMBOL EQ cexp (let
adamc@211 318 val loc = s (CLASSleft, cexpright)
adamc@211 319 val k = (KType, loc)
adamc@211 320 val c = (CAbs (SYMBOL2, SOME k, cexp), loc)
adamc@211 321 in
adamc@211 322 (DClass (SYMBOL1, c), s (CLASSleft, cexpright))
adamc@211 323 end)
adamc@30 324
adamc@191 325 dargs : ([])
adamc@191 326 | SYMBOL dargs (SYMBOL :: dargs)
adamc@191 327
adamc@156 328 barOpt : ()
adamc@156 329 | BAR ()
adamc@156 330
adamc@156 331 dcons : dcon ([dcon])
adamc@156 332 | dcon BAR dcons (dcon :: dcons)
adamc@156 333
adamc@156 334 dcon : CSYMBOL (CSYMBOL, NONE)
adamc@156 335 | CSYMBOL OF cexp (CSYMBOL, SOME cexp)
adamc@156 336
adamc@123 337 vali : SYMBOL EQ eexp (SYMBOL, NONE, eexp)
adamc@123 338 | SYMBOL COLON cexp EQ eexp (SYMBOL, SOME cexp, eexp)
adamc@123 339
adamc@123 340 valis : vali ([vali])
adamc@123 341 | vali AND valis (vali :: valis)
adamc@123 342
adamc@42 343 sgn : sgntm (sgntm)
adamc@40 344 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@40 345 (SgnFun (CSYMBOL, sgn1, sgn2), s (FUNCTORleft, sgn2right))
adamc@30 346
adamc@42 347 sgntm : SIG sgis END (SgnConst sgis, s (SIGleft, ENDright))
adamc@59 348 | mpath (case mpath of
adamc@61 349 [] => raise Fail "Impossible mpath parse [2]"
adamc@59 350 | [x] => SgnVar x
adamc@59 351 | m :: ms => SgnProj (m,
adamc@59 352 List.take (ms, length ms - 1),
adamc@59 353 List.nth (ms, length ms - 1)),
adamc@59 354 s (mpathleft, mpathright))
adamc@42 355 | sgntm WHERE CON SYMBOL EQ cexp (SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 356 | sgntm WHERE LTYPE SYMBOL EQ cexp(SgnWhere (sgntm, SYMBOL, cexp), s (sgntmleft, cexpright))
adamc@42 357 | LPAREN sgn RPAREN (sgn)
adamc@42 358
adamc@30 359 sgi : CON SYMBOL DCOLON kind (SgiConAbs (SYMBOL, kind), s (CONleft, kindright))
adamc@30 360 | LTYPE SYMBOL (SgiConAbs (SYMBOL, (KType, s (LTYPEleft, SYMBOLright))),
adamc@30 361 s (LTYPEleft, SYMBOLright))
adamc@30 362 | CON SYMBOL EQ cexp (SgiCon (SYMBOL, NONE, cexp), s (CONleft, cexpright))
adamc@30 363 | CON SYMBOL DCOLON kind EQ cexp (SgiCon (SYMBOL, SOME kind, cexp), s (CONleft, cexpright))
adamc@30 364 | LTYPE SYMBOL EQ cexp (SgiCon (SYMBOL, SOME (KType, s (LTYPEleft, cexpright)), cexp),
adamc@30 365 s (LTYPEleft, cexpright))
adamc@191 366 | DATATYPE SYMBOL dargs EQ barOpt dcons(SgiDatatype (SYMBOL, dargs, dcons), s (DATATYPEleft, dconsright))
adamc@191 367 | DATATYPE SYMBOL dargs EQ DATATYPE CSYMBOL DOT path
adamc@191 368 (case dargs of
adamc@191 369 [] => (SgiDatatypeImp (SYMBOL, CSYMBOL :: #1 path, #2 path), s (DATATYPEleft, pathright))
adamc@191 370 | _ => raise Fail "Arguments specified for imported datatype")
adamc@30 371 | VAL SYMBOL COLON cexp (SgiVal (SYMBOL, cexp), s (VALleft, cexpright))
adamc@30 372
adamc@30 373 | STRUCTURE CSYMBOL COLON sgn (SgiStr (CSYMBOL, sgn), s (STRUCTUREleft, sgnright))
adamc@59 374 | SIGNATURE CSYMBOL EQ sgn (SgiSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
adamc@42 375 | FUNCTOR CSYMBOL LPAREN CSYMBOL COLON sgn RPAREN COLON sgn
adamc@42 376 (SgiStr (CSYMBOL1,
adamc@42 377 (SgnFun (CSYMBOL2, sgn1, sgn2), s (FUNCTORleft, sgn2right))),
adamc@42 378 s (FUNCTORleft, sgn2right))
adamc@58 379 | INCLUDE sgn (SgiInclude sgn, s (INCLUDEleft, sgnright))
adamc@88 380 | CONSTRAINT cterm TWIDDLE cterm (SgiConstraint (cterm1, cterm2), s (CONSTRAINTleft, ctermright))
adamc@203 381 | TABLE SYMBOL COLON cexp (SgiTable (SYMBOL, entable cexp), s (TABLEleft, cexpright))
adamc@211 382 | CLASS SYMBOL (SgiClassAbs SYMBOL, s (CLASSleft, SYMBOLright))
adamc@211 383 | CLASS SYMBOL EQ cexp (SgiClass (SYMBOL, cexp), s (CLASSleft, cexpright))
adamc@211 384 | CLASS SYMBOL SYMBOL EQ cexp (let
adamc@211 385 val loc = s (CLASSleft, cexpright)
adamc@211 386 val k = (KType, loc)
adamc@211 387 val c = (CAbs (SYMBOL2, SOME k, cexp), loc)
adamc@211 388 in
adamc@211 389 (SgiClass (SYMBOL1, c), s (CLASSleft, cexpright))
adamc@211 390 end)
adamc@30 391
adamc@30 392 sgis : ([])
adamc@30 393 | sgi sgis (sgi :: sgis)
adamc@30 394
adamc@30 395 str : STRUCT decls END (StrConst decls, s (STRUCTleft, ENDright))
adamc@34 396 | spath (spath)
adamc@40 397 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN DARROW str
adamc@40 398 (StrFun (CSYMBOL, sgn, NONE, str), s (FUNCTORleft, strright))
adamc@40 399 | FUNCTOR LPAREN CSYMBOL COLON sgn RPAREN COLON sgn DARROW str
adamc@40 400 (StrFun (CSYMBOL, sgn1, SOME sgn2, str), s (FUNCTORleft, strright))
adamc@44 401 | spath LPAREN str RPAREN (StrApp (spath, str), s (spathleft, RPARENright))
adamc@34 402
adamc@34 403 spath : CSYMBOL (StrVar CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@34 404 | spath DOT CSYMBOL (StrProj (spath, CSYMBOL), s (spathleft, CSYMBOLright))
adamc@30 405
adamc@1 406 kind : TYPE (KType, s (TYPEleft, TYPEright))
adamc@1 407 | NAME (KName, s (NAMEleft, NAMEright))
adamc@1 408 | LBRACE kind RBRACE (KRecord kind, s (LBRACEleft, RBRACEright))
adamc@1 409 | kind ARROW kind (KArrow (kind1, kind2), s (kind1left, kind2right))
adamc@1 410 | LPAREN kind RPAREN (#1 kind, s (LPARENleft, RPARENright))
adamc@82 411 | KUNIT (KUnit, s (KUNITleft, KUNITright))
adamc@18 412 | UNDERUNDER (KWild, s (UNDERUNDERleft, UNDERUNDERright))
adamc@207 413 | LPAREN ktuple RPAREN (KTuple ktuple, s (LPARENleft, RPARENright))
adamc@207 414
adamc@207 415 ktuple : kind STAR kind ([kind1, kind2])
adamc@207 416 | kind STAR ktuple (kind :: ktuple)
adamc@1 417
adamc@1 418 capps : cterm (cterm)
adamc@1 419 | capps cterm (CApp (capps, cterm), s (cappsleft, ctermright))
adamc@1 420
adamc@1 421 cexp : capps (capps)
adamc@1 422 | cexp ARROW cexp (TFun (cexp1, cexp2), s (cexp1left, cexp2right))
adamc@15 423 | SYMBOL kcolon kind ARROW cexp (TCFun (kcolon, SYMBOL, kind, cexp), s (SYMBOLleft, cexpright))
adamc@1 424
adamc@1 425 | cexp PLUSPLUS cexp (CConcat (cexp1, cexp2), s (cexp1left, cexp1right))
adamc@1 426
adamc@67 427 | FN SYMBOL DARROW cexp (CAbs (SYMBOL, NONE, cexp), s (FNleft, cexpright))
adamc@67 428 | FN SYMBOL DCOLON kind DARROW cexp (CAbs (SYMBOL, SOME kind, cexp), s (FNleft, cexpright))
adamc@84 429 | cterm TWIDDLE cterm DARROW cexp(CDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@85 430 | cterm TWIDDLE cterm ARROW cexp (TDisjoint (cterm1, cterm2, cexp), s (cterm1left, cexpright))
adamc@1 431
adamc@8 432 | LPAREN cexp RPAREN DCOLON kind (CAnnot (cexp, kind), s (LPARENleft, kindright))
adamc@6 433
adamc@18 434 | UNDER DCOLON kind (CWild kind, s (UNDERleft, UNDERright))
adamc@195 435 | ctuple (let
adamc@195 436 val loc = s (ctupleleft, ctupleright)
adamc@195 437 in
adamc@195 438 (TRecord (CRecord (ListUtil.mapi (fn (i, c) =>
adamc@195 439 ((CName (Int.toString (i + 1)), loc),
adamc@195 440 c)) ctuple),
adamc@195 441 loc), loc)
adamc@195 442 end)
adamc@18 443
adamc@1 444 kcolon : DCOLON (Explicit)
adamc@1 445 | TCOLON (Implicit)
adamc@1 446
adamc@34 447 path : SYMBOL ([], SYMBOL)
adamc@34 448 | CSYMBOL DOT path (let val (ms, x) = path in (CSYMBOL :: ms, x) end)
adamc@34 449
adamc@156 450 cpath : CSYMBOL ([], CSYMBOL)
adamc@156 451 | CSYMBOL DOT cpath (let val (ms, x) = cpath in (CSYMBOL :: ms, x) end)
adamc@156 452
adamc@59 453 mpath : CSYMBOL ([CSYMBOL])
adamc@59 454 | CSYMBOL DOT mpath (CSYMBOL :: mpath)
adamc@59 455
adamc@1 456 cterm : LPAREN cexp RPAREN (#1 cexp, s (LPARENleft, RPARENright))
adamc@1 457 | LBRACK rcon RBRACK (CRecord rcon, s (LBRACKleft, RBRACKright))
adamc@83 458 | LBRACK rconn RBRACK (CRecord rconn, s (LBRACKleft, RBRACKright))
adamc@1 459 | LBRACE rcone RBRACE (TRecord (CRecord rcone, s (LBRACEleft, RBRACEright)),
adamc@1 460 s (LBRACEleft, RBRACEright))
adamc@1 461 | DOLLAR cterm (TRecord cterm, s (DOLLARleft, ctermright))
adamc@1 462 | HASH CSYMBOL (CName CSYMBOL, s (HASHleft, CSYMBOLright))
adamc@195 463 | HASH INT (CName (Int64.toString INT), s (HASHleft, INTright))
adamc@1 464
adamc@34 465 | path (CVar path, s (pathleft, pathright))
adamc@207 466 | path DOT INT (CProj ((CVar path, s (pathleft, pathright)), Int64.toInt INT),
adamc@207 467 s (pathleft, INTright))
adamc@18 468 | UNDER (CWild (KWild, s (UNDERleft, UNDERright)), s (UNDERleft, UNDERright))
adamc@67 469 | FOLD (CFold, s (FOLDleft, FOLDright))
adamc@82 470 | UNIT (CUnit, s (UNITleft, UNITright))
adamc@207 471 | LPAREN ctuplev RPAREN (CTuple ctuplev, s (LPARENleft, RPARENright))
adamc@207 472
adamc@207 473 ctuplev: cexp COMMA cexp ([cexp1, cexp2])
adamc@207 474 | cexp COMMA ctuplev (cexp :: ctuplev)
adamc@1 475
adamc@196 476 ctuple : capps STAR capps ([capps1, capps2])
adamc@196 477 | capps STAR ctuple (capps :: ctuple)
adamc@195 478
adamc@1 479 rcon : ([])
adamc@1 480 | ident EQ cexp ([(ident, cexp)])
adamc@1 481 | ident EQ cexp COMMA rcon ((ident, cexp) :: rcon)
adamc@1 482
adamc@83 483 rconn : ident ([(ident, (CUnit, s (identleft, identright)))])
adamc@83 484 | ident COMMA rconn ((ident, (CUnit, s (identleft, identright))) :: rconn)
adamc@83 485
adamc@1 486 rcone : ([])
adamc@1 487 | ident COLON cexp ([(ident, cexp)])
adamc@1 488 | ident COLON cexp COMMA rcone ((ident, cexp) :: rcone)
adamc@1 489
adamc@1 490 ident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@195 491 | INT (CName (Int64.toString INT), s (INTleft, INTright))
adamc@200 492 | SYMBOL (CVar ([], SYMBOL), s (SYMBOLleft, SYMBOLright))
adamc@8 493
adamc@8 494 eapps : eterm (eterm)
adamc@8 495 | eapps eterm (EApp (eapps, eterm), s (eappsleft, etermright))
adamc@8 496 | eapps LBRACK cexp RBRACK (ECApp (eapps, cexp), s (eappsleft, RBRACKright))
adamc@8 497
adamc@8 498 eexp : eapps (eapps)
adamc@8 499 | FN SYMBOL kcolon kind DARROW eexp (ECAbs (kcolon, SYMBOL, kind, eexp), s (FNleft, eexpright))
adamc@8 500 | FN SYMBOL COLON cexp DARROW eexp (EAbs (SYMBOL, SOME cexp, eexp), s (FNleft, eexpright))
adamc@8 501 | FN SYMBOL DARROW eexp (EAbs (SYMBOL, NONE, eexp), s (FNleft, eexpright))
adamc@212 502 | FN UNDER COLON cexp DARROW eexp (EAbs ("_", SOME cexp, eexp), s (FNleft, eexpright))
adamc@93 503 | LBRACK cterm TWIDDLE cterm RBRACK DARROW eexp(EDisjoint (cterm1, cterm2, eexp), s (LBRACKleft, RBRACKright))
adamc@93 504 | FN UNIT DARROW eexp (let
adamc@93 505 val loc = s (FNleft, eexpright)
adamc@93 506 in
adamc@93 507 (EAbs ("_", SOME (TRecord (CRecord [], loc), loc), eexp), loc)
adamc@93 508 end)
adamc@8 509
adamc@196 510 | eexp COLON cexp (EAnnot (eexp, cexp), s (eexpleft, cexpright))
adamc@149 511 | eexp MINUSMINUS cexp (ECut (eexp, cexp), s (eexpleft, cexpright))
adamc@170 512 | CASE eexp OF barOpt branch branchs (ECase (eexp, branch :: branchs), s (CASEleft, branchsright))
adamc@190 513 | IF eexp THEN eexp ELSE eexp (let
adamc@190 514 val loc = s (IFleft, eexp3right)
adamc@190 515 in
adamc@190 516 (ECase (eexp1, [((PCon (["Basis"], "True", NONE), loc), eexp2),
adamc@190 517 ((PCon (["Basis"], "False", NONE), loc), eexp3)]), loc)
adamc@190 518 end)
adamc@8 519
adamc@8 520 eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
adamc@195 521 | LPAREN etuple RPAREN (let
adamc@195 522 val loc = s (LPARENleft, RPARENright)
adamc@195 523 in
adamc@195 524 (ERecord (ListUtil.mapi (fn (i, e) =>
adamc@195 525 ((CName (Int.toString (i + 1)), loc),
adamc@195 526 e)) etuple), loc)
adamc@195 527 end)
adamc@8 528
adamc@34 529 | path (EVar path, s (pathleft, pathright))
adamc@156 530 | cpath (EVar cpath, s (cpathleft, cpathright))
adamc@12 531 | LBRACE rexp RBRACE (ERecord rexp, s (LBRACEleft, RBRACEright))
adamc@110 532 | UNIT (ERecord [], s (UNITleft, UNITright))
adamc@12 533
adamc@14 534 | INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@14 535 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@14 536 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@14 537
adamc@200 538 | path DOT idents (let
adamc@200 539 val loc = s (pathleft, identsright)
adamc@200 540 in
adamc@200 541 foldl (fn (ident, e) =>
adamc@200 542 (EField (e, ident), loc))
adamc@200 543 (EVar path, s (pathleft, pathright)) idents
adamc@200 544 end)
adamc@71 545 | FOLD (EFold, s (FOLDleft, FOLDright))
adamc@71 546
adamc@91 547 | XML_BEGIN xml XML_END (xml)
adamc@91 548 | XML_BEGIN XML_END (EApp ((EVar (["Basis"], "cdata"), s (XML_BEGINleft, XML_ENDright)),
adamc@91 549 (EPrim (Prim.String ""), s (XML_BEGINleft, XML_ENDright))),
adamc@91 550 s (XML_BEGINleft, XML_ENDright))
adamc@204 551 | LPAREN query RPAREN (query)
adamc@211 552 | UNDER (EWild, s (UNDERleft, UNDERright))
adamc@91 553
adamc@200 554 idents : ident ([ident])
adamc@200 555 | ident DOT idents (ident :: idents)
adamc@200 556
adamc@195 557 etuple : eexp COMMA eexp ([eexp1, eexp2])
adamc@195 558 | eexp COMMA etuple (eexp :: etuple)
adamc@195 559
adamc@170 560 branch : pat DARROW eexp (pat, eexp)
adamc@170 561
adamc@170 562 branchs: ([])
adamc@170 563 | BAR branch branchs (branch :: branchs)
adamc@170 564
adamc@170 565 pat : pterm (pterm)
adamc@170 566 | cpath pterm (PCon (#1 cpath, #2 cpath, SOME pterm), s (cpathleft, ptermright))
adamc@170 567
adamc@170 568 pterm : SYMBOL (PVar SYMBOL, s (SYMBOLleft, SYMBOLright))
adamc@170 569 | cpath (PCon (#1 cpath, #2 cpath, NONE), s (cpathleft, cpathright))
adamc@170 570 | UNDER (PWild, s (UNDERleft, UNDERright))
adamc@173 571 | INT (PPrim (Prim.Int INT), s (INTleft, INTright))
adamc@173 572 | STRING (PPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@170 573 | LPAREN pat RPAREN (pat)
adamc@174 574 | LBRACE RBRACE (PRecord ([], false), s (LBRACEleft, RBRACEright))
adamc@174 575 | UNIT (PRecord ([], false), s (UNITleft, UNITright))
adamc@174 576 | LBRACE rpat RBRACE (PRecord rpat, s (LBRACEleft, RBRACEright))
adamc@195 577 | LPAREN ptuple RPAREN (PRecord (ListUtil.mapi (fn (i, p) => (Int.toString (i + 1), p)) ptuple,
adamc@195 578 false),
adamc@195 579 s (LPARENleft, RPARENright))
adamc@174 580
adamc@175 581 rpat : CSYMBOL EQ pat ([(CSYMBOL, pat)], false)
adamc@174 582 | DOTDOTDOT ([], true)
adamc@175 583 | CSYMBOL EQ pat COMMA rpat ((CSYMBOL, pat) :: #1 rpat, #2 rpat)
adamc@170 584
adamc@195 585 ptuple : pat COMMA pat ([pat1, pat2])
adamc@195 586 | pat COMMA ptuple (pat :: ptuple)
adamc@195 587
adamc@12 588 rexp : ([])
adamc@12 589 | ident EQ eexp ([(ident, eexp)])
adamc@12 590 | ident EQ eexp COMMA rexp ((ident, eexp) :: rexp)
adamc@91 591
adamc@141 592 xml : xmlOne xml (let
adamc@141 593 val pos = s (xmlOneleft, xmlright)
adamc@141 594 in
adamc@141 595 (EApp ((EApp (
adamc@141 596 (EVar (["Basis"], "join"), pos),
adamc@91 597 xmlOne), pos),
adamc@141 598 xml), pos)
adamc@141 599 end)
adamc@141 600 | xmlOne (xmlOne)
adamc@91 601
adamc@141 602 xmlOne : NOTAGS (EApp ((EVar (["Basis"], "cdata"), s (NOTAGSleft, NOTAGSright)),
adamc@141 603 (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))),
adamc@141 604 s (NOTAGSleft, NOTAGSright))
adamc@141 605 | tag DIVIDE GT (let
adamc@141 606 val pos = s (tagleft, GTright)
adamc@141 607 in
adamc@141 608 (EApp (#2 tag,
adamc@141 609 (EApp ((EVar (["Basis"], "cdata"), pos),
adamc@141 610 (EPrim (Prim.String ""), pos)),
adamc@141 611 pos)), pos)
adamc@141 612 end)
adamc@141 613
adamc@141 614 | tag GT xml END_TAG (let
adamc@141 615 val pos = s (tagleft, GTright)
adamc@141 616 in
adamc@141 617 if #1 tag = END_TAG then
adamc@141 618 if END_TAG = "lform" then
adamc@141 619 (EApp ((EVar (["Basis"], "lform"), pos),
adamc@141 620 xml), pos)
adamc@141 621 else
adamc@141 622 (EApp (#2 tag, xml), pos)
adamc@141 623 else
adamc@141 624 (ErrorMsg.errorAt pos "Begin and end tags don't match.";
adamc@141 625 (EFold, pos))
adamc@141 626 end)
adamc@141 627 | LBRACE eexp RBRACE (eexp)
adamc@92 628
adamc@141 629 tag : tagHead attrs (let
adamc@141 630 val pos = s (tagHeadleft, attrsright)
adamc@141 631 in
adamc@141 632 (#1 tagHead,
adamc@141 633 (EApp ((EApp ((EVar (["Basis"], "tag"), pos),
adamc@141 634 (ERecord attrs, pos)), pos),
adamc@141 635 (EApp (#2 tagHead,
adamc@141 636 (ERecord [], pos)), pos)),
adamc@141 637 pos))
adamc@141 638 end)
adamc@141 639
adamc@141 640 tagHead: BEGIN_TAG (let
adamc@141 641 val pos = s (BEGIN_TAGleft, BEGIN_TAGright)
adamc@141 642 in
adamc@141 643 (BEGIN_TAG,
adamc@141 644 (EVar ([], BEGIN_TAG), pos))
adamc@141 645 end)
adamc@141 646 | tagHead LBRACE cexp RBRACE (#1 tagHead, (ECApp (#2 tagHead, cexp), s (tagHeadleft, RBRACEright)))
adamc@92 647
adamc@104 648 attrs : ([])
adamc@104 649 | attr attrs (attr :: attrs)
adamc@104 650
adamc@204 651 attr : SYMBOL EQ attrv ((CName (capitalize SYMBOL), s (SYMBOLleft, SYMBOLright)), attrv)
adamc@204 652
adamc@104 653 attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright))
adamc@104 654 | FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
adamc@104 655 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
adamc@110 656 | LBRACE eexp RBRACE (eexp)
adamc@226 657
adamc@229 658 query : query1 (let
adamc@229 659 val loc = s (query1left, query1right)
adamc@229 660 in
adamc@229 661 (EApp ((EVar (["Basis"], "sql_query"), loc), query1), loc)
adamc@229 662 end)
adamc@204 663
adamc@227 664 query1 : SELECT select FROM tables wopt gopt hopt
adamc@209 665 (let
adamc@204 666 val loc = s (SELECTleft, tablesright)
adamc@207 667
adamc@207 668 val sel =
adamc@207 669 case select of
adamc@207 670 Star => map (fn (nm, _) =>
adamc@207 671 (nm, (CTuple [(CWild (KRecord (KType, loc), loc),
adamc@207 672 loc),
adamc@207 673 (CRecord [], loc)],
adamc@207 674 loc))) tables
adamc@207 675 | Items sis =>
adamc@207 676 let
adamc@207 677 val tabs = map (fn (nm, _) => (nm, (CRecord [], loc))) tables
adamc@207 678 val tabs = foldl (amend_select loc) tabs sis
adamc@207 679 in
adamc@207 680 map (fn (nm, c) => (nm,
adamc@207 681 (CTuple [c,
adamc@207 682 (CWild (KRecord (KType, loc), loc),
adamc@207 683 loc)], loc))) tabs
adamc@207 684 end
adamc@207 685
adamc@207 686 val sel = (CRecord sel, loc)
adamc@207 687
adamc@226 688 val grp = case gopt of
adamc@226 689 NONE => (ECApp ((EVar (["Basis"], "sql_subset_all"), loc),
adamc@226 690 (CWild (KRecord (KRecord (KType, loc), loc),
adamc@226 691 loc), loc)), loc)
adamc@226 692 | SOME gis =>
adamc@226 693 let
adamc@226 694 val tabs = map (fn (nm, _) =>
adamc@226 695 (nm, (CRecord [], loc))) tables
adamc@226 696 val tabs = foldl (amend_group loc) tabs gis
adamc@226 697
adamc@226 698 val tabs = map (fn (nm, c) =>
adamc@226 699 (nm,
adamc@226 700 (CTuple [c,
adamc@226 701 (CWild (KRecord (KType, loc),
adamc@226 702 loc),
adamc@226 703 loc)], loc))) tabs
adamc@226 704 in
adamc@226 705 (ECApp ((EVar (["Basis"], "sql_subset"), loc),
adamc@226 706 (CRecord tabs, loc)), loc)
adamc@226 707 end
adamc@226 708
adamc@229 709 val e = (EVar (["Basis"], "sql_query1"), loc)
adamc@209 710 val re = (ERecord [((CName "From", loc),
adamc@209 711 (ERecord tables, loc)),
adamc@209 712 ((CName "Where", loc),
adamc@223 713 wopt),
adamc@224 714 ((CName "GroupBy", loc),
adamc@226 715 grp),
adamc@224 716 ((CName "Having", loc),
adamc@224 717 hopt),
adamc@223 718 ((CName "SelectFields", loc),
adamc@223 719 (ECApp ((EVar (["Basis"], "sql_subset"), loc),
adamc@223 720 sel), loc))], loc)
adamc@223 721
adamc@209 722 val e = (EApp (e, re), loc)
adamc@204 723 in
adamc@207 724 e
adamc@204 725 end)
adamc@229 726 | query1 UNION query1 (sql_relop ("union", query11, query12, s (query11left, query12right)))
adamc@229 727 | query1 INTERSECT query1 (sql_relop ("intersect", query11, query12, s (query11left, query12right)))
adamc@229 728 | query1 EXCEPT query1 (sql_relop ("except", query11, query12, s (query11left, query12right)))
adamc@204 729
adamc@204 730 tables : table ([table])
adamc@204 731 | table COMMA tables (table :: tables)
adamc@204 732
adamc@204 733 tname : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@204 734 | LBRACE cexp RBRACE (cexp)
adamc@204 735
adamc@207 736 table : SYMBOL ((CName SYMBOL, s (SYMBOLleft, SYMBOLright)),
adamc@204 737 (EVar ([], SYMBOL), s (SYMBOLleft, SYMBOLright)))
adamc@204 738 | SYMBOL AS tname (tname, (EVar ([], SYMBOL), s (SYMBOLleft, SYMBOLright)))
adamc@221 739 | LBRACE LBRACE eexp RBRACE RBRACE AS tname (tname, eexp)
adamc@207 740
adamc@207 741 tident : SYMBOL (CName SYMBOL, s (SYMBOLleft, SYMBOLright))
adamc@207 742 | CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@221 743 | LBRACE LBRACE cexp RBRACE RBRACE (cexp)
adamc@207 744
adamc@207 745 fident : CSYMBOL (CName CSYMBOL, s (CSYMBOLleft, CSYMBOLright))
adamc@207 746 | LBRACE cexp RBRACE (cexp)
adamc@207 747
adamc@207 748 seli : tident DOT fident (Field (tident, fident))
adamc@207 749
adamc@207 750 selis : seli ([seli])
adamc@207 751 | seli COMMA selis (seli :: selis)
adamc@207 752
adamc@207 753 select : STAR (Star)
adamc@207 754 | selis (Items selis)
adamc@209 755
adamc@209 756 sqlexp : TRUE (sql_inject (EVar (["Basis"], "True"),
adamc@209 757 EVar (["Basis"], "sql_bool"),
adamc@209 758 s (TRUEleft, TRUEright)))
adamc@209 759 | FALSE (sql_inject (EVar (["Basis"], "False"),
adamc@209 760 EVar (["Basis"], "sql_bool"),
adamc@209 761 s (FALSEleft, FALSEright)))
adamc@209 762
adamc@222 763 | INT (sql_inject (EPrim (Prim.Int INT),
adamc@222 764 EVar (["Basis"], "sql_int"),
adamc@222 765 s (INTleft, INTright)))
adamc@222 766 | FLOAT (sql_inject (EPrim (Prim.Float FLOAT),
adamc@222 767 EVar (["Basis"], "sql_float"),
adamc@222 768 s (FLOATleft, FLOATright)))
adamc@229 769 | STRING (sql_inject (EPrim (Prim.String STRING),
adamc@229 770 EVar (["Basis"], "sql_string"),
adamc@229 771 s (STRINGleft, STRINGright)))
adamc@222 772
adamc@221 773 | tident DOT fident (let
adamc@221 774 val loc = s (tidentleft, fidentright)
adamc@221 775 val e = (EVar (["Basis"], "sql_field"), loc)
adamc@221 776 val e = (ECApp (e, tident), loc)
adamc@221 777 in
adamc@221 778 (ECApp (e, fident), loc)
adamc@221 779 end)
adamc@221 780
adamc@219 781 | sqlexp EQ sqlexp (sql_compare ("eq", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 782 | sqlexp NE sqlexp (sql_compare ("ne", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 783 | sqlexp LT sqlexp (sql_compare ("lt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 784 | sqlexp LE sqlexp (sql_compare ("le", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 785 | sqlexp GT sqlexp (sql_compare ("gt", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 786 | sqlexp GE sqlexp (sql_compare ("ge", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@219 787
adamc@220 788 | sqlexp CAND sqlexp (sql_binary ("and", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@220 789 | sqlexp OR sqlexp (sql_binary ("or", sqlexp1, sqlexp2, s (sqlexp1left, sqlexp2right)))
adamc@220 790 | NOT sqlexp (sql_unary ("not", sqlexp, s (NOTleft, sqlexpright)))
adamc@220 791
adamc@210 792 | LBRACE eexp RBRACE (sql_inject (#1 eexp,
adamc@211 793 EWild,
adamc@210 794 s (LBRACEleft, RBRACEright)))
adamc@220 795 | LPAREN sqlexp RPAREN (sqlexp)
adamc@210 796
adamc@209 797 wopt : (sql_inject (EVar (["Basis"], "True"),
adamc@209 798 EVar (["Basis"], "sql_bool"),
adamc@209 799 ErrorMsg.dummySpan))
adamc@209 800 | CWHERE sqlexp (sqlexp)
adamc@226 801
adamc@226 802 groupi : tident DOT fident (GField (tident, fident))
adamc@226 803
adamc@226 804 groupis: groupi ([groupi])
adamc@226 805 | groupi COMMA groupis (groupi :: groupis)
adamc@226 806
adamc@226 807 gopt : (NONE)
adamc@226 808 | GROUP BY groupis (SOME groupis)
adamc@227 809
adamc@227 810 hopt : (sql_inject (EVar (["Basis"], "True"),
adamc@227 811 EVar (["Basis"], "sql_bool"),
adamc@227 812 ErrorMsg.dummySpan))
adamc@227 813 | HAVING sqlexp (sqlexp)