changeset 1151:de48dc2c9ee8

Allow .urp files without initial blank lines
author Adam Chlipala <adamc@hcoop.net>
date Sat, 06 Feb 2010 15:34:41 -0500
parents 151837581b5e
children e6eabf0c5ccc
files demo/alert.urp demo/batchFun.urp demo/cookie.urp demo/counter.urp demo/form.urp demo/hello.urp demo/link.urp demo/listEdit.urp demo/listShop.urp demo/metaform1.urp demo/metaform2.urp demo/nested.urp demo/react.urp demo/rec.urp demo/subforms.urp demo/sum.urp demo/tcSum.urp demo/threads.urp doc/manual.tex src/compiler.sml src/demo.sml
diffstat 21 files changed, 30 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/demo/alert.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/alert.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 alert
--- a/demo/batchFun.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/batchFun.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 batchFun
--- a/demo/cookie.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/cookie.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 cookie
--- a/demo/counter.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/counter.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 counter
--- a/demo/form.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/form.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 form
--- a/demo/hello.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/hello.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 hello
--- a/demo/link.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/link.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 link
--- a/demo/listEdit.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/listEdit.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 listEdit
--- a/demo/listShop.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/listShop.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,4 +1,3 @@
-
 list
 listFun
 listShop
--- a/demo/metaform1.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/metaform1.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,3 +1,2 @@
-
 metaform
 metaform1
--- a/demo/metaform2.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/metaform2.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,3 +1,2 @@
-
 metaform
 metaform2
--- a/demo/nested.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/nested.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 nested
--- a/demo/react.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/react.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 react
--- a/demo/rec.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/rec.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 rec
--- a/demo/subforms.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/subforms.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 subforms
--- a/demo/sum.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/sum.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 sum
--- a/demo/tcSum.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/tcSum.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,2 +1,1 @@
-
 tcSum
--- a/demo/threads.urp	Sat Feb 06 13:53:26 2010 -0500
+++ b/demo/threads.urp	Sat Feb 06 15:34:41 2010 -0500
@@ -1,3 +1,2 @@
-
 buffer
 threads
--- a/doc/manual.tex	Sat Feb 06 13:53:26 2010 -0500
+++ b/doc/manual.tex	Sat Feb 06 15:34:41 2010 -0500
@@ -128,7 +128,7 @@
 psql -f crud1.sql test
 \end{verbatim}
 
-A blank line always separates the named directives from a list of modules to include in the project; if there are no named directives, a blank line must begin the file.
+A blank line separates the named directives from a list of modules to include in the project.
 
 For each entry \texttt{M} in the module list, the file \texttt{M.urs} is included in the project if it exists, and the file \texttt{M.ur} must exist and is always included.
 
--- a/src/compiler.sml	Sat Feb 06 13:53:26 2010 -0500
+++ b/src/compiler.sml	Sat Feb 06 15:34:41 2010 -0500
@@ -282,7 +282,25 @@
         fun pu filename =
             let
                 val dir = OS.Path.dir filename
-                val inf = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
+                fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
+
+                val inf = opener ()
+
+                fun hasAnyLine () =
+                    case TextIO.inputLine inf of
+                        NONE => false
+                      | SOME "\n" => false
+                      | _ => true
+
+                fun hasBlankLine () =
+                    case TextIO.inputLine inf of
+                        NONE => false
+                      | SOME "\n" => hasAnyLine ()
+                      | _ => hasBlankLine ()
+
+                val hasBlankLine = hasBlankLine ()
+
+                val inf = (TextIO.closeIn inf; opener ())
 
                 fun pathify fname =
                     if size fname > 0 andalso String.sub (fname, 0) = #"$" then
@@ -591,7 +609,10 @@
                             read ()
                         end
 
-                val job = read ()
+                val job = if hasBlankLine then
+                              read ()
+                          else
+                              finish (readSources [])
             in
                 TextIO.closeIn inf;
                 Settings.setUrlPrefix (#prefix job);
--- a/src/demo.sml	Sat Feb 06 13:53:26 2010 -0500
+++ b/src/demo.sml	Sat Feb 06 15:34:41 2010 -0500
@@ -1,4 +1,4 @@
-(* Copyright (c) 2008, Adam Chlipala
+(* Copyright (c) 2008-2010, Adam Chlipala
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -197,7 +197,8 @@
                                                                         ext = SOME s}
                                          val src' = OS.Path.file src
                                      in
-                                         if String.isPrefix (OS.Path.mkCanonical dirname) src
+                                         if String.isPrefix (OS.Path.mkAbsolute {path = dirname,
+                                                                                 relativeTo = OS.FileSys.getDir ()}) src
                                             andalso OS.FileSys.access (src, []) then
                                              (TextIO.output (out, " | <a target=\"showcase\" href=\"");
                                               TextIO.output (out, src');
@@ -205,7 +206,9 @@
                                               TextIO.output (out, src');
                                               TextIO.output (out, "</tt></a>"))
                                          else
-                                             ()
+                                             print (src ^ " "
+                                                    ^ OS.Path.mkAbsolute {path = dirname,
+                                                                          relativeTo = OS.FileSys.getDir ()} ^ "\n")
                                      end
                              in
                                  ifEx "urs";