diff options
author | 2008-08-28 12:56:08 -0400 | |
---|---|---|
committer | 2008-08-28 12:56:08 -0400 | |
commit | 86b1f463ce9af2ddfcd86bb75279b9809b22db6a (patch) | |
tree | b356ee03cb6af9e37de926271f5cc02376641fc9 /src | |
parent | fe8bd11ade81a5835d72c498a763c13c17fddd25 (diff) |
More aggregate functions
Diffstat (limited to 'src')
-rw-r--r-- | src/lacweb.grm | 19 | ||||
-rw-r--r-- | src/lacweb.lex | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/lacweb.grm b/src/lacweb.grm index e230d91e..df01558e 100644 --- a/src/lacweb.grm +++ b/src/lacweb.grm @@ -110,7 +110,6 @@ fun sql_compare (oper, sqlexp1, sqlexp2, loc) = let val e = (EVar (["Basis"], "sql_comparison"), loc) val e = (EApp (e, (EVar (["Basis"], "sql_" ^ oper), loc)), loc) - val e = (EApp (e, (EWild, loc)), loc) val e = (EApp (e, sqlexp1), loc) in (EApp (e, sqlexp2), loc) @@ -169,7 +168,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) = | UNION | INTERSECT | EXCEPT | LIMIT | OFFSET | ALL | TRUE | FALSE | CAND | OR | NOT - | COUNT + | COUNT | AVG | SUM | MIN | MAX | NE | LT | LE | GT | GE %nonterm @@ -253,6 +252,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) = | lopt of exp | ofopt of exp | sqlint of exp + | sqlagg of string %verbose (* print summary of errors *) @@ -831,6 +831,16 @@ sqlexp : TRUE (sql_inject (EVar (["Basis"], "True"), (EApp ((EVar (["Basis"], "sql_count"), loc), (ERecord [], loc)), loc) end) + | sqlagg LPAREN sqlexp RPAREN (let + val loc = s (sqlaggleft, RPARENright) + + val e = (EApp ((EVar (["Basis"], "sql_" ^ sqlagg), loc), + (EWild, loc)), loc) + val e = (EApp ((EVar (["Basis"], "sql_aggregate"), loc), + e), loc) + in + (EApp (e, sqlexp), loc) + end) wopt : (sql_inject (EVar (["Basis"], "True"), EVar (["Basis"], "sql_bool"), @@ -892,3 +902,8 @@ ofopt : (EVar (["Basis"], "sql_no_offset"), dum sqlint : INT (EPrim (Prim.Int INT), s (INTleft, INTright)) | LBRACE eexp RBRACE (eexp) + +sqlagg : AVG ("avg") + | SUM ("sum") + | MIN ("min") + | MAX ("max") diff --git a/src/lacweb.lex b/src/lacweb.lex index 08e39c81..5ba2f5c8 100644 --- a/src/lacweb.lex +++ b/src/lacweb.lex @@ -324,6 +324,10 @@ notags = [^<{\n]+; <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext)); <INITIAL> "COUNT" => (Tokens.COUNT (pos yypos, pos yypos + size yytext)); +<INITIAL> "AVG" => (Tokens.AVG (pos yypos, pos yypos + size yytext)); +<INITIAL> "SUM" => (Tokens.SUM (pos yypos, pos yypos + size yytext)); +<INITIAL> "MIN" => (Tokens.MIN (pos yypos, pos yypos + size yytext)); +<INITIAL> "MAX" => (Tokens.MAX (pos yypos, pos yypos + size yytext)); <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext)); <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext)); |