Commit 91584e55 authored by Andrei Paskevich's avatar Andrei Paskevich

accept string literals in use/clone qualifiers

parent b56e22bd
......@@ -117,8 +117,21 @@ let locate_file name lp path =
| [file] -> file
| file1 :: file2 :: _ -> raise (AmbiguousPath (file1, file2))
exception InvalidQualifier of string
let check_qualifier s =
let find_dir_sep s =
let re = Str.regexp_string Filename.dir_sep in
try ignore (Str.search_forward re s 0); true
with Not_found -> false in
if (s = Filename.parent_dir_name ||
s = Filename.current_dir_name ||
find_dir_sep s)
then raise (InvalidQualifier s)
let create_env_of_loadpath lp =
let fc f sl =
List.iter check_qualifier sl;
let file = locate_file f lp sl in
file, open_in file
in
......@@ -176,6 +189,8 @@ let () = Exn_printer.register
Format.fprintf fmt "Format not specified"
| AmbiguousPath (f1,f2) ->
Format.fprintf fmt "Ambiguous path:@ both `%s'@ and `%s'@ match" f1 f2
| InvalidQualifier s ->
Format.fprintf fmt "Invalid qualifier `%s'" s
| _ -> raise exn
end
......@@ -330,10 +330,8 @@ decl:
{ UseClone (floc (), $2, None) }
| CLONE use clone_subst
{ UseClone (floc (), $2, Some $3) }
| META ident list1_meta_arg_sep_comma
| META sident list1_meta_arg_sep_comma
{ Meta (floc (), $2, $3) }
| META STRING list1_meta_arg_sep_comma
{ Meta (floc (), mk_id $2 (floc_i 2), $3) }
;
/* Use and clone */
......@@ -906,8 +904,13 @@ tqualid:
;
any_qualid:
| ident { Qident $1 }
| any_qualid DOT ident { Qdot ($1, $3) }
| sident { Qident $1 }
| any_qualid DOT sident { Qdot ($1, $3) }
;
sident:
| ident { $1 }
| STRING { mk_id $1 (floc ()) }
;
/* Misc */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment