diff options
| author | Damien Doligez <damien.doligez-inria.fr> | 2008-10-06 13:53:54 +0000 |
|---|---|---|
| committer | Damien Doligez <damien.doligez-inria.fr> | 2008-10-06 13:53:54 +0000 |
| commit | 0c26c850b3328258603a0d4fe90fbfa8e8ba0a68 (patch) | |
| tree | 07d935773d8d05895adad7797c2e13cd5611db30 /driver/compile.ml | |
| parent | a76ddd0f1285ed2ac7b761bb4eed17d866196d1a (diff) | |
| download | ocaml-0c26c850b3328258603a0d4fe90fbfa8e8ba0a68.tar.gz | |
"invalid module name" becomes a warning
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9074 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'driver/compile.ml')
| -rw-r--r-- | driver/compile.ml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/driver/compile.ml b/driver/compile.ml index 3cf2c749e6..4e2d8566ec 100644 --- a/driver/compile.ml +++ b/driver/compile.ml @@ -48,6 +48,27 @@ let initial_env () = with Not_found -> fatal_error "cannot open pervasives.cmi" +(* Note: this function is duplicated in optcompile.ml *) +let check_unit_name ppf filename name = + try + begin match name.[0] with + | 'A'..'Z' -> () + | _ -> + Location.print_warning (Location.in_file filename) ppf + (Warnings.Bad_module_name name); + raise Exit; + end; + for i = 1 to String.length name - 1 do + match name.[i] with + | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () + | _ -> + Location.print_warning (Location.in_file filename) ppf + (Warnings.Bad_module_name name); + raise Exit; + done; + with Exit -> () +;; + (* Compile a .mli file *) let interface ppf sourcefile outputprefix = @@ -55,6 +76,7 @@ let interface ppf sourcefile outputprefix = init_path (); let modulename = String.capitalize(Filename.basename(chop_extension_if_any sourcefile)) in + check_unit_name ppf sourcefile modulename; Env.set_unit_name modulename; let inputfile = Pparse.preprocess sourcefile in try @@ -86,6 +108,7 @@ let implementation ppf sourcefile outputprefix = init_path (); let modulename = String.capitalize(Filename.basename(chop_extension_if_any sourcefile)) in + check_unit_name ppf sourcefile modulename; Env.set_unit_name modulename; let inputfile = Pparse.preprocess sourcefile in let env = initial_env() in |
