summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-08-21 14:09:08 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-08-21 14:09:08 -0400
commit919c2a950ff74af266791e88a258c7ff09be4839 (patch)
tree02d23cc3d6d72e84b9232fd999fa1dd614990ef4 /src
parent4832e63e1f6c7b5bb7c098e371c794111f32f878 (diff)
GROUP BY and HAVING
Diffstat (limited to 'src')
-rw-r--r--src/lacweb.grm14
-rw-r--r--src/lacweb.lex1
2 files changed, 9 insertions, 6 deletions
diff --git a/src/lacweb.grm b/src/lacweb.grm
index c9fe7a6c..dd1cd201 100644
--- a/src/lacweb.grm
+++ b/src/lacweb.grm
@@ -152,7 +152,7 @@ fun sql_unary (oper, sqlexp, loc) =
| NOTAGS of string
| BEGIN_TAG of string | END_TAG of string
- | SELECT | FROM | AS | CWHERE | GROUP | BY
+ | SELECT | FROM | AS | CWHERE | GROUP | BY | HAVING
| TRUE | FALSE | CAND | OR | NOT
| NE | LT | LE | GT | GE
@@ -231,6 +231,7 @@ fun sql_unary (oper, sqlexp, loc) =
| groupi of group_item
| groupis of group_item list
| gopt of group_item list option
+ | hopt of exp
%verbose (* print summary of errors *)
@@ -645,7 +646,7 @@ attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTri
query : query1 (query1)
-query1 : SELECT select FROM tables wopt gopt
+query1 : SELECT select FROM tables wopt gopt hopt
(let
val loc = s (SELECTleft, tablesright)
@@ -690,10 +691,6 @@ query1 : SELECT select FROM tables wopt gopt
(CRecord tabs, loc)), loc)
end
- val hopt = (sql_inject (EVar (["Basis"], "True"),
- EVar (["Basis"], "sql_bool"),
- loc))
-
val e = (EVar (["Basis"], "sql_query"), loc)
val re = (ERecord [((CName "From", loc),
(ERecord tables, loc)),
@@ -788,3 +785,8 @@ groupis: groupi ([groupi])
gopt : (NONE)
| GROUP BY groupis (SOME groupis)
+
+hopt : (sql_inject (EVar (["Basis"], "True"),
+ EVar (["Basis"], "sql_bool"),
+ ErrorMsg.dummySpan))
+ | HAVING sqlexp (sqlexp)
diff --git a/src/lacweb.lex b/src/lacweb.lex
index 0a7d2433..5c8b9d11 100644
--- a/src/lacweb.lex
+++ b/src/lacweb.lex
@@ -297,6 +297,7 @@ notags = [^<{\n]+;
<INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext));
<INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext));
<INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext));
+<INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext));
<INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext));
<INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext));