changeset 1722:f7d9dc5d57eb

Antiquote for PRIMARY KEY
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Apr 2012 15:47:02 -0400
parents 5df85275c0d4
children 5ecf67553da8
files doc/manual.tex src/urweb.grm tests/pkeyEscape.ur tests/pkeyEscape.urp
diffstat 4 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/doc/manual.tex	Sat Apr 21 15:19:00 2012 -0400
+++ b/doc/manual.tex	Sat Apr 21 15:47:02 2012 -0400
@@ -2113,7 +2113,7 @@
 $$\begin{array}{rrcll}
   \textrm{Declarations} & d &::=& \mt{table} \; x : c \; [pk[,]] \; cts \mid \mt{view} \; x = V \\
   \textrm{Primary key constraints} & pk &::=& \mt{PRIMARY} \; \mt{KEY} \; K \\
-  \textrm{Keys} & K &::=& f \mid (f, (f,)^+) \\
+  \textrm{Keys} & K &::=& f \mid (f, (f,)^+) \mid \{\{e\}\} \\
   \textrm{Constraint sets} & cts &::=& \mt{CONSTRAINT} f \; ct \mid cts, cts \mid \{\{e\}\} \\
   \textrm{Constraints} & ct &::=& \mt{UNIQUE} \; K \mid \mt{CHECK} \; E \\
   &&& \mid \mt{FOREIGN} \; \mt{KEY} \; K \; \mt{REFERENCES} \; F \; (K) \; [\mt{ON} \; \mt{DELETE} \; pr] \; [\mt{ON} \; \mt{UPDATE} \; pr] \\
--- a/src/urweb.grm	Sat Apr 21 15:19:00 2012 -0400
+++ b/src/urweb.grm	Sat Apr 21 15:47:02 2012 -0400
@@ -300,6 +300,7 @@
  | dcon of string * con option
 
  | pkopt of exp
+ | pk of exp
  | commaOpt of unit
 
  | cst of exp
@@ -707,9 +708,9 @@
 commaOpt:                               ()
         | COMMA                         ()
 
-pkopt  :                                (EVar (["Basis"], "no_primary_key", Infer), dummy)
-       | PRIMARY KEY tnames             (let
-                                             val loc = s (PRIMARYleft, tnamesright)
+pk     : LBRACE LBRACE eexp RBRACE RBRACE (eexp)
+       | tnames                         (let
+                                             val loc = s (tnamesleft, tnamesright)
 
                                              val e = (EVar (["Basis"], "primary_key", TypesOnly), loc)
                                              val e = (ECApp (e, #1 (#1 tnames)), loc)
@@ -725,6 +726,9 @@
                                              (EApp (e, witness), loc)
                                          end)
 
+pkopt  :                                (EVar (["Basis"], "no_primary_key", Infer), dummy)
+       | PRIMARY KEY pk                 (pk)
+
 valis  : vali                           ([vali])
        | vali AND valis                 (vali :: valis)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/pkeyEscape.ur	Sat Apr 21 15:47:02 2012 -0400
@@ -0,0 +1,6 @@
+table t : {A : int, B : int}
+  PRIMARY KEY {{primary_key [#A] [[B = _]]}}
+
+fun main () : transaction page =
+    queryI (SELECT * FROM t) (fn _ => return ());
+    return <xml/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/pkeyEscape.urp	Sat Apr 21 15:47:02 2012 -0400
@@ -0,0 +1,5 @@
+debug
+database dbname=pkeyEscape
+sql pkeyEscape.sql
+
+pkeyEscape