summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-08-21 16:00:01 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-08-21 16:00:01 -0400
commit535d72045b35d01cf4513af273262c3c50c219fe (patch)
treeaca827d739a146f42091ceb29e614392b63c561a /src
parent5334dee9b387e718de785ee8578219d854755002 (diff)
LIMIT
Diffstat (limited to 'src')
-rw-r--r--src/lacweb.grm19
-rw-r--r--src/lacweb.lex2
2 files changed, 19 insertions, 2 deletions
diff --git a/src/lacweb.grm b/src/lacweb.grm
index b4256f30..0809842d 100644
--- a/src/lacweb.grm
+++ b/src/lacweb.grm
@@ -164,6 +164,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
| SELECT | FROM | AS | CWHERE | GROUP | ORDER | BY | HAVING
| UNION | INTERSECT | EXCEPT
+ | LIMIT | OFFSET
| TRUE | FALSE | CAND | OR | NOT
| NE | LT | LE | GT | GE
@@ -245,6 +246,8 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
| hopt of exp
| obopt of exp
| obexps of exp
+ | lopt of exp
+ | sqlint of exp
%verbose (* print summary of errors *)
@@ -658,13 +661,15 @@ attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTri
| STRING (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
| LBRACE eexp RBRACE (eexp)
-query : query1 obopt (let
+query : query1 obopt lopt (let
val loc = s (query1left, query1right)
val re = (ERecord [((CName "Rows", loc),
query1),
((CName "OrderBy", loc),
- obopt)], loc)
+ obopt),
+ ((CName "Limit", loc),
+ lopt)], loc)
in
(EApp ((EVar (["Basis"], "sql_query"), loc), re), loc)
end)
@@ -844,3 +849,13 @@ obexps : sqlexp (let
in
(EApp (e, obexps), loc)
end)
+
+lopt : (EVar (["Basis"], "sql_no_limit"), dummy)
+ | LIMIT sqlint (let
+ val loc = s (LIMITleft, sqlintright)
+ in
+ (EApp ((EVar (["Basis"], "sql_limit"), loc), sqlint), loc)
+ end)
+
+sqlint : INT (EPrim (Prim.Int INT), s (INTleft, INTright))
+ | LBRACE eexp RBRACE (eexp)
diff --git a/src/lacweb.lex b/src/lacweb.lex
index 5c87ae17..8ec07c41 100644
--- a/src/lacweb.lex
+++ b/src/lacweb.lex
@@ -309,6 +309,8 @@ notags = [^<{\n]+;
<INITIAL> "ORDER" => (Tokens.ORDER (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> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext));
+<INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext));
<INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext));
<INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));