diff src/lacweb.grm @ 231:eadeea528f75

LIMIT
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 Aug 2008 16:00:01 -0400
parents 87d41ac28b30
children a338da9d82f3
line wrap: on
line diff
--- a/src/lacweb.grm	Thu Aug 21 15:50:08 2008 -0400
+++ b/src/lacweb.grm	Thu Aug 21 16:00:01 2008 -0400
@@ -164,6 +164,7 @@
 
  | 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 @@
  | hopt of exp
  | obopt of exp
  | obexps of exp
+ | lopt of exp
+ | sqlint of exp
 
 
 %verbose                                (* print summary of errors *)
@@ -658,13 +661,15 @@
        | 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 @@
                                          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)