diff options
author | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-04-07 03:45:27 +0200 |
---|---|---|
committer | Emilio Jesus Gallego Arias <e+git@x80.org> | 2017-04-12 16:49:46 +0200 |
commit | b63b9a86b09856262b5b7bb2b3bb01f704032d41 (patch) | |
tree | b7480e3d41a1dd418c98f73034fc907df1ffbcac /toplevel | |
parent | cf24cedb2926fa00db222eeac48e88a6078b4444 (diff) |
[toplevel] [stm] cleanup in module open
Diffstat (limited to 'toplevel')
-rw-r--r-- | toplevel/coqloop.ml | 27 | ||||
-rw-r--r-- | toplevel/coqtop.ml | 21 |
2 files changed, 20 insertions, 28 deletions
diff --git a/toplevel/coqloop.ml b/toplevel/coqloop.ml index 9478542c1..4641a2bc8 100644 --- a/toplevel/coqloop.ml +++ b/toplevel/coqloop.ml @@ -7,11 +7,6 @@ (************************************************************************) open Pp -open CErrors -open Util -open Flags -open Vernac -open Pcoq let top_stderr x = Format.fprintf !Topfmt.err_ft "@[%a@]%!" pp_with x @@ -24,7 +19,7 @@ type input_buffer = { mutable str : Bytes.t; (* buffer of already read characters *) mutable len : int; (* number of chars in the buffer *) mutable bols : int list; (* offsets in str of beginning of lines *) - mutable tokens : Gram.coq_parsable; (* stream of tokens *) + mutable tokens : Pcoq.Gram.coq_parsable; (* stream of tokens *) mutable start : int } (* stream count of the first char of the buffer *) (* Double the size of the buffer. *) @@ -61,7 +56,7 @@ let prompt_char ic ibuf count = | ll::_ -> Int.equal ibuf.len ll | [] -> Int.equal ibuf.len 0 in - if bol && not !print_emacs then top_stderr (str (ibuf.prompt())); + if bol && not !Flags.print_emacs then top_stderr (str (ibuf.prompt())); try let c = input_char ic in if c == '\n' then ibuf.bols <- (ibuf.len+1) :: ibuf.bols; @@ -78,7 +73,7 @@ let reset_input_buffer ic ibuf = ibuf.str <- Bytes.empty; ibuf.len <- 0; ibuf.bols <- []; - ibuf.tokens <- Gram.parsable (Stream.from (prompt_char ic ibuf)); + ibuf.tokens <- Pcoq.Gram.parsable (Stream.from (prompt_char ic ibuf)); ibuf.start <- 0 (* Functions to print underlined locations from an input buffer. *) @@ -89,7 +84,7 @@ module TopErr = struct let get_bols_of_loc ibuf (bp,ep) = let add_line (b,e) lines = - if b < 0 || e < b then anomaly (Pp.str "Bad location"); + if b < 0 || e < b then CErrors.anomaly (Pp.str "Bad location"); match lines with | ([],None) -> ([], Some (b,e)) | (fl,oe) -> ((b,e)::fl, oe) @@ -174,7 +169,7 @@ let error_info_for_buffer ?loc buf = let fname = loc.Loc.fname in let hl, loc = (* We are in the toplevel *) - if String.equal fname "" then + if CString.equal fname "" then let nloc = adjust_loc_buf buf loc in if valid_buffer_loc buf loc then (fnl () ++ print_highlight_location buf nloc, nloc) @@ -223,7 +218,7 @@ let make_emacs_prompt() = let pending = Stm.get_all_proof_names() in let pendingprompt = List.fold_left - (fun acc x -> acc ^ (if String.is_empty acc then "" else "|") ^ Names.Id.to_string x) + (fun acc x -> acc ^ (if CString.is_empty acc then "" else "|") ^ Names.Id.to_string x) "" pending in let proof_info = if dpth >= 0 then string_of_int dpth else "0" in if !Flags.print_emacs then statnum ^ " |" ^ pendingprompt ^ "| " ^ proof_info ^ " < " @@ -243,7 +238,7 @@ let top_buffer = str = Bytes.empty; len = 0; bols = []; - tokens = Gram.parsable (Stream.of_list []); + tokens = Pcoq.Gram.parsable (Stream.of_list []); start = 0 } let set_prompt prompt = @@ -260,7 +255,7 @@ let parse_to_dot = | Tok.EOI -> raise Stm.End_of_input | _ -> dot st in - Gram.Entry.of_parser "Coqtoplevel.dot" dot + Pcoq.Gram.Entry.of_parser "Coqtoplevel.dot" dot (* If an error occurred while parsing, we try to read the input until a dot token is encountered. @@ -268,7 +263,7 @@ let parse_to_dot = let rec discard_to_dot () = try - Gram.entry_parse parse_to_dot top_buffer.tokens + Pcoq.Gram.entry_parse parse_to_dot top_buffer.tokens with | Token.Error _ | CLexer.Error.E _ -> discard_to_dot () | Stm.End_of_input -> raise Stm.End_of_input @@ -280,7 +275,7 @@ let read_sentence sid input = let reraise = CErrors.push reraise in discard_to_dot (); TopErr.print_toplevel_parse_error reraise top_buffer; - iraise reraise + Exninfo.iraise reraise (** Coqloop Console feedback handler *) let coqloop_feed (fb : Feedback.feedback) = let open Feedback in @@ -312,7 +307,7 @@ let coqloop_feed (fb : Feedback.feedback) = let open Feedback in let do_vernac sid = top_stderr (fnl()); - if !print_emacs then top_stderr (str (top_buffer.prompt())); + if !Flags.print_emacs then top_stderr (str (top_buffer.prompt())); resynch_buffer top_buffer; try let input = (top_buffer.tokens, None) in diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml index 6f9ffe02b..d3c89ede8 100644 --- a/toplevel/coqtop.ml +++ b/toplevel/coqtop.ml @@ -8,11 +8,8 @@ open Pp open CErrors -open Util open Flags -open Names open Libnames -open States open Coqinit let () = at_exit flush_all @@ -133,10 +130,10 @@ let engage () = let set_batch_mode () = batch_mode := true -let toplevel_default_name = DirPath.make [Id.of_string "Top"] +let toplevel_default_name = Names.(DirPath.make [Id.of_string "Top"]) let toplevel_name = ref toplevel_default_name let set_toplevel_name dir = - if DirPath.is_empty dir then error "Need a non empty toplevel module name"; + if Names.DirPath.is_empty dir then error "Need a non empty toplevel module name"; toplevel_name := dir let remove_top_ml () = Mltop.remove () @@ -150,9 +147,9 @@ let set_inputstate s = warn_deprecated_inputstate (); inputstate:=s let inputstate () = - if not (String.is_empty !inputstate) then + if not (CString.is_empty !inputstate) then let fname = Loadpath.locate_file (CUnix.make_suffix !inputstate ".coq") in - intern_state fname + States.intern_state fname let warn_deprecated_outputstate = CWarnings.create ~name:"deprecated-outputstate" ~category:"deprecated" @@ -164,9 +161,9 @@ let set_outputstate s = warn_deprecated_outputstate (); outputstate:=s let outputstate () = - if not (String.is_empty !outputstate) then + if not (CString.is_empty !outputstate) then let fname = CUnix.make_suffix !outputstate ".coq" in - extern_state fname + States.extern_state fname let set_include d p implicit = let p = dirpath_of_string p in @@ -379,7 +376,7 @@ let get_host_port opt s = let get_error_resilience opt = function | "on" | "all" | "yes" -> `All | "off" | "no" -> `None - | s -> `Only (String.split ',' s) + | s -> `Only (CString.split ',' s) let get_task_list s = List.map int_of_string (Str.split (Str.regexp ",") s) @@ -624,7 +621,7 @@ let init_toplevel arglist = init_load_path (); Option.iter Mltop.load_ml_object_raw !toploop; let extras = !toploop_init extras in - if not (List.is_empty extras) then begin + if not (CList.is_empty extras) then begin prerr_endline ("Don't know what to do with "^String.concat " " extras); prerr_endline "See -help for the list of supported options"; exit 1 @@ -633,7 +630,7 @@ let init_toplevel arglist = inputstate (); Mltop.init_known_plugins (); engage (); - if (not !batch_mode || List.is_empty !compile_list) + if (not !batch_mode || CList.is_empty !compile_list) && Global.env_is_initial () then Declaremods.start_library !toplevel_name; init_library_roots (); |