diff src/urweb.grm @ 1045:36efaf119b85

Refactor compile functions; allow empty tag contents
author Adam Chlipala <adamc@hcoop.net>
date Wed, 25 Nov 2009 08:52:32 -0500
parents 1d456a06ea4e
children e933297c4e24
line wrap: on
line diff
--- a/src/urweb.grm	Wed Nov 25 08:38:12 2009 -0500
+++ b/src/urweb.grm	Wed Nov 25 08:52:32 2009 -0500
@@ -289,6 +289,7 @@
  | rexp of (con * exp) list
  | xml of exp
  | xmlOne of exp
+ | xmlOpt of exp
  | tag of (string * exp) * exp
  | tagHead of string * exp
  | bind of string * con option * exp
@@ -1294,6 +1295,11 @@
                                          end)
        | xmlOne                         (xmlOne)
 
+xmlOpt : xml                            (xml)
+       |                                (EApp ((EVar (["Basis"], "cdata", Infer), dummy),
+                                               (EPrim (Prim.String ""), dummy)),
+                                         dummy)
+
 xmlOne : NOTAGS                         (EApp ((EVar (["Basis"], "cdata", Infer), s (NOTAGSleft, NOTAGSright)),
                                                (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))),
                                          s (NOTAGSleft, NOTAGSright))
@@ -1318,25 +1324,25 @@
                                              (EApp (#2 tag, cdata), pos)
                                          end)
          
-       | tag GT xml END_TAG             (let
+       | tag GT xmlOpt END_TAG          (let
                                              val pos = s (tagleft, GTright)
                                              val et = tagIn END_TAG
                                          in
                                              if #1 (#1 tag) = et then
                                                  if et = "form" then
                                                      (EApp ((EVar (["Basis"], "form", Infer), pos),
-                                                            xml), pos)
+                                                            xmlOpt), pos)
                                                  else if et = "subform" then
                                                      (EApp ((EDisjointApp (#2 (#1 tag)), pos),
-                                                            xml), pos)
+                                                            xmlOpt), pos)
                                                  else if et = "subforms" then
                                                      (EApp ((EDisjointApp (#2 (#1 tag)), pos),
-                                                            xml), pos)
+                                                            xmlOpt), pos)
                                                  else if et = "entry" then
                                                      (EApp ((EVar (["Basis"], "entry", Infer), pos),
-                                                            xml), pos)
+                                                            xmlOpt), pos)
                                                  else
-                                                     (EApp (#2 tag, xml), pos)
+                                                     (EApp (#2 tag, xmlOpt), pos)
                                              else
                                                  (if ErrorMsg.anyErrors () then
                                                       ()