comparison src/lacweb.grm @ 227:524e10c91478

GROUP BY and HAVING
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 Aug 2008 14:09:08 -0400
parents b0041cc7e5f7
children 016d71e878c1
comparison
equal deleted inserted replaced
226:b0041cc7e5f7 227:524e10c91478
150 150
151 | XML_BEGIN of string | XML_END 151 | XML_BEGIN of string | XML_END
152 | NOTAGS of string 152 | NOTAGS of string
153 | BEGIN_TAG of string | END_TAG of string 153 | BEGIN_TAG of string | END_TAG of string
154 154
155 | SELECT | FROM | AS | CWHERE | GROUP | BY 155 | SELECT | FROM | AS | CWHERE | GROUP | BY | HAVING
156 | TRUE | FALSE | CAND | OR | NOT 156 | TRUE | FALSE | CAND | OR | NOT
157 | NE | LT | LE | GT | GE 157 | NE | LT | LE | GT | GE
158 158
159 %nonterm 159 %nonterm
160 file of decl list 160 file of decl list
229 | sqlexp of exp 229 | sqlexp of exp
230 | wopt of exp 230 | wopt of exp
231 | groupi of group_item 231 | groupi of group_item
232 | groupis of group_item list 232 | groupis of group_item list
233 | gopt of group_item list option 233 | gopt of group_item list option
234 | hopt of exp
234 235
235 236
236 %verbose (* print summary of errors *) 237 %verbose (* print summary of errors *)
237 %pos int (* positions *) 238 %pos int (* positions *)
238 %start file 239 %start file
643 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright)) 644 | STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
644 | LBRACE eexp RBRACE (eexp) 645 | LBRACE eexp RBRACE (eexp)
645 646
646 query : query1 (query1) 647 query : query1 (query1)
647 648
648 query1 : SELECT select FROM tables wopt gopt 649 query1 : SELECT select FROM tables wopt gopt hopt
649 (let 650 (let
650 val loc = s (SELECTleft, tablesright) 651 val loc = s (SELECTleft, tablesright)
651 652
652 val sel = 653 val sel =
653 case select of 654 case select of
688 in 689 in
689 (ECApp ((EVar (["Basis"], "sql_subset"), loc), 690 (ECApp ((EVar (["Basis"], "sql_subset"), loc),
690 (CRecord tabs, loc)), loc) 691 (CRecord tabs, loc)), loc)
691 end 692 end
692 693
693 val hopt = (sql_inject (EVar (["Basis"], "True"),
694 EVar (["Basis"], "sql_bool"),
695 loc))
696
697 val e = (EVar (["Basis"], "sql_query"), loc) 694 val e = (EVar (["Basis"], "sql_query"), loc)
698 val re = (ERecord [((CName "From", loc), 695 val re = (ERecord [((CName "From", loc),
699 (ERecord tables, loc)), 696 (ERecord tables, loc)),
700 ((CName "Where", loc), 697 ((CName "Where", loc),
701 wopt), 698 wopt),
786 groupis: groupi ([groupi]) 783 groupis: groupi ([groupi])
787 | groupi COMMA groupis (groupi :: groupis) 784 | groupi COMMA groupis (groupi :: groupis)
788 785
789 gopt : (NONE) 786 gopt : (NONE)
790 | GROUP BY groupis (SOME groupis) 787 | GROUP BY groupis (SOME groupis)
788
789 hopt : (sql_inject (EVar (["Basis"], "True"),
790 EVar (["Basis"], "sql_bool"),
791 ErrorMsg.dummySpan))
792 | HAVING sqlexp (sqlexp)