summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.tex2
-rw-r--r--src/compiler.sml18
-rw-r--r--tests/css.urp4
3 files changed, 17 insertions, 7 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index 44fe8bdc..2cbfefb3 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -128,7 +128,7 @@ createdb test
psql -f crud1.sql test
\end{verbatim}
-A blank line separates the named directives from a list of modules to include in the project.
+A blank line separates the named directives from a list of modules to include in the project. Any line may contain a shell-script-style comment, where any suffix of a line starting at a hash character \texttt{\#} is ignored.
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.
diff --git a/src/compiler.sml b/src/compiler.sml
index c4e8977f..63db1b87 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -310,6 +310,14 @@ fun institutionalizeJob (job : job) =
Settings.setSafeGets (#safeGets job);
Settings.setOnError (#onError job))
+fun inputCommentableLine inf =
+ Option.map (fn s =>
+ let
+ val s = #1 (Substring.splitl (fn ch => ch <> #"#") (Substring.full s))
+ in
+ Substring.string (#1 (Substring.splitr (not o Char.isSpace) s))
+ end) (TextIO.inputLine inf)
+
fun parseUrp' accLibs fname =
if not (Posix.FileSys.access (fname ^ ".urp", []) orelse Posix.FileSys.access (fname ^ "/lib.urp", []))
andalso Posix.FileSys.access (fname ^ ".ur", []) then
@@ -359,9 +367,9 @@ fun parseUrp' accLibs fname =
val inf = opener ()
fun hasSpaceLine () =
- case TextIO.inputLine inf of
+ case inputCommentableLine inf of
NONE => false
- | SOME s => s = "debug\n" orelse s = "profile\n"
+ | SOME s => s = "debug" orelse s = "profile"
orelse CharVector.exists (fn ch => ch = #" " orelse ch = #"\t") s orelse hasSpaceLine ()
val hasBlankLine = hasSpaceLine ()
@@ -412,7 +420,7 @@ fun parseUrp' accLibs fname =
OS.Path.mkAbsolute {path = pathify fname, relativeTo = absDir}
fun readSources acc =
- case TextIO.inputLine inf of
+ case inputCommentableLine inf of
NONE => rev acc
| SOME line =>
let
@@ -573,9 +581,9 @@ fun parseUrp' accLibs fname =
(Settings.Exact, s)
fun read () =
- case TextIO.inputLine inf of
+ case inputCommentableLine inf of
NONE => finish []
- | SOME "\n" => finish (readSources [])
+ | SOME "" => finish (readSources [])
| SOME line =>
let
val (cmd, arg) = Substring.splitl (fn x => not (Char.isSpace x)) (Substring.full line)
diff --git a/tests/css.urp b/tests/css.urp
index dac138d9..08a48817 100644
--- a/tests/css.urp
+++ b/tests/css.urp
@@ -1 +1,3 @@
-css
+# Comment here
+css # Comment at end of line!
+# Comments everywhere!