summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-05-27 16:36:17 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-05-27 16:36:17 -0400
commitd6b698a6ad00a5f707ae48af039388687ac9b4ba (patch)
treee323bae4aa24f7a07c4a5c0941b14dc88b97e75a /src/compiler.sml
parent0091af30d2d24940404e49b30a6d0e2a0e4ba4e7 (diff)
-moduleOf command-line option; compatibility fixes and better error messages for SQLite
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index d39122f0..1d15367f 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -1254,4 +1254,23 @@ fun compiler job =
else
OS.Process.exit OS.Process.failure
+fun moduleOf fname =
+ let
+ val mrs = !moduleRoots
+ val fname = OS.Path.mkCanonical fname
+ in
+ case List.find (fn (root, _) => String.isPrefix (root ^ "/") fname) mrs of
+ NONE => capitalize (OS.Path.base (OS.Path.file fname))
+ | SOME (root, name) =>
+ let
+ val fname = OS.Path.base fname
+ val fname = String.extract (fname, size root + 1, NONE)
+ val fs = String.fields (fn ch => ch = #"/") fname
+ val fs = List.filter (CharVector.exists (fn ch => not (Char.isDigit ch))) fs
+ val fs = map capitalize fs
+ in
+ String.concatWith "." (name :: fs)
+ end
+ end
+
end