Mercurial > urweb
comparison src/compiler.sml @ 1743:1e940643a5f0
Report which files lead to duplicate module names
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 04 May 2012 10:38:22 -0400 |
parents | c414850f206f |
children | 675ce534e3ec |
comparison
equal
deleted
inserted
replaced
1742:fca4a6d05ac1 | 1743:1e940643a5f0 |
---|---|
892 end) | 892 end) |
893 | 893 |
894 val moduleRoots = ref ([] : (string * string) list) | 894 val moduleRoots = ref ([] : (string * string) list) |
895 fun addModuleRoot (k, v) = moduleRoots := (k, v) :: !moduleRoots | 895 fun addModuleRoot (k, v) = moduleRoots := (k, v) :: !moduleRoots |
896 | 896 |
897 structure SS = BinarySetFn(struct | 897 structure SK = struct |
898 type ord_key = string | 898 type ord_key = string |
899 val compare = String.compare | 899 val compare = String.compare |
900 end) | 900 end |
901 | |
902 structure SS = BinarySetFn(SK) | |
903 structure SM = BinaryMapFn(SK) | |
901 | 904 |
902 val parse = { | 905 val parse = { |
903 func = fn {database, sources = fnames, ffi, onError, ...} : job => | 906 func = fn {database, sources = fnames, ffi, onError, ...} : job => |
904 let | 907 let |
905 val mrs = !moduleRoots | 908 val mrs = !moduleRoots |
1097 | SOME v => ds @ [(Source.DOnError v, loc)] | 1100 | SOME v => ds @ [(Source.DOnError v, loc)] |
1098 in | 1101 in |
1099 ignore (List.foldl (fn (d, used) => | 1102 ignore (List.foldl (fn (d, used) => |
1100 case #1 d of | 1103 case #1 d of |
1101 Source.DStr (x, _, _, _) => | 1104 Source.DStr (x, _, _, _) => |
1102 if SS.member (used, x) then | 1105 (case SM.find (used, x) of |
1103 (ErrorMsg.errorAt (#2 d) ("Duplicate top-level module name " ^ x); | 1106 SOME loc => |
1104 used) | 1107 (ErrorMsg.error ("Duplicate top-level module name " ^ x); |
1105 else | 1108 Print.prefaces "Files" [("Previous", Print.PD.string (ErrorMsg.spanToString loc)), |
1106 SS.add (used, x) | 1109 ("Current", Print.PD.string (ErrorMsg.spanToString (#2 d)))]; |
1107 | _ => used) SS.empty ds); | 1110 used) |
1111 | NONE => | |
1112 SM.insert (used, x, #2 d)) | |
1113 | _ => used) SM.empty ds); | |
1108 ds | 1114 ds |
1109 end handle Empty => ds | 1115 end handle Empty => ds |
1110 end, | 1116 end, |
1111 print = SourcePrint.p_file | 1117 print = SourcePrint.p_file |
1112 } | 1118 } |