diff src/compiler.sml @ 1266:459a334345ae

-moduleOf command-line option; compatibility fixes and better error messages for SQLite
author Adam Chlipala <adamc@hcoop.net>
date Thu, 27 May 2010 16:36:17 -0400
parents 79b2bcac6200
children 56bd4a4f6e66
line wrap: on
line diff
--- a/src/compiler.sml	Thu May 27 15:10:52 2010 -0400
+++ b/src/compiler.sml	Thu May 27 16:36:17 2010 -0400
@@ -1254,4 +1254,23 @@
     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