summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-12-11 13:42:54 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2010-12-11 13:42:54 -0500
commit019d9a9c56bab7876983b78613e621d884ec20ae (patch)
tree0819f8da13c6f066806e8c69132013dbf29a795c /src/compiler.sml
parentc1d0d8f52b4896bc34d9eb8937c55d5aa3458751 (diff)
Comments in .urp files
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml18
1 files changed, 13 insertions, 5 deletions
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)