# HG changeset patch # User Adam Chlipala # Date 1292092974 18000 # Node ID a6427d1eda6f1b430dabda74cb830d4f0f3b9891 # Parent 452b14d88a10eefe0c454046af88dd1be256bcf7 Comments in .urp files diff -r 452b14d88a10 -r a6427d1eda6f doc/manual.tex --- a/doc/manual.tex Sun Dec 05 18:47:54 2010 +0100 +++ b/doc/manual.tex Sat Dec 11 13:42:54 2010 -0500 @@ -128,7 +128,7 @@ 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 -r 452b14d88a10 -r a6427d1eda6f src/compiler.sml --- a/src/compiler.sml Sun Dec 05 18:47:54 2010 +0100 +++ b/src/compiler.sml Sat Dec 11 13:42:54 2010 -0500 @@ -310,6 +310,14 @@ 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 @@ 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 @@ 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 @@ (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 -r 452b14d88a10 -r a6427d1eda6f tests/css.urp --- a/tests/css.urp Sun Dec 05 18:47:54 2010 +0100 +++ b/tests/css.urp Sat Dec 11 13:42:54 2010 -0500 @@ -1,1 +1,3 @@ -css +# Comment here +css # Comment at end of line! +# Comments everywhere!