Mercurial > urweb
comparison src/compiler.sml @ 1773:b5f5e8d439c7
Proper error messages for missing source files
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 26 May 2012 09:16:14 -0400 |
parents | 675ce534e3ec |
children | 85a87f155e7b |
comparison
equal
deleted
inserted
replaced
1772:141f234a91fb | 1773:b5f5e8d439c7 |
---|---|
903 end | 903 end |
904 | 904 |
905 structure SS = BinarySetFn(SK) | 905 structure SS = BinarySetFn(SK) |
906 structure SM = BinaryMapFn(SK) | 906 structure SM = BinaryMapFn(SK) |
907 | 907 |
908 exception MissingFile of string | |
909 | |
908 val parse = { | 910 val parse = { |
909 func = fn {database, sources = fnames, ffi, onError, ...} : job => | 911 func = fn {database, sources = fnames, ffi, onError, ...} : job => |
910 let | 912 let |
911 val mrs = !moduleRoots | 913 val mrs = !moduleRoots |
912 | 914 |
947 fun parseOne fname = | 949 fun parseOne fname = |
948 let | 950 let |
949 val mname = nameOf fname | 951 val mname = nameOf fname |
950 val ur = OS.Path.joinBaseExt {base = fname, ext = SOME "ur"} | 952 val ur = OS.Path.joinBaseExt {base = fname, ext = SOME "ur"} |
951 val urs = OS.Path.joinBaseExt {base = fname, ext = SOME "urs"} | 953 val urs = OS.Path.joinBaseExt {base = fname, ext = SOME "urs"} |
954 | |
955 val () = if Posix.FileSys.access (ur, []) then | |
956 () | |
957 else | |
958 raise MissingFile ur | |
952 | 959 |
953 val sgnO = | 960 val sgnO = |
954 if Posix.FileSys.access (urs, []) then | 961 if Posix.FileSys.access (urs, []) then |
955 SOME (Source.SgnConst (#func parseUrs urs), | 962 SOME (Source.SgnConst (#func parseUrs urs), |
956 {file = urs, | 963 {file = urs, |
1060 end) "" pieces) | 1067 end) "" pieces) |
1061 end | 1068 end |
1062 in | 1069 in |
1063 checkErrors (); | 1070 checkErrors (); |
1064 d | 1071 d |
1065 end | 1072 end handle MissingFile fname => (ErrorMsg.error ("Missing source file: " ^ fname); |
1073 (Source.DSequence "", ErrorMsg.dummySpan)) | |
1066 | 1074 |
1067 val dsFfi = map parseFfi ffi | 1075 val dsFfi = map parseFfi ffi |
1068 val ds = map parseOne fnames | 1076 val ds = map parseOne fnames |
1069 val loc = ErrorMsg.dummySpan | 1077 val loc = ErrorMsg.dummySpan |
1070 in | 1078 in |