text stringlengths 12 786k |
|---|
let pp_print_if_newline state ( ) = if state . pp_curr_depth < state . pp_max_boxes then enqueue_advance state { size = Size . zero ; token = Pp_if_newline ; length = 0 } |
let pp_print_custom_break state ~ fits ~ breaks = let before , width , after = fits in if state . pp_curr_depth < state . pp_max_boxes then let size = Size . of_int ( - state . pp_right_total ) in let token = Pp_break { fits ; breaks } in let length = String . length before + width + ... |
let pp_print_break state width offset = pp_print_custom_break state ~ fits ( " " , : width , " " ) ~ breaks ( " " , : offset , " " ) |
let pp_print_space state ( ) = pp_print_break state 1 0 |
let pp_open_tbox state ( ) = state . pp_curr_depth <- state . pp_curr_depth + 1 ; if state . pp_curr_depth < state . pp_max_boxes then let size = Size . zero in let elem = { size ; token = Pp_tbegin ( Pp_tbox ( ref [ ] ) ) ; length = 0 } in enqueue_advance state elem |
let pp_close_tbox state ( ) = if state . pp_curr_depth > 1 then begin if state . pp_curr_depth < state . pp_max_boxes then let elem = { size = Size . zero ; token = Pp_tend ; length = 0 } in enqueue_advance state elem ; state . pp_curr_depth <- state . pp_curr_depth - 1 end |
let pp_print_tbreak state width offset = if state . pp_curr_depth < state . pp_max_boxes then let size = Size . of_int ( - state . pp_right_total ) in let elem = { size ; token = Pp_tbreak ( width , offset ) ; length = width } in scan_push state true elem |
let pp_print_tab state ( ) = pp_print_tbreak state 0 0 |
let pp_set_tab state ( ) = if state . pp_curr_depth < state . pp_max_boxes then let elem = { size = Size . zero ; token = Pp_stab ; length = 0 } in enqueue_advance state elem |
let pp_set_max_boxes state n = if n > 1 then state . pp_max_boxes <- n |
let pp_get_max_boxes state ( ) = state . pp_max_boxes |
let pp_over_max_boxes state ( ) = state . pp_curr_depth = state . pp_max_boxes |
let pp_set_ellipsis_text state s = state . pp_ellipsis <- s |
let pp_limit n = if n < pp_infinity then n else pred pp_infinity |
let pp_set_min_space_left state n = if n >= 1 then let n = pp_limit n in state . pp_min_space_left <- n ; state . pp_max_indent <- state . pp_margin - state . pp_min_space_left ; pp_rinit state |
let pp_set_max_indent state n = if n > 1 then pp_set_min_space_left state ( state . pp_margin - n ) |
let pp_get_max_indent state ( ) = state . pp_max_indent |
let pp_set_margin state n = if n >= 1 then let n = pp_limit n in state . pp_margin <- n ; let new_max_indent = if state . pp_max_indent <= state . pp_margin then state . pp_max_indent else max ( max ( state . pp_margin - state . pp_min_space_left ) ( state . pp_margin / 2 ) ) 1 in... |
type geometry = { max_indent : int ; margin : int } |
let validate_geometry { margin ; max_indent } = if max_indent < 2 then Error " max_indent < 2 " else if margin <= max_indent then Error " margin <= max_indent " else Ok ( ) |
let check_geometry geometry = match validate_geometry geometry with | Ok ( ) -> true | Error _ -> false |
let pp_get_margin state ( ) = state . pp_margin |
let pp_set_full_geometry state { margin ; max_indent } = pp_set_margin state margin ; pp_set_max_indent state max_indent ; ( ) |
let pp_set_geometry state ~ max_indent ~ margin = let geometry = { max_indent ; margin } in match validate_geometry geometry with | Error msg -> raise ( Invalid_argument ( " Format . pp_set_geometry : " ^ msg ) ) | Ok ( ) -> pp_set_full_geometry state geometry |
let pp_safe_set_geometry state ~ max_indent ~ margin = let geometry = { max_indent ; margin } in match validate_geometry geometry with | Error _msg -> ( ) | Ok ( ) -> pp_set_full_geometry state geometry |
let pp_get_geometry state ( ) = { margin = pp_get_margin state ( ) ; max_indent = pp_get_max_indent state ( ) } |
let pp_update_geometry state update = let geometry = pp_get_geometry state ( ) in pp_set_full_geometry state ( update geometry ) |
let pp_set_formatter_out_functions state { out_string = f ; out_flush = g ; out_newline = h ; out_spaces = i ; out_indent = j ; } = state . pp_out_string <- f ; state . pp_out_flush <- g ; state . pp_out_newline <- h ; state . pp_out_spaces <- i ; state . pp_out_indent <- j |
let pp_get_formatter_out_functions state ( ) = { out_string = state . pp_out_string ; out_flush = state . pp_out_flush ; out_newline = state . pp_out_newline ; out_spaces = state . pp_out_spaces ; out_indent = state . pp_out_indent ; } |
let pp_set_formatter_output_functions state f g = state . pp_out_string <- f ; state . pp_out_flush <- g |
let pp_get_formatter_output_functions state ( ) = ( state . pp_out_string , state . pp_out_flush ) |
let display_newline state ( ) = state . pp_out_string " \ n " 0 1 |
let blank_line = String . make 80 ' ' |
let rec display_blanks state n = if n > 0 then if n <= 80 then state . pp_out_string blank_line 0 n else begin state . pp_out_string blank_line 0 80 ; display_blanks state ( n - 80 ) end |
let pp_set_formatter_out_channel state oc = state . pp_out_string <- output_substring oc ; state . pp_out_flush <- ( fun ( ) -> flush oc ) ; state . pp_out_newline <- display_newline state ; state . pp_out_spaces <- display_blanks state ; state . pp_out_indent <- display_indent state |
let default_pp_mark_open_tag = function | String_tag s -> " " < ^ s ^ " " > | _ -> " " |
let default_pp_mark_close_tag = function | String_tag s -> " " </ ^ s ^ " " > | _ -> " " |
let pp_make_formatter f g h i j = let pp_queue = Queue . create ( ) in let sys_tok = { size = Size . unknown ; token = Pp_begin ( 0 , Pp_hovbox ) ; length = 0 } in Queue . add sys_tok pp_queue ; let scan_stack = Stack . create ( ) in initialize_scan_stack scan_stack ; Stack . ... |
let formatter_of_out_functions out_funs = pp_make_formatter out_funs . out_string out_funs . out_flush out_funs . out_newline out_funs . out_spaces out_funs . out_indent |
let make_formatter output flush = let ppf = pp_make_formatter output flush ignore ignore ignore in ppf . pp_out_newline <- display_newline ppf ; ppf . pp_out_spaces <- display_blanks ppf ; ppf . pp_out_indent <- display_indent ppf ; ppf |
let formatter_of_out_channel oc = make_formatter ( output_substring oc ) ( fun ( ) -> flush oc ) |
let formatter_of_buffer b = make_formatter ( Buffer . add_substring b ) ignore |
let pp_make_buffer ( ) = Buffer . create pp_buffer_size |
let stdbuf = pp_make_buffer ( ) |
let std_formatter = formatter_of_out_channel Stdlib . stdout |
let flush_buffer_formatter buf ppf = pp_flush_queue ppf false ; let s = Buffer . contents buf in Buffer . reset buf ; s |
let flush_str_formatter ( ) = flush_buffer_formatter stdbuf str_formatter |
type symbolic_output_item = | Output_flush | Output_newline | Output_string of string | Output_spaces of int | Output_indent of int |
type symbolic_output_buffer = { mutable symbolic_output_contents : symbolic_output_item list ; } |
let make_symbolic_output_buffer ( ) = { symbolic_output_contents = [ ] } |
let clear_symbolic_output_buffer sob = sob . symbolic_output_contents <- [ ] |
let get_symbolic_output_buffer sob = List . rev sob . symbolic_output_contents |
let flush_symbolic_output_buffer sob = let items = get_symbolic_output_buffer sob in clear_symbolic_output_buffer sob ; items |
let add_symbolic_output_item sob item = sob . symbolic_output_contents <- item :: sob . symbolic_output_contents |
let formatter_of_symbolic_output_buffer sob = let symbolic_flush sob ( ) = add_symbolic_output_item sob Output_flush and symbolic_newline sob ( ) = add_symbolic_output_item sob Output_newline and symbolic_string sob s i n = add_symbolic_output_item sob ( Output_string ( String . sub s i n ) ) and ... |
let open_hbox = pp_open_hbox std_formatter pp_set_formatter_out_channel std_formatter pp_set_formatter_out_functions std_formatter pp_get_formatter_out_functions std_formatter pp_set_formatter_output_functions std_formatter pp_get_formatter_output_functions std_formatter pp_set_formatter_stag_functions std_formatter p... |
let rec pp_print_list ( ? pp_sep = pp_print_cut ) pp_v ppf = function | [ ] -> ( ) | [ v ] -> pp_v ppf v | v :: vs -> pp_v ppf v ; pp_sep ppf ( ) ; pp_print_list ~ pp_sep pp_v ppf vs |
let rec pp_print_seq_in ~ pp_sep pp_v ppf seq = match seq ( ) with | Seq . Nil -> ( ) | Seq . Cons ( v , seq ) -> pp_sep ppf ( ) ; pp_v ppf v ; pp_print_seq_in ~ pp_sep pp_v ppf seq |
let pp_print_seq ( ? pp_sep = pp_print_cut ) pp_v ppf seq = match seq ( ) with | Seq . Nil -> ( ) | Seq . Cons ( v , seq ) -> pp_v ppf v ; pp_print_seq_in ~ pp_sep pp_v ppf seq |
let pp_print_text ppf s = let len = String . length s in let left = ref 0 in let right = ref 0 in let flush ( ) = pp_print_string ppf ( String . sub s ! left ( ! right - ! left ) ) ; incr right ; left := ! right ; in while ( ! right <> len ) do match s . [ ! right ] with ... |
let pp_print_option ( ? none = fun _ ( ) -> ( ) ) pp_v ppf = function |
let pp_print_result ~ ok ~ error ppf = function |
let compute_tag output tag_acc = let buf = Buffer . create 16 in let ppf = formatter_of_buffer buf in output ppf tag_acc ; pp_print_flush ppf ( ) ; let len = Buffer . length buf in if len < 2 then Buffer . contents buf else Buffer . sub buf 1 ( len - 2 ) |
let output_formatting_lit ppf fmting_lit = match fmting_lit with | Close_box -> pp_close_box ppf ( ) | Close_tag -> pp_close_tag ppf ( ) | Break ( _ , width , offset ) -> pp_print_break ppf width offset | FFlush -> pp_print_flush ppf ( ) | Force_newline -> pp_force_newline ppf ( ) |... |
let rec output_acc ppf acc = match acc with | Acc_string_literal ( Acc_formatting_lit ( p , Magic_size ( _ , size ) ) , s ) | Acc_data_string ( Acc_formatting_lit ( p , Magic_size ( _ , size ) ) , s ) -> output_acc ppf p ; pp_print_as_size ppf ( Size . of_int size ) s ;... |
let rec strput_acc ppf acc = match acc with | Acc_string_literal ( Acc_formatting_lit ( p , Magic_size ( _ , size ) ) , s ) | Acc_data_string ( Acc_formatting_lit ( p , Magic_size ( _ , size ) ) , s ) -> strput_acc ppf p ; pp_print_as_size ppf ( Size . of_int size ) s ;... |
let kfprintf k ppf ( Format ( fmt , _ ) ) = make_printf ( fun acc -> output_acc ppf acc ; k ppf ) End_of_acc fmt make_iprintf k ppf fmt |
let ifprintf _ppf ( Format ( fmt , _ ) ) = make_iprintf ignore ( ) fmt |
let fprintf ppf = kfprintf ignore ppf |
let printf fmt = fprintf std_formatter fmt |
let eprintf fmt = fprintf err_formatter fmt |
let kdprintf k ( Format ( fmt , _ ) ) = make_printf ( fun acc -> k ( fun ppf -> output_acc ppf acc ) ) End_of_acc fmt |
let dprintf fmt = kdprintf ( fun i -> i ) fmt |
let ksprintf k ( Format ( fmt , _ ) ) = let b = pp_make_buffer ( ) in let ppf = formatter_of_buffer b in let k acc = strput_acc ppf acc ; k ( flush_buffer_formatter b ppf ) in make_printf k End_of_acc fmt |
let sprintf fmt = ksprintf id fmt |
let kasprintf k ( Format ( fmt , _ ) ) = let b = pp_make_buffer ( ) in let ppf = formatter_of_buffer b in let k acc = output_acc ppf acc ; k ( flush_buffer_formatter b ppf ) in make_printf k End_of_acc fmt |
let asprintf fmt = kasprintf id fmt |
let flush_standard_formatters ( ) = pp_print_flush std_formatter ( ) ; pp_print_flush err_formatter ( ) |
let ( ) = at_exit flush_standard_formatters |
let pp_set_all_formatter_output_functions state ~ out : f ~ flush : g ~ newline : h ~ spaces : i = pp_set_formatter_output_functions state f g ; state . pp_out_newline <- h ; state . pp_out_spaces <- i |
let pp_get_all_formatter_output_functions state ( ) = ( state . pp_out_string , state . pp_out_flush , state . pp_out_newline , state . pp_out_spaces ) |
let set_all_formatter_output_functions = pp_set_all_formatter_output_functions std_formatter |
let get_all_formatter_output_functions = pp_get_all_formatter_output_functions std_formatter |
let bprintf b ( Format ( fmt , _ ) : ( ' a , formatter , unit ) format ) = let ppf = formatter_of_buffer b in let k acc = output_acc ppf acc ; pp_flush_queue ppf false in make_printf k End_of_acc fmt |
type formatter_tag_functions = { mark_open_tag : tag -> string ; mark_close_tag : tag -> string ; print_open_tag : tag -> unit ; print_close_tag : tag -> unit ; } |
let pp_set_formatter_tag_functions state { mark_open_tag = mot ; mark_close_tag = mct ; print_open_tag = pot ; print_close_tag = pct ; } = let stringify f e = function String_tag s -> f s | _ -> e in state . pp_mark_open_tag <- stringify mot " " ; state . pp_mark_close_tag <- stringify... |
let pp_get_formatter_tag_functions fmt ( ) = let funs = pp_get_formatter_stag_functions fmt ( ) in let mark_open_tag s = funs . mark_open_stag ( String_tag s ) in let mark_close_tag s = funs . mark_close_stag ( String_tag s ) in let print_open_tag s = funs . print_open_stag ( String_tag s )... |
let set_formatter_tag_functions = pp_set_formatter_tag_functions std_formatter pp_get_formatter_tag_functions std_formatter |
let current_frame = ref 0 |
let selected_event = ref ( None : code_event option ) |
let selected_point ( ) = match ! selected_event with None -> raise Not_found | Some { ev_ev = ev } -> ( ev . ev_module , ( Events . get_pos ev ) . Lexing . pos_lnum , ( Events . get_pos ev ) . Lexing . pos_cnum - ( Events . get_pos ev ) . Lexing . pos_bol ) |
let selected_event_is_before ( ) = match ! selected_event with None -> raise Not_found | Some { ev_ev { = ev_kind = Event_before } } -> true | _ -> false |
let rec move_up frame_count event = if frame_count <= 0 then event else begin let ( sp , pc ) = up_frame event . ev_ev . ev_stacksize in if sp < 0 then raise Not_found ; move_up ( frame_count - 1 ) ( any_event_at_pc pc ) end |
let select_frame frame_number = if frame_number < 0 then raise Not_found ; let ( initial_sp , _ ) = get_frame ( ) in try match ! current_event with None -> raise Not_found | Some curr_event -> match ! selected_event with Some sel_event when frame_number >= ! current_frame -> selected_event := ... |
let try_select_frame frame_number = try select_frame frame_number with Not_found -> ( ) |
let reset_frame ( ) = set_initial_frame ( ) ; selected_event := ! current_event ; current_frame := 0 |
let do_backtrace action = match ! current_event with None -> Misc . fatal_error " Frames . do_backtrace " | Some ev -> let ( initial_sp , _ ) = get_frame ( ) in set_initial_frame ( ) ; let event = ref ev in begin try while action ( Some ! event ) do let ( sp , pc ) = up_frame... |
let stack_depth ( ) = let num_frames = ref 0 in do_backtrace ( function Some _ev -> incr num_frames ; true | None -> num_frames := - 1 ; false ) ; ! num_frames |
module Make ( Ast : Sig . Camlp4Ast ) = struct module S = Set . Make String ; class c_fold_pattern_vars [ ' accu ] f init = object inherit Ast . fold as super ; value acc = init ; method acc : ' accu = acc ; method patt = fun [ <: patt < $ lid : s $ >> | <: patt < ~ $ s $... |
module FV = Camlp4 . Struct . FreeVars . Make Ast ; fprintf f " [ @< 2 { > " ; FV . S . iter ( fprintf f " % s @ " ) s ; fprintf f " } ] " ; @ } ; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.