From 919c2a950ff74af266791e88a258c7ff09be4839 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 21 Aug 2008 14:09:08 -0400 Subject: GROUP BY and HAVING --- src/lacweb.grm | 14 ++++++++------ src/lacweb.lex | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') 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]+; "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext)); "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext)); "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext)); + "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext)); "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext)); "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext)); -- cgit v1.2.3