compatible with 4.11

* use the exposed parser to parse longident
This commit is contained in:
ZAN DoYe 2020-05-08 14:54:32 +08:00
parent aa832e280c
commit 952f97a460
3 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,9 @@
next
------------------
* compatible with OCaml 4.11
* switch to the exposed parser
2.5.0 (2020-04-26)
------------------

View File

@ -892,6 +892,14 @@ and find_context_in_quotation = function
| Completion |
+-----------------------------------------------------------------+ *)
#if OCAML_VERSION < (4, 11, 0)
let longident_parse= Longident.parse
#else
let longident_parse str=
let lexbuf= Lexing.from_string str in
Parse.longident lexbuf
#endif
let complete ~phrase_terminator ~input =
let true_name, false_name = ("true", "false") in
let tokens = UTop_lexer.lex_string input in
@ -924,7 +932,7 @@ let complete ~phrase_terminator ~input =
| [(Symbol "#", _); (Lident "typeof", _); (String (tlen, false), loc)] ->
let prefix = String.sub input (loc.ofs1 + tlen) (String.length input - loc.ofs1 - tlen) in
begin match Longident.parse prefix [@ocaml.warning "-3"] with
begin match longident_parse prefix with
| Longident.Ldot (lident, last_prefix) ->
let set = names_of_module lident in
let compls = lookup last_prefix (String_set.elements set) in

View File

@ -437,6 +437,14 @@ type rewrite_rule = {
(* Whether the rule is enabled or not. *)
}
#if OCAML_VERSION < (4, 11, 0)
let longident_parse= Longident.parse
#else
let longident_parse str=
let lexbuf= Lexing.from_string str in
Parse.longident lexbuf
#endif
let longident_lwt_main_run = Longident.Ldot (Longident.Lident "Lwt_main", "run")
let longident_async_thread_safe_block_on_async_exn =
Longident.(Ldot (Ldot (Lident "Async", "Thread_safe"), "block_on_async_exn"))
@ -1182,7 +1190,7 @@ end
+-----------------------------------------------------------------+ *)
let typeof sid =
let id = Longident.parse sid [@ocaml.warning "-3"] in
let id = longident_parse sid in
let env = !Toploop.toplevel_env in
#if OCAML_VERSION >= (4, 10, 0)
let lookup_value= Env.find_value_by_name