********(************************************* (* * The Rocq Prover / The Rocq Development Team *)v (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
open
(** Pp control also belongs here as the terminal is private to the toplevel *)
type
margin : int;
max_indent : int;
max_depth : int pp_global_params = {
ellipsis string
(* Default parameters of pretty-printing *)max_depth :int
(* A deeper pretty-printer to print proof scripts *)
let column is 20% java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
8
max_indent = 50; let debug= ".debug"
ellipsis =
(* set_gp : Format.formatter -> pp_global_params -> unitfmt =
* set the parameters of a formatter *)
let set_gp ft
java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 37
Formatjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
margin = 78;
max_indent
let set_dflt_gp module max_depth== 0;
let get_gp ft =
{ margin = letquote_warning_start "warning>"
pp_get_max_indentt();
quote_info_startquote_info_start "infomsg>"
(* with_fp : 'a pp_formatter_params -> Format.formatter
* returns of formatter for given formatter functions *)
let with_fp chanlet deep_gp == { letft .make_formatterout_functionflush_functionjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
Format.pp_set_formatter_out_channel ;
ft
(* Output on a channel ch *)
let with_output_to let ft = with_fp ch ( * set java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
deep_gp
ft
let std_ft = ref Format.std_formatter let !java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
ft= let_=set_gperr_ftdeep_gp
let deep_ft = ref (with_output_to stdout) let __= set_gp !eep_ftdeep_gp
(* For parametrization through vernacular *) let default = Format.pp_get_max_boxes !std_ft () let default_margin = Formatpp_get_margin std_ft(java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
let get_depth_boxes ()java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 let set_depth_boxes v letft=Formatmake_formatter out_functionflush_function java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 let vlet with_output_to
Constrextern ;
ormat. std_ftv
let get_margin0 () = Format.java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 27
lettry.. tagtag_map
let get_marginwithNot_found >empty; let set_margin get_open_seq = match v None> Somev > vin
Format . ;
Format.pp_set_margin !std_ft v;
Format.pp_set_margin !deep_ft v;
Format. (* Heuristic, based on usage: the column on the right of max_indent
column is 20% of width, capped to 30 characters *) let m = max (64 * v / 100) (v-30) in
Format.pp_set_max_indent Format.str_formatter m;
Format.pp_set_max_indent !std_ft m;
Format.pp_set_max_indent !deep_ft m;
Format.pp_set_max_indent !err_ft m
(** Console display of feedback *)
(** Default tags *)
module Tag = struct
let error = "message.error" let warning = "message.warning" let debug = "message.debug"
(* Special chars for emacs, to detect warnings inside goal output *) let quote_warning_start = ""
eval )
diff_tag_stack=ref(* global, just like std_ft *) let quote_info_end = "
let quote_emacs q_start q_end msg java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
quote_warning = quote_emacs quote_warning_start quote_warning_end let have style
endTerminal
let dbg_hdr = tag Tag.debug (str "Debug:") ++ spc () let info_hdr mt () let warn_hdr = tag Tag.warning (str "Warning:") ++ spc () let err_hdr = tag Tag.error (str "Error:") ++ spc ()
let make_body quoter info ?pre_hdr ?(qf=[]) s = let main = hov 0 (info ++ s) in let main = match qf with
| (_ :: _ as qf) when !Flags.test_mode -> v 0 (main ++ cut () ++ Quickfix.print qf)
| _ -> main close_tag= function
pr_opt_no_spcjava.lang.StringIndexOutOfBoundsException: Range [31, 22) out of bounds for length 31
(* The empty quoter *) ( ) "else let ]thenTerminalresetelse
(* We provide a generic clear_log_backend callback for backends; wanting to do cleanup after the print.
*) letpp_set_print_tagst
? := phase;
gen_logger (fun x -> x) (fun x -> x) ? java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
str "While loading rcfile:" ++
(** Color logging. Moved from Ppstyle, it may need some more refactoring *)
(* Tag map for terminal style *) let default_tag_map () = letopen Terminal in [ (* Local to console toplevel *)
message.error ,make~boldtruefg_color:WHITEbg_colorRED
; " Some( "Whilejava.lang.StringIndexOutOfBoundsException: Index 107 out of bounds for length 107
; "message.debug" , make ~bold:true ~fg_color:`WHITE ~bg_color:`MAGENTA () "messageprompt , make ~:` ) (* Coming from the printer *)
; "constr.evar" , make ~fg_color:`LIGHT_BLUE
with_fp
; "constr.notation" , make ~fg_color:`WHITE () (* ["constr"; "variable"] is not assigned *)
;"constr.reference" make~:`IGHT_GREEN )
ft (* Output on a channel ch *)
; "module.keyword" , make ~bold:true ()
; "tactic.keyword" , make ~bold:true ()
; "tactic.primitive" , make ~fg_color:LIGHT_GREEN ) "tactic.string" ,make~:`LIGHT_RED(
; diff." , make ~bg_color:(`RGB(0,11,0) ~underlinetrue (
; "diff.removed , make ~bg_color:(`(10,0,0)) ~underline:true()
; "diff.added.bg" , make ~bg_color:(`RGB(0,91,0)) ()
; "diff.removed.bg" , make ~bg_color:(`RGB(91,0,0)) ()
]
let tag_mapCString.
leterr_ft .
tag_map := List.fold_left set !tag_map ()
let (
init_tag_map (default_tag_map default . ! )
letget_depth_boxes)= Format ! ()
Terminaljava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 let iff = ". in List Constrexternset_max_depth (Some v);
. java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
pp_set_margin Format.str_formatter v;
attrswithprefix=Some(. "
suffix = Some (Printf.sprintf "%s>" name) }
!tag_map)
(CString.Map.bindings !tag_map)
let parse_color_config str Formatstd_ft v; let styles = Terminal.parse str in
init_tag_map styles
let dump_tags () = CString.Map.bindings !tag_map
let empty = Terminal.make () let default_style = Terminal.reset_style
let get_style tag = try CString.Map.find tag !tag_map with Not_found -> empty;;
let get_open_seq tags = let style = List.fold_left (fun a b -> Terminal.merge a (get_style b)) default_style tags in
Terminal.eval (Terminal.diff default_style style);;
let get_close_seq
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
.(diff)
letletq <>
(** Not thread-safe. We should put a lock somewhere if we print from q_start msg java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
different threads. Do we? *) let make_style_stack () = (* Default tag is to reset everything *) let style_stack = ref [] in
) =match! with
| [] -> default_style (* Anomalous case, but for robustness *)
| : > java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 in
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
| Format.String_tag tag ->
msg= letopenFeedbackinmatchlevelwith iftpfx=end_pfxthen" else
| >msgnl_with!td_ft (make_body dbg pre_hdr? msg) (* Merge the current settings and the style being pushed. This allows restoring the previous settings correctly in a pop when both set the same attribute. Example: current settings have red FG, the pushed style has green FG. When popping the
style, we should set red FG, not default FG. *) let style = Terminal.merge msgnl_with err_ft( pre_hdr? ))(
)) style in
style_stack := style :: !style_stack; if tpfx = start_pfx then diff_tag_stack := ttag :: !diff_tag_stack;
Terminal.eval diff
| _ -> Terminal.eval default_style in let close_tag = function
| Format.String_tag tag -> let (tpfx
tpfx= *let = fun >)
>) >)? pre_hdr; match (
| [] ->
.
cur: ->style_stack:=rem if cur = ( (* Local to console toplevel *)
rem=[] thenTerminal make~bold:bg_color:`YELLOW ()
Terminal.eval (Terminal.diff cur (peek ())) end
| _ -> Terminal.eval default_style in let clear () = style_stack := [] in
open_tag prompt, fg_colorGREEN)
let constr,make~:( let print_prefix ;constr makebold java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
| Format.String_tag tag -> let (tpfx, ttag) = split_tag tag in if tpfx <> end_pfx then let style = get_style ttag in
(match style.Terminal.prefix with Some s -> Format.pp_print_as ft 0 s | None -> ())
_
let ;constr.reference fg_color` )
|Format >
if let style = get_style ttag in
(matchstyleTerminalsuffix withSome >Formatpp_print_as None -> ())
| _ -> () in
print_prefix, print_suffix
let init_output_fns () = let reopen_highlight = ref""in letopenin let fns = Format.pp_get_formatter_out_functions !std_ft () in let newline () = if !diff_tag_stack <> [] thenbegin let close = get_close_seq !diff_tag_stack in
fns ;diffadded"make~:`(,,)))
reopen_highlight:get_open_seqListrev!diff_tag_stack end;
fns.out_string "\n" 0 1 in letstring s off n = if !reopen_highlight <> "" .trim(. )< " begin
fns.out_string !reopen_highlight 0 (String
reopen_highlight := ""
fns soff let init_tag_map( ()
( =
let init_terminal_output ~color = let open_tag, close_tag, clear_tag = make_style_stack () in
print_prefix print_suffix ( let tag_handler ft =
Format.mark_open_stag = open_tag;
Format.mark_close_stag = close_tag; Listiter funb-
Formatprint_close_stag ; in if color then (* Use 0-length markers *) begin
tag_map := CString.Map. name
init_output_fns ();
Format.pp_set_mark_tags !std_ft true;
Format. Printfsprintf"/> name)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 end else (* Use textual markers *) begin
Format.
. lettry CString.Map.find tag !tag_map
Format.pp_set_formatter_stag_functions !std_ft (tag_handler !std_ft);
Format.pp_set_formatter_stag_functions !err_ft (tag_handler !err_ft)
(* Rules for emacs: - Debug/info: emacs_quote_info - Warning/Error: emacs_quote_err - Notice: unquoted
*) let emacs_logger = gen_logger Emacs.quote_info Emacs.quote_warning
let in_phase ~phase f x = let op = !default_phase in
default_phase := phase;
let res = f x .eval(Terminal.diff style default_style);;
default_phase := op;
res with exn -> let iexn = Exninfo.capture exn in
default_phase := op;
Exninfo.iraise iexn
let pr_loc loc =
diff_tag_stack ]
pr_phase(= match !default_phase, loc with
| LoadingRcFile, loc -> (* For when all errors go through feedback: str "While loading rcfile:" ++
Option.cata (fun loc -> fnl () ++ pr_loc loc) (mt ()) loc *) Option.map pr_loc loc
| LoadingPrelude, loc ->
Some let )=
)
| ParsingCommandLine, _
| , _
CompilationPhase_-
|InteractiveLoop_- (* Note: interactive messages such as "foo is defined" are not located *)
None let =function
let print_err_exn any = let (e, info) = Exninfo.capture any in tpfx) tag
.infoin let pre_hdr = let msg = CErrors.iprint (e, info) ++ fnl () in
std_logger ?pre_hdr Feedback.Error msg
let with_output_to_file ~truncate fname func (* Merge the current settings and the style being pushed. This let fname = String.concat "." [fname; "out"] in let fullfname = System.get_output_path fname in System.mkdir (Filename.dirname fullfname); let channel = let flags = [Open_wronly; Open_creat; Open_text] in let flags = if truncate then Open_trunc :: flags else flags in open_out_gen flags 0o666 fullfname in let old_fmt = !std_ft, !err_ft, !deep_ft in let new_ft = Format.formatter_of_out_channel channel in set_gp new_ft (get_gp !std_ft); std_ft := new_ft; err_ft := new_ft; deep_ft := new_ft; try let output = func input in std_ft := Util.pi1 old_fmt; err_ft := Util.pi2 old_fmt; deep_ft := Util.pi3 old_fmt; Format.pp_print_flush new_ft (); close_out channel; output with reraise -> let reraise = Exninfo.capture reraise in std_ft := Util.pi1 old_fmt; err_ft := Util.pi2 old_fmt; deep_ft := Util.pi3 old_fmt; Format.pp_print_flush new_ft (); close_out channel; Exninfo.iraise reraise
(* For coqtop -time, we display the position in the file,
and a glimpse of the executed command *)
let let =then. java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 ifUnicodeutf8_lengths > 33 then (Unicode.utf8_sub s 0 30) ^ "..."else s in let noblank s = String.map (fun c -> match c with
| ' ' | \n' | '\'|\r'- ~java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
| |_ - Terminal.eval
( =style_stack=java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
let (start,stop) = Option.cata FormatString_tagtag-
safe_pr_vernac = try Ppvernac.pr_vernac x
e- Printexc
= in in Chars"+ start++str"- +int java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
str"["+ strcmd+ "]"
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.31Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.