diff src/urweb.grm @ 1265:e8d68fd8ed4b

Consider view declarations while shaking
author Adam Chlipala <adamc@hcoop.net>
date Thu, 27 May 2010 15:10:52 -0400
parents c316ca3c9ec6
children d008c4c43a0a
line wrap: on
line diff
--- a/src/urweb.grm	Thu May 27 10:56:52 2010 -0400
+++ b/src/urweb.grm	Thu May 27 15:10:52 2010 -0400
@@ -184,6 +184,26 @@
         PAnnot (_, t) => t
       | _ => (CWild (KType, loc), loc)
 
+fun tnamesOf (e, _) =
+    case e of
+        EApp (e1, e2) => tnamesOf e1 @ tnamesOf e2
+      | ECApp (e, c as (CName _, _)) =>
+        let
+            fun isFt (e, _) =
+                case e of
+                    EVar (["Basis"], "sql_from_table", _) => true
+                  | EVar ([], "sql_from_table", _) => true
+                  | ECApp (e, _) => isFt e
+                  | EApp (e, _) => isFt e
+                  | EDisjointApp e => isFt e
+                  | _ => false
+        in
+            (if isFt e then [c] else []) @ tnamesOf e
+        end
+      | ECApp (e, _) => tnamesOf e
+      | EDisjointApp e => tnamesOf e
+      | _ => []
+
 %%
 %header (functor UrwebLrValsFn(structure Token : TOKEN))
 
@@ -1540,7 +1560,7 @@
                                          end)
 
 fitem  : table'                         ([#1 table'], #2 table')
-       | LBRACE LBRACE eexp RBRACE RBRACE ([], eexp)
+       | LBRACE LBRACE eexp RBRACE RBRACE (tnamesOf eexp, eexp)
        | fitem JOIN fitem ON sqlexp     (let
                                              val loc = s (fitem1left, sqlexpright)