text
stringlengths
0
601k
let normalize_name s = String . lowercase_ascii s
let make_name_translator ( ) = let map = Protect_ident . create ~ reserved_dst [ ] : ( ) in fun name -> let preferred_name = remove_leading_underscores name |> normalize_name in Protect_ident . add_translation map name ~ preferred_dst : preferred_name
let simplify_rule_body translate_name = let rec simplify ( x : rule_body ) : rule_body = match x with | SYMBOL name -> SYMBOL ( translate_name name ) | STRING _ | PATTERN _ | BLANK -> x | REPEAT x -> REPEAT ( simplify x ) | REPEAT1 x -> REPEAT1 ( simplify x ) | CHOICE xs -> CHOICE ( List . map simplify xs ) | SEQ xs ->...
let apply_inline grammar = let rules = Hashtbl . create 100 in List . iter ( fun ( name , body ) -> Hashtbl . add rules name body ) grammar . rules ; let inline_rules = Hashtbl . create 100 in List . iter ( fun name -> match Hashtbl . find_opt rules name with | None -> ( ) | Some body -> Hashtbl . add inline_rules name...
let translate_named_prec_level translate_name ( x : named_prec_level ) = match x with | Prec_symbol name -> Prec_symbol ( translate_name name ) | Prec_string _ as x -> x
let translate_precedences translate_name ll = List . map ( List . map ( translate_named_prec_level translate_name ) ) ll
let simplify_grammar grammar = let grammar = Missing_node . work_around_missing_nodes grammar in let grammar = apply_inline grammar in let translate_name = make_name_translator ( ) in let simplify = simplify_rule_body translate_name in let simplified_rules = List . map ( fun ( name , rule_body ) -> ( translate_name nam...
let run grammar output_file = let oc = open_out output_file in let orig_grammar = Atdgen_runtime . Util . Json . from_file Tree_sitter_j . read_grammar grammar in let new_grammar = simplify_grammar orig_grammar in let compact_json = Atdgen_runtime . Util . Json . to_string Tree_sitter_j . write_grammar new_grammar in l...
let phys_equal ( approxs : A . t list ) = match approxs with | [ ] | [ _ ] | _ :: _ :: _ :: _ -> Misc . fatal_error " wrong number of arguments for equality " | [ a1 ; a2 ] -> match a1 . symbol , a2 . symbol with | Some ( s1 , None ) , Some ( s2 , None ) -> Symbol . equal s1 s2 | Some ( s1 , Some f1 ) , Some ( s2 , Som...
let is_known_to_be_some_kind_of_int ( arg : A . descr ) = match arg with | Value_int _ | Value_char _ | Value_constptr _ -> true | Value_block ( _ , _ ) | Value_float _ | Value_set_of_closures _ | Value_closure _ | Value_string _ | Value_float_array _ | A . Value_boxed_int _ | Value_unknown _ | Value_extern _ | Value_s...
let is_known_to_be_some_kind_of_block ( arg : A . descr ) = match arg with | Value_block _ | Value_float _ | Value_float_array _ | A . Value_boxed_int _ | Value_closure _ | Value_string _ -> true | Value_set_of_closures _ | Value_int _ | Value_char _ | Value_constptr _ | Value_unknown _ | Value_extern _ | Value_symbol ...
let rec structurally_different ( arg1 : A . t ) ( arg2 : A . t ) = match arg1 . descr , arg2 . descr with | ( Value_int n1 | Value_constptr n1 ) , ( Value_int n2 | Value_constptr n2 ) when n1 <> n2 -> true | Value_block ( tag1 , fields1 ) , Value_block ( tag2 , fields2 ) -> not ( Tag . equal tag1 tag2 ) || ( Array . le...
let phys_different ( approxs : A . t list ) = match approxs with | [ ] | [ _ ] | _ :: _ :: _ :: _ -> Misc . fatal_error " wrong number of arguments for equality " | [ a1 ; a2 ] -> structurally_different a1 a2
let is_empty = function | [ ] -> true | _ :: _ -> false
let is_pisint = function | Clambda_primitives . Pisint -> true | _ -> false
let is_pstring_length = function | Clambda_primitives . Pstringlength -> true | _ -> false
let is_pbytes_length = function | Clambda_primitives . Pbyteslength -> true | _ -> false
let is_pstringrefs = function | Clambda_primitives . Pstringrefs -> true | _ -> false
let is_pbytesrefs = function | Clambda_primitives . Pbytesrefs -> true | _ -> false
let primitive ( p : Clambda_primitives . primitive ) ( args , approxs ) expr dbg ~ size_int : Flambda . named * A . t * Inlining_cost . Benefit . t = let fpc = ! Clflags . float_const_prop in match p with | Pmakeblock ( tag_int , Asttypes . Immutable , shape ) -> let tag = Tag . create_exn tag_int in let shape = match ...
let simplify_switch ( block : C . basic_block ) labels = let len = Array . length labels in if len < 1 then Misc . fatal_error " Malformed terminator : switch with empty arms " ; let labels_with_counts = Array . fold_right ( fun l acc -> if List . compare_length_with acc 3 > 0 then acc else match acc with | [ ] -> [ ( ...
let block cfg ( block : C . basic_block ) = match block . terminator . desc with | Always _ -> ( ) | Never -> Misc . fatal_errorf " Cannot simplify terminator : Never ( in block % d ) " block . start | Parity_test _ | Truth_test _ | Int_test _ | Float_test _ -> let labels = C . successor_labels cfg ~ normal : true ~ ex...
let run cfg = C . iter_blocks cfg ~ f ( : fun _ b -> block cfg b )
let int_of_hex1 c = match c with | ' 0 ' . . ' 9 ' -> int_of_char c - int_of_char ' 0 ' | ' a ' . . ' f ' -> int_of_char c - int_of_char ' a ' + 10 | ' A ' . . ' F ' -> int_of_char c - int_of_char ' A ' + 10 | _ -> invalid_arg " Simul . int_of_hex1 "
let int_of_hex2 c1 c0 = ( int_of_hex1 c1 lsl 4 ) lor int_of_hex1 c0 ; ;
let int_of_hex3 c2 c1 c0 = ( int_of_hex1 c2 lsl 8 ) lor ( int_of_hex1 c1 lsl 4 ) lor int_of_hex1 c0 ; ;
type port = PORTA | PORTB | PORTC | PORTD | PORTE | PORTF | SPDR | PORTG | PORTH | PORTI | PORTJ | PORTK | PORTL
let string_of_port port = match port with | PORTA -> " PORTA " | PORTB -> " PORTB " | PORTC -> " PORTC " | PORTD -> " PORTD " | PORTE -> " PORTE " | PORTF -> " PORTF " | PORTG -> " PORTG " | PORTH -> " PORTH " | PORTI -> " PORTI " | PORTJ -> " PORTJ " | PORTK -> " PORTK " | PORTL -> " PORTL " | SPDR -> " SPDR " ; ;
let port_of_string s = match String . uppercase_ascii s with | " PORTA " -> PORTA | " PORTB " -> PORTB | " PORTC " -> PORTC | " PORTD " -> PORTD | " PORTE " -> PORTE | " PORTF " -> PORTF | " SPDR " -> SPDR | _ -> invalid_arg " Simul . port_of_string " ; ;
let char_of_port port = match port with | PORTA -> ' A ' | PORTB -> ' B ' | PORTC -> ' C ' | PORTD -> ' D ' | PORTE -> ' E ' | PORTF -> ' F ' | SPDR -> ' G ' | PORTG -> ' G ' | PORTH -> ' H ' | PORTI -> ' I ' | PORTJ -> ' J ' | PORTK -> ' K ' | PORTL -> ' L ' ; ;
let port_of_char c = match c with | ' B ' | ' b ' -> PORTB | ' C ' | ' c ' -> PORTC | ' D ' | ' d ' -> PORTD | ' E ' | ' e ' -> PORTE | ' F ' | ' f ' -> PORTF | ' G ' | ' g ' -> SPDR | ' H ' | ' h ' -> PORTH | ' I ' | ' i ' -> PORTI | ' J ' | ' j ' -> PORTJ | ' K ' | ' k ' -> PORTK | ' L ' | ' l ' -> PORTL | _ -> inval...
let index_of_port port = match port with | PORTA -> 0 | PORTB -> 1 | PORTC -> 2 | PORTD -> 3 | PORTE -> 4 | PORTF -> 5 | SPDR -> 6 | PORTG -> 7 | PORTH -> 8 | PORTI -> 9 | PORTJ -> 10 | PORTK -> 11 | PORTL -> 12 ; ;
let port_of_index ind = match ind with | 1 -> PORTB | 2 -> PORTC | 3 -> PORTD | 4 -> PORTE | 5 -> PORTF | 6 -> SPDR | _ -> invalid_arg " Simul . port_of_index " ; ;
type pin = | RA0 | RA1 | RA2 | RA3 | RA4 | RA5 | RA6 | RA7 | RB0 | RB1 | RB2 | RB3 | RB4 | RB5 | RB6 | RB7 | RC0 | RC1 | RC2 | RC3 | RC4 | RC5 | RC6 | RC7 | RD0 | RD1 | RD2 | RD3 | RD4 | RD5 | RD6 | RD7 | RE0 | RE1 | RE2 | RE3 | RE4 | RE5 | RE6 | RE7 | RF0 | RF1 | RF2 | RF3 | RF4 | RF5 | RF6 | RF7 | SPDR0 | SPDR1 | SPD...
let string_of_pin pin = match pin with | RA0 -> " RA0 " | RA1 -> " RA1 " | RA2 -> " RA2 " | RA3 -> " RA3 " | RA4 -> " RA4 " | RA5 -> " RA5 " | RA6 -> " RA6 " | RA7 -> " RA7 " | RB0 -> " RB0 " | RB1 -> " RB1 " | RB2 -> " RB2 " | RB3 -> " RB3 " | RB4 -> " RB4 " | RB5 -> " RB5 " | RB6 -> " RB6 " | RB7 -> " RB7 " | RC0 -> ...
let port_of_pin pin = match pin with | RA0 | RA1 | RA2 | RA3 | RA4 | RA5 | RA6 | RA7 -> PORTA | RB0 | RB1 | RB2 | RB3 | RB4 | RB5 | RB6 | RB7 -> PORTB | RC0 | RC1 | RC2 | RC3 | RC4 | RC5 | RC6 | RC7 -> PORTC | RD0 | RD1 | RD2 | RD3 | RD4 | RD5 | RD6 | RD7 -> PORTD | RE0 | RE1 | RE2 | RE3 | RE4 | RE5 | RE6 | RE7 -> PORT...
let index_of_pin pin = match pin with | RA0 | RB0 | RC0 | RD0 | RE0 | RF0 | SPDR0 | RG0 | RH0 | RI0 | RJ0 | RK0 | RL0 -> 0 | RA1 | RB1 | RC1 | RD1 | RE1 | RF1 | SPDR1 | RG1 | RH1 | RI1 | RJ1 | RK1 | RL1 -> 1 | RA2 | RB2 | RC2 | RD2 | RE2 | RF2 | SPDR2 | RG2 | RH2 | RI2 | RJ2 | RK2 | RL2 -> 2 | RA3 | RB3 | RC3 | RD3 | R...
let pin_of_port_index port index = let error ( ) = invalid_arg " Simul . pin_of_port_index " in match port with | PORTA -> begin match index with | 0 -> RA0 | 1 -> RA1 | 2 -> RA2 | 3 -> RA3 | 4 -> RA4 | 5 -> RA5 | 6 -> RA6 | 7 -> RA7 | _ -> error ( ) end | PORTB -> begin match index with | 0 -> RB0 | 1 -> RB1 | 2 -> RB...
let pin_of_number s = match s with | " PIN0 " -> RD2 | " PIN1 " -> RE1 | " PIN2 " -> RE4 | " PIN3 " -> RE5 | " PIN4 " -> RD4 | " PIN5 " -> RC6 | " PIN6 " -> RH3 | " PIN7 " -> RH4 | " PIN8 " -> RH5 | " PIN9 " -> RH6 | " PIN10 " -> RB4 | " PIN11 " -> RB5 | " PIN12 " -> RB6 | " PIN13 " -> RB7 | " PIN18 " -> RD3 | " PIN19 ...
let pin_of_string s = let error ( ) = invalid_arg ( " Simul . pin_of_string : " ^ s ) in if String . length s <> 3 || ( s . [ 0 ] <> ' R ' && s . [ 0 ] <> ' r ' ) then error ( ) ; try let port = port_of_char s . [ 1 ] in let index = int_of_char s . [ 2 ] - int_of_char ' 0 ' in pin_of_port_index port index with Invalid_...
type an = | AN0 | AN1 | AN2 | AN3 | AN4 | AN5 | AN6 | AN7 | AN8 | AN9 | AN10 | AN11 | AN12
let string_of_an an = match an with | AN0 -> " AN0 " | AN1 -> " AN1 " | AN2 -> " AN2 " | AN3 -> " AN3 " | AN4 -> " AN4 " | AN5 -> " AN5 " | AN6 -> " AN6 " | AN7 -> " AN7 " | AN8 -> " AN8 " | AN9 -> " AN9 " | AN10 -> " AN10 " | AN11 -> " AN11 " | AN12 -> " AN12 "
let an_of_string str = match str with | " AN0 " -> AN0 | " AN1 " -> AN1 | " AN2 " -> AN2 | " AN3 " -> AN3 | " AN4 " -> AN4 | " AN5 " -> AN5 | " AN6 " -> AN6 | " AN7 " -> AN7 | " AN8 " -> AN8 | " AN9 " -> AN9 | " AN10 " -> AN10 | " AN11 " -> AN11 | " AN12 " -> AN12 | _ -> invalid_arg " Simul . an_of_string "
let char_of_an an = match an with | AN0 -> ' 0 ' | AN1 -> ' 1 ' | AN2 -> ' 2 ' | AN3 -> ' 3 ' | AN4 -> ' 4 ' | AN5 -> ' 5 ' | AN6 -> ' 6 ' | AN7 -> ' 7 ' | AN8 -> ' 8 ' | AN9 -> ' 9 ' | AN10 -> ' A ' | AN11 -> ' B ' | AN12 -> ' C '
let an_of_char c = match c with | ' 0 ' -> AN0 | ' 1 ' -> AN1 | ' 2 ' -> AN2 | ' 3 ' -> AN3 | ' 4 ' -> AN4 | ' 5 ' -> AN5 | ' 6 ' -> AN6 | ' 7 ' -> AN7 | ' 8 ' -> AN8 | ' 9 ' -> AN9 | ' A ' -> AN10 | ' B ' -> AN11 | ' C ' -> AN12 | _ -> invalid_arg " Simul . an_of_char "
let int_of_an an = match an with | AN0 -> 0x0 | AN1 -> 0x1 | AN2 -> 0x2 | AN3 -> 0x3 | AN4 -> 0x4 | AN5 -> 0x5 | AN6 -> 0x6 | AN7 -> 0x7 | AN8 -> 0x8 | AN9 -> 0x9 | AN10 -> 0xA | AN11 -> 0xB | AN12 -> 0xC
let an_of_int n = match n with | 0x0 -> AN0 | 0x1 -> AN1 | 0x2 -> AN2 | 0x3 -> AN3 | 0x4 -> AN4 | 0x5 -> AN5 | 0x6 -> AN6 | 0x7 -> AN7 | 0x8 -> AN8 | 0x9 -> AN9 | 0xA -> AN10 | 0xB -> AN11 | 0xC -> AN12 | _ -> invalid_arg " Simul . an_of_int "
type input = IWrite of port * int | ITris of port * int | IWriteAnalog of an * int | IConfigAnalog of int | ISync | IStop
let input_of_string s = let error ( ) = invalid_arg ( " Simul . input_of_string : " ^ s ) in match s with | " SYNC " -> ISync | " STOP " -> IStop | _ -> try match s . [ 0 ] with | ' W ' -> assert ( String . length s = 4 ) ; IWrite ( port_of_char s . [ 1 ] , int_of_hex2 s . [ 2 ] s . [ 3 ] ) | ' T ' -> assert ( String ....
type output = OSet of pin | OClear of pin | OWrite of port * int | OWriteAnalog of an * int | ODone | OStop
let string_of_output output = match output with | OSet pin -> Printf . sprintf " S % c % d " ( char_of_port ( port_of_pin pin ) ) ( index_of_pin pin ) | OClear pin -> Printf . sprintf " C % c % d " ( char_of_port ( port_of_pin pin ) ) ( index_of_pin pin ) | OWrite ( port , value ) -> if value < 0 || value > 0xFF then f...
let channel = Event . new_channel ( ) ; ;
let rec send_loop ( ) = begin try let output = ( Event . sync ( Event . receive channel ) ) in print_string ( string_of_output output ) ; print_char ' \ n ' ; flush stdout ; with exn -> Printf . eprintf " Unhandled exception % s \ n " %! ( Printexc . to_string exn ) end ; send_loop ( ) ; in ; ;
let send output = Event . sync ( Event . send channel output ) ; ;
type handler = | Exit_handler of ( unit -> unit ) | Write_handler of ( port -> int -> unit ) | Write_port_handler of port * ( int -> unit ) | Tris_handler of ( port -> int -> unit ) | Tris_port_handler of port * ( int -> unit ) | Set_handler of ( pin -> unit ) | Clear_handler of ( pin -> unit ) | Change_handler of ( pi...
let handlers_mutex = Mutex . create ( ) ; ;
let handlers = ref [ ] ; ;
let add_handler handler = Mutex . lock handlers_mutex ; handlers := handler :: ! handlers ; Mutex . unlock handlers_mutex ; ; ;
let remove_handler handler = Mutex . lock handlers_mutex ; handlers := List . filter ( ( ) != handler ) ! handlers ; Mutex . unlock handlers_mutex ; ; ;
let ports = Array . make 13 0 ; ;
let triss = Array . make 13 0xFF ; ;
let analogs = Array . make 13 0 ; ;
let analog_cnt = ref 0 ; ;
let scall1 f arg = try Printexc . print f arg with _ -> ( ) ; ; ;
let scall2 f arg1 arg2 = try Printexc . print ( Printexc . print f arg1 ) arg2 with _ -> ( ) ; ; ;
let exec input = match input with | IWrite ( port , new_value ) -> assert ( new_value >= 0 && new_value <= 255 ) ; let index = index_of_port port in let old_value = ports . ( index ) in let lxor_values = old_value lxor new_value in let set_pins = ref [ ] in let clear_pins = ref [ ] in let ( ) = for i = 0 to 7 do let ma...
let ( start , join ) = let rec receive_loop ( ) = let s = read_line ( ) in match try Some ( input_of_string s ) with Invalid_argument _ -> Printf . eprintf " Invalid instruction : ` % s ' \ n " %! s ; None with | Some input -> if exec input then receive_loop ( ) ; | None -> receive_loop ( ) ; in let loop_thread_mutex =...
let write_port port value = send ( OWrite ( port , value mod 256 ) ) ; ;
let set_pin pin = send ( OSet pin ) ; ;
let clear_pin pin = send ( OClear pin ) ; ;
let change_pin pin b = send ( if b then OSet pin else OClear pin ) ; ;
let write_analog an value = send ( OWriteAnalog ( an , value ) ) ; ;
let read_port port = ports . ( index_of_port port ) ; ;
let read_tris port = triss . ( index_of_port port ) ; ;
let test_pin pin = try let value = ports . ( index_of_port ( port_of_pin pin ) ) in let mask = 1 lsl ( index_of_pin pin ) in ( value land mask ) <> 0 with _ -> invalid_arg " test_pin " ; ;
let state_pin pin = try let value = triss . ( index_of_port ( port_of_pin pin ) ) in let mask = 1 lsl ( index_of_pin pin ) in ( value land mask ) <> 0 with _ -> invalid_arg " state_pin " ; ;
let analog_input_count ( ) = ! analog_cnt ; ;
let find name = try Modules . find_value ( Lident . Name ( name ) ) with | Not_found -> eprintf " The name % s is unbound . . " @ name ; raise Zmisc . Error
let check_type_of_main_node name { qualid = qualid ; info = { value_typ = tys } } opt_name expected_ty_arg expected_ty_res = let actual_ty = Ztypes . instance_of_type tys in let actual_k , opt_name , actual_ty_arg , actual_ty_res = try Ztypes . filter_actual_arrow actual_ty with | _ -> eprintf " [ @ The name % s must d...
let check_unit_unit name info = check_type_of_main_node name info None Initial . typ_unit Initial . typ_unit
let check_unit_bool name info = check_type_of_main_node name info None Initial . typ_unit Initial . typ_bool
let rec is_unit ty = match ty . t_desc with | Tlink ty -> is_unit ty | Tconstr ( id , _ , _ ) -> id . id = " unit " | _ -> false
let allowed_types = Initial . ( Lident . ( List . map ( fun qualid -> qualid . id ) [ int_ident ; bool_ident ; float_ident ; unit_ident ] ) )
let rec check_simple_ty ty = match ty . t_desc with | Tvar -> eprintf " Undefined type variables are not supported by Luciole . . " ; @ raise Zmisc . Error | Tfun _ -> eprintf " Higher order functions are not supported by Luciole . . " ; @ raise Zmisc . Error | Tvec _ -> eprintf " Vectors are not supported by Luciole ....
let rec flatten ty = match ty . t_desc with | Tproduct ty -> List . concat ( List . map flatten ty ) | Tconstr ( id , _ , _ ) -> [ id . id ] | Tlink ty -> flatten ty | Tvar | Tfun _ | Tvec _ -> assert false
let rec flatten_patt patt = match patt . Zelus . p_desc with | Etuplepat p_l -> List . concat ( List . map flatten_patt p_l ) | Ealiaspat ( p , id ) -> flatten_patt p | Evarpat id -> [ id . source ] | Etypeconstraintpat ( p , _ ) -> flatten_patt p | Econstpat Evoid -> [ " unit " ] | Econstr0pat _ | Econstr1pat _ | Ewil...
let print_string_of_ty ff ty = Format . fprintf ff " string_of_ % s " ty
let print_ty_of_string ff ty = Format . fprintf ff " % s_of_string " ty
let rec type_size ty = match ty . t_desc with | Tproduct ty -> List . fold_left ( + ) 0 ( List . map type_size ty ) | Tconstr ( _ , _ , _ ) -> 1 | Tlink ty -> type_size ty | Tvec _ | Tfun _ | Tvar -> assert false
let format_names names ty = let rec aux i0 ty = match ty . t_desc with | Tproduct ty -> Printf . sprintf " ( % s ) " ( aux_list i0 ty ) | Tconstr ( id , _ , _ ) -> if id . id = unit_id then " ( ) " else names . ( i0 ) | Tlink ty -> aux i0 ty | Tvar | Tfun _ | Tvec _ -> assert false and aux_list i0 ty_list = match ty_li...
let emit_open ff open_list = List . iter ( fprintf ff " [ @% s ] . " ) @@ open_list
let emit_discrete_main k ff name = match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete ( false ) -> fprintf ff " [ @< v [ ] ; >@@@\ [ @ let main x = % s x ] ] " @@ name | Deftypes . Tdiscrete ( true ) -> fprintf ff " [ @< v [ ] ; >@@@\ [ @< v 2 [ >@ let main ] ; =@@\ [ @ let open Ztypes in ] ; ...
let emit_prelude ff ( { Lident . id = id } as qualid ) info k = let s = Lident . qualidname qualid in match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete ( false ) | Deftypes . Tdiscrete ( true ) -> if ! use_rif then begin let ( { typ_vars ; typ_body } as scheme ) = info . info . value_typ in l...
let emit_simulation_code ff k = match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete _ -> fprintf ff " [ @\ n \ while true do main ( ) done ; \ n \ exit ( 0 ) ; ; . ] " @@ | Deftypes . Tcont -> fprintf ff " [ @\ n \ module Runtime = Zlsrun . Make ( Defaultsolver ) \ n \ let _ = Runtime . go main...
let emit_checked_code ff k n = match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete _ -> fprintf ff " [ @ let ok = ref true in for i = 0 to % d - 1 do let r = main ( ) in if not r then begin print_string ( " \ error ( " \ ^ ( string_of_int i ) ^ " ) \\\ n " ) ; \ exit ( 2 ) end else ok := r done...
let emit_gtkmain_code ff k sampling = match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete _ -> fprintf ff " [ @\ n . ] " @@ sampling ; fprintf ff " [ @\ n \ module Runtime = Zlsrungtk . MakeDiscrete ( ) \ n \ let _ = Runtime . go % f main . ] " @@ sampling | Deftypes . Tcont -> fprintf ff " [ @...
let emit_periodic_code ff k sampling = match k with | Deftypes . Tstatic _ | Deftypes . Tany | Deftypes . Tdiscrete _ -> fprintf ff " [ @\ n \ . ] " @@ sampling ; fprintf ff " [ @ let periodic ( ) = let _x = Unix . setitimer Unix . ITIMER_REAL { Unix . it_interval = % f ; Unix . it_value = 1 . 0 } in Sys . set_signal S...
let main outname name sampling number_of_checks use_gtk = let outname = match outname with None -> name | Some s -> s in let filename = outname ^ " . ml " in let info = find name in let qualid , k = if number_of_checks > 0 then check_unit_bool name info else check_unit_unit name info in let oc = open_out filename in le...
let print_with_time t v = Printf . printf " % e " t ; Sundials . RealArray . iter ( Printf . printf " \ t % e " ) v ; print_newline ( )
let string_of_root x = match x with | Sundials . Roots . Rising -> " rising " | Sundials . Roots . Falling -> " falling " | Sundials . Roots . NoRoot -> " noroot "