text stringlengths 12 786k |
|---|
let typeof sid = let id = longident_parse sid in let env = ! Toploop . toplevel_env in let lookup_value = Env . find_value_by_name and lookup_label = Env . find_label_by_name and lookup_modtype = Env . find_modtype_by_name and lookup_module id env = let path , decl = Env . find_module_by_name id en... |
let default_info = { Toploop . section = " UTop " ; doc = " " ; } |
let ( ) = Toploop . add_directive " typeof " ( Toploop . Directive_string typeof ) default_info |
let emacs_mode = ref false |
let preload = ref [ ] |
let prepare ( ) = Toploop . set_paths ( ) ; try let ok = List . for_all ( function | ` Packages l -> UTop . require l ; true | ` Object fn -> Toploop . load_file Format . err_formatter fn ) # else Topdirs . load_file Format . err_formatter fn ) # endif ( List . rev ! pre... |
let override_argv ( ) = let len = Array . length Sys . argv - ! Arg . current in let copy = Array . init len ( fun i -> Sys . argv . ( i + ! Arg . current ) ) in caml_sys_modify_argv copy ; Arg . current := 0 # else |
let override_argv ( ) = let len = Array . length Sys . argv - ! Arg . current in Array . blit Sys . argv ! Arg . current Sys . argv 0 len ; Obj . truncate ( Obj . repr Sys . argv ) len ; Arg . current := 0 # endif |
let run_script name = Sys . interactive := false ; if not ( prepare ( ) ) then exit 2 ; override_argv ( ) ; Toploop . initialize_toplevel_env ( ) ; Location . input_name := UTop . input_name ; if toploop_use_silently Format . err_formatter name then exit 0 else exit 2 |
let file_argument name = if Filename . check_suffix name " . cmo " || Filename . check_suffix name " . cma " then preload := ` Object name :: ! preload else run_script name |
let print_version ( ) = Printf . printf " The universal toplevel for OCaml , version % s , compiled for OCaml version % s \ n " UTop . version Sys . ocaml_version ; exit 0 |
let print_version_num ( ) = Printf . printf " % s \ n " UTop . version ; exit 0 |
let autoload = ref true |
let args = Arg . align [ " - absname " , Arg . Set Clflags . absname , " Show absolute filenames in error message " ; # else " - absname " , Arg . Set Location . absname , " Show absolute filenames in error message " ; # endif " - I " , Arg . String ( fun dir -> ... |
let ( ) = Clflags . real_paths := false |
let app_name = Filename . basename Sys . executable_name |
let usage = Printf . sprintf " Usage : % s < options > < object - files > [ script - file [ arguments ] ] \ noptions are " : app_name |
let load_init_files dir = let files = Sys . readdir dir in Array . sort String . compare files ; Array . iter ( fun fn -> if Filename . check_suffix fn " . ml " then ignore ( toploop_use_silently Format . err_formatter ( Filename . concat dir fn ) : bool ) ) files ; ; |
let common_init ~ initial_env = ( match initial_env with | None -> Toploop . initialize_toplevel_env ( ) | Some env -> Toploop . toplevel_env := env ) ; Location . input_name := UTop . input_name ; Sys . catch_break true ; ( match try Some ( Sys . getenv " OCAML_TOPLEVEL_PATH " ... |
let load_inputrc ( ) = Lwt . catch LTerm_inputrc . load ( function | Unix . Unix_error ( error , func , arg ) -> Lwt_log . error_f " cannot load key bindings from % S : % s : % s " LTerm_inputrc . default func ( Unix . error_message error ) | LTerm_inputrc . Parse_error ( ... |
let main_aux ~ initial_env = Arg . parse args file_argument usage ; Topcommon . load_topdirs_signature ( ) ; # endif if not ( prepare ( ) ) then exit 2 ; if ! emacs_mode then begin Printf . printf " protocol - version :% d \ n " %! protocol_version ; UTop_private . set_ui UTop_p... |
let main_internal ~ initial_env = let exit_status = ref 2 in try main_aux ~ initial_env with exn -> ( match exn with | Unix . Unix_error ( error , func , " " ) -> Printf . eprintf " % s : % s : % s \ n " app_name func ( Unix . error_message error ) | Unix . Unix_error ( er... |
let main ( ) = main_internal ~ initial_env : None |
type value = V : string * _ -> value |
let get_required_label name args = match List . find ( fun ( lab , _ ) -> lab = Asttypes . Labelled name ) args with | _ , x -> x | exception Not_found -> None # else |
let get_required_label name args = match List . find ( fun ( lab , _ , k ) -> lab = " loc " && k = Typedtree . Required ) args with | _ , x , _ -> x | _ -> None | exception Not_found -> None # endif |
let walk dir ~ init ~ f = let rec loop dir acc = let acc = f dir acc in ArrayLabels . fold_left ( Sys . readdir dir ) ~ init : acc ~ f ( : fun acc fn -> let fn = Filename . concat dir fn in match Unix . lstat fn with | { st_kind = S_DIR ; _ } -> loop fn acc | _ -> acc ) in match ... |
let interact ( ? search_path [ ] ) = ( ? build_dir " = _build " ) ~ unit ~ loc ( : fname , lnum , cnum , _ ) ~ values = let search_path = walk build_dir ~ init : search_path ~ f ( : fun dir acc -> dir :: acc ) in let cmt_fname = try Misc . find_in_path_uncap search_pat... |
let ( ) = Location . register_error_of_exn ( function | Envaux . Error err -> Some ( Location . error_of_printer_file Envaux . report_error err ) | _ -> None ) |
let print_fan_error pp exn = Format . fprintf pp " [ @< 0 >% s ] . " @@ ( Printexc . to_string exn ) |
let get_fan_error_message exn = let ( loc , exn ) = match exn with | Locf . Exc_located ( loc , exn ) -> ( ( loc . loc_start . pos_cnum , loc . loc_end . pos_cnum ) , exn ) | exn -> ( ( 0 , 0 ) , exn ) in let msg = UTop . get_message print_fan_error exn in let id... |
let revise_parser str _eos_is_error = let eof = ref false in let lexbuf = UTop . lexbuf_of_string eof str in try let stream = Lex_fan . from_lexbuf lexbuf in match Streamf . peek stream with | Some ( ` EOI _ ) -> ( Streamf . junk stream ; raise End_of_file ) | _ -> UTop . Value ( Mkto... |
let normal ( ) = begin UTop . parse_toplevel_phrase := UTop . parse_toplevel_phrase_default ; UTop . parse_use_file := UTop . parse_use_file_default ; end ; ; |
let fan ( ) = begin UTop . parse_toplevel_phrase := revise_parser ; Toploop . parse_use_file := Mktop . wrap Mktop . use_file ~ print_location : Toploop . print_location ; end ; ; begin Hashtbl . replace Toploop . directive_table " fan " ( Toploop . Directive_none ( fun ( ) ... |
let ( ) = UTop_main . main ( ) ; ; |
let size , set_size = let ev , set_size = E . create ( ) in let init = S . const { LTerm_geom . rows = 25 ; LTerm_geom . cols = 80 } in ( S . switch ( S . hold ~ eq ( : == ) init ev ) , set_size ) |
let key_sequence , set_key_sequence = let ev , set_key_sequence = E . create ( ) in let init = ( S . const ( [ ] : LTerm_key . t list ) ) in ( S . switch ( S . hold ~ eq ( : == ) init ev ) , set_key_sequence ) |
let count , set_count = S . create ( - 1 ) |
type ui = Console | Emacs |
let ui , set_ui = S . create Console |
let error_style = ref LTerm_style . none |
let autoload = ref true |
let margin_function , set_margin_function = S . create ~ eq ( : == ) ( fun ( size : LTerm_geom . size ) -> Some ( min 80 size . cols ) ) |
let margin = S . app margin_function size |
let set_margin pp = match S . value margin with | None -> ( ) | Some n -> if Format . pp_get_margin pp ( ) <> n then Format . pp_set_margin pp n |
let return , ( ) >>= = Lwt . return , Lwt . ( ) >>= |
module String_set = Set . Make ( String ) |
type styles = { mutable style_keyword : LTerm_style . t ; mutable style_symbol : LTerm_style . t ; mutable style_ident : LTerm_style . t ; mutable style_module : LTerm_style . t ; mutable style_constant : LTerm_style . t ; mutable style_char : LTerm_style . t ; mutable style_string : L... |
let styles = { style_keyword = LTerm_style . none ; style_symbol = LTerm_style . none ; style_ident = LTerm_style . none ; style_module = LTerm_style . none ; style_constant = LTerm_style . none ; style_char = LTerm_style . none ; style_string = LTerm_style . none ; style_quotation... |
let load ( ) = let fn = Filename . concat LTerm_resources . home " . utoprc " in Lwt . catch ( fun ( ) -> LTerm_resources . load fn >>= fun res -> styles . style_keyword <- LTerm_resources . get_style " keyword " res ; styles . style_symbol <- LTerm_resources . get_style " ... |
let stylise_filter_layout stylise tokens = let aux acc = function | ( Comment ( Comment_reg , _ ) , loc ) -> stylise loc styles . style_comment ; acc | ( Comment ( Comment_doc , _ ) , loc ) -> stylise loc styles . style_doc ; acc | ( Blanks , loc ) -> stylise loc styles .... |
let rec stylise_rec stylise tokens = match tokens with | [ ] -> ( ) | ( Symbol _ , loc ) :: tokens -> stylise loc styles . style_symbol ; stylise_rec stylise tokens | ( Lident id , loc ) :: tokens -> stylise loc ( if String_set . mem id ! UTop . keywords then styles . style_ke... |
let stylise stylise tokens = let tokens = stylise_filter_layout stylise tokens in match tokens with | ( Symbol " " , # loc ) :: tokens -> begin stylise loc styles . style_directive ; match tokens with | ( ( Lident id | Uident id ) , loc ) :: tokens -> stylise loc ( if String_set . ... |
type location = { idx1 : int ; idx2 : int ; ofs1 : int ; ofs2 : int ; } |
type t = | Symbol of string | Lident of string | Uident of string | Constant of string | Char | String of int * bool | Comment of comment_kind * bool | Blanks | Error | Quotation of ( quotation_item * location ) list * bool | Comment_reg | Comment_doc | Quot_data | Quot_anti of antiquotation a_op... |
let str_of_name ( u , l ) = str " { % s } % s " u l |
let split_string s sep = let rec split accum j = let i = try ( String . rindex_from s j sep ) with Not_found -> - 1 in if ( i = - 1 ) then let p = String . sub s 0 ( j + 1 ) in if p <> " " then p :: accum else accum else let p = String . sub s ( i + 1 ) ( j - i ) in let ... |
let err s = failwith s |
let err_data = " character data not allowed here " |
let err_exp_el_end = " expected end of element " |
let err_exp_data = " expected character data " |
let err_wf = " document not well formed " |
let err_dup n = str " duplicate element ( % s ) " ( str_of_name n ) |
let err_miss_att n = str " missing attribute ( % s ) " n |
let err_att_val v = str " invalid attribute value ( " \% s " ) " \ v |
let err_invalid_cp v = str " invalid code point ( " \% s " ) " \ v |
let err_empty_cps = " empty code point sequence " |
let err_exp_ucd fnd = str " expected ucd element found % s " ( str_of_name fnd ) |
let err_invalid_cp_spec = str " invalid code point specification " |
let err_invalid_name_alias_spec = str " invalid name alias specification " |
module Cp = struct type t = int let compare : int -> int -> int = compare end |
let is_cp i = 0x0000 <= i && i <= 0x10_FFFF |
let is_scalar_value i = ( 0x0000 <= i && i <= 0xD7FF ) || ( 0xE000 <= i && i <= 0x10FFFF ) |
let cp_of_string v = let is_hex c = ( 0x30 <= c && c <= 0x39 ) || ( 0x41 <= c && c <= 0x46 ) in let cp = ref 0 in for k = 0 to ( String . length v ) - 1 do let c = Char . code v . [ k ] in if not ( is_hex c ) then err ( err_invalid_cp v ) else cp := ! cp * 16 + ( ... |
let cps_of_string ( ? empty = false ) v = if ( v = " " ) then ( if empty then [ ] else err err_empty_cps ) else List . map cp_of_string ( split_string v ' ' ) |
module Cpmap = Map . Make ( Cp ) |
type script = [ ] |
type block_prop = [ ] |
type value = | ` AL | ` AN | ` B | ` BN | ` CS | ` EN | ` ES | ` ET | ` L | ` LRE | ` LRO | ` NSM | ` ON | ` PDF | ` R | ` RLE | ` RLO | ` S | ` WS | ` LRI | ` RLI | ` FSI | ` PDI ] | ` Can | ` Com | ` Enc | ` Fin | ` Font | ` Fra... |
let o_age = function Age_v v -> v | _ -> assert false |
let o_bidi_class = function Bidi_class_v v -> v | _ -> assert false |
let o_bidi_paired_bracket_type = function Bidi_paired_bracket_type_v v -> v | _ -> assert false |
let o_block = function Block_v v -> v | _ -> assert false |
let o_bool = function Bool_v v -> v | _ -> assert false |
let o_bool_maybe = function Bool_maybe_v v -> v | _ -> assert false |
let o_cp = function Cp_v v -> v | _ -> assert false |
let o_cp_map = function Cp_map_v v -> v | _ -> assert false |
let o_cp_opt = function Cp_opt_v v -> v | _ -> assert false |
let o_decomposition_type = function Decomposition_type_v v -> v | _ -> assert false |
let o_east_asian_width = function East_asian_width_v v -> v | _ -> assert false |
let o_general_category = function General_category_v v -> v | _ -> assert false |
let o_grapheme_cluster_break = function Grapheme_cluster_break_v v -> v | _ -> assert false |
let o_hangul_syllable_type = function Hangul_syllable_type_v v -> v | _ -> assert false |
let o_int = function Int_v v -> v | _ -> assert false |
let o_indic_syllabic_category = function Indic_syllabic_category_v v -> v | _ -> assert false |
let o_indic_matra_category = function Indic_matra_category_v v -> v | _ -> assert false |
let o_indic_positional_category = function Indic_positional_category_v v -> v | _ -> assert false |
let o_joining_group = function Joining_group_v v -> v | _ -> assert false |
let o_joining_type = function Joining_type_v v -> v | _ -> assert false |
let o_line_break = function Line_break_v v -> v | _ -> assert false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.