···7070 (* Echo command - repeat the message *)
7171 let echo_text = String.sub msg 6 (String.length msg - 6) in
7272 (try
7373- Messages.send_text client ~room_id ~body:echo_text ();
7373+ let _ = Messages.send_text client ~room_id ~body:echo_text () in
7474 Printf.printf "Echoed: %s\n%!" echo_text
7575 with Eio.Io _ as e ->
7676 Printf.eprintf "Failed to send echo: %s\n%!" (Printexc.to_string e))
7777 | Some msg when msg = "!ping" ->
7878 (* Ping command *)
7979 (try
8080- Messages.send_text client ~room_id ~body:"pong!" ();
8080+ let _ = Messages.send_text client ~room_id ~body:"pong!" () in
8181 Printf.printf "Responded to ping\n%!"
8282 with Eio.Io _ as e ->
8383 Printf.eprintf "Failed to send pong: %s\n%!" (Printexc.to_string e))
···108108 ~homeserver:(Uri.of_string homeserver)
109109 ~user:username ~password ()
110110 with Eio.Io (Error.E err, _) ->
111111- Printf.eprintf "Login failed: %a\n%!" Error.pp_err err;
111111+ Format.eprintf "Login failed: %a@." Error.pp_err err;
112112 exit 1
113113 in
114114···137137 handle_sync client my_user_id response;
138138 Sync.Continue)
139139 ~on_error:(fun err ->
140140- Printf.eprintf "Sync error: %a\n%!" Error.pp_err err;
140140+ Format.eprintf "Sync error: %a@." Error.pp_err err;
141141 (* Retry after 5 seconds on error *)
142142 Sync.Retry_after 5.0)
143143 ();
+1-1
project/ocaml-quickjs/dune-project
···1616 (ocaml (>= 5.1))
1717 (dune (>= 3.20))
1818 (zarith (>= 1.13)) ; For BigInt support
1919- (pcre2 (>= 8.0)) ; For RegExp support with full PCRE2 features
1919+ (re (>= 1.11)) ; For RegExp support (pure OCaml)
2020 (fmt (>= 0.9)) ; For pretty printing
2121 (sedlex (>= 3.2)) ; Unicode-aware lexer (optional, we do handwritten but may use for unicode categories)
2222 (yojson (>= 2.1)) ; For test262 metadata parsing
···11(** JavaScript RegExp built-in object.
2233 Implements RegExp as specified in ECMA-262.
44- Uses OCaml's pcre2 library for regex execution with support for:
44+ Uses OCaml's re library for regex execution with support for:
55 - Lookahead assertions: (?=...) and (?!...)
66- - Lookbehind assertions: (?<=...) and (?<!...)
76 - Named capture groups: (?<name>...) or (?P<name>...)
88- - All standard flags: g, i, m, s, u, y *)
77+ - All standard flags: g, i, m, s, u, y
88+99+ Note: Lookbehind assertions are not supported by the re library. *)
9101011open Quickjs_runtime.Value
11121213(** Compiled regexp with metadata for JavaScript semantics *)
1314type js_regexp = {
1414- re : Pcre2.regexp;
1515+ re : Re.re;
1516 pattern : string;
1617 flags : string;
1718 num_groups : int;
1819 named_groups : (string * int) list;
1920}
20212121-(** Convert JS regex flags to Pcre2 icflag *)
2222-let flags_to_icflag flags =
2222+(** Convert JS regex flags to Re.Pcre flags *)
2323+let flags_to_re_flags flags =
2324 let opts = ref [] in
2425 if String.contains flags 'i' then
2526 opts := `CASELESS :: !opts;
···2728 opts := `MULTILINE :: !opts;
2829 if String.contains flags 's' then
2930 opts := `DOTALL :: !opts;
3030- Pcre2.cflags !opts
3131+ !opts
31323232-(** Convert JS regex pattern to PCRE2 pattern, handling JS-specific syntax *)
3333+(** Convert JS regex pattern to PCRE pattern, handling JS-specific syntax *)
3334let convert_js_pattern pattern =
3435 (* JavaScript uses (?<name>...) for named groups, PCRE uses (?P<name>...) *)
3536 let buf = Buffer.create (String.length pattern + 10) in
···4243 if !i + 3 < String.length pattern &&
4344 (pattern.[!i + 3] = '=' || pattern.[!i + 3] = '!') then
4445 begin
4545- (* It's a lookbehind, keep as is *)
4646+ (* Lookbehind not supported by re library, keep as is but will fail at compile *)
4647 Buffer.add_char buf pattern.[!i];
4748 incr i
4849 end
···128129let compile_pattern pattern flags =
129130 try
130131 let pcre_pattern = convert_js_pattern pattern in
131131- let iflags = flags_to_icflag flags in
132132- let compiled = Pcre2.regexp ~iflags pcre_pattern in
132132+ let re_flags = flags_to_re_flags flags in
133133+ let compiled = Re.compile (Re.Pcre.re ~flags:re_flags pcre_pattern) in
133134 let num_groups, named_groups = analyze_pattern pattern in
134135 Some {
135136 re = compiled;
···172173 | _ -> 0
173174 else 0
174175 in
175175- (try
176176- let result = Pcre2.exec ~rex:regexp.re ~pos:last_index str in
177177- let match_start, match_end = Pcre2.get_substring_ofs result 0 in
176176+ (match Re.exec_opt ~pos:last_index regexp.re str with
177177+ | Some result ->
178178+ let match_start, match_end = Re.Group.offset result 0 in
178179 (* For sticky, match must start at lastIndex *)
179180 if sticky && match_start <> last_index then begin
180181 ignore (set_property obj "lastIndex" (Int 0l));
···184185 ignore (set_property obj "lastIndex" (Int (Int32.of_int match_end)));
185186 Bool true
186187 end
187187- with Not_found ->
188188+ | None ->
188189 if sticky || String.contains regexp.flags 'g' then
189190 ignore (set_property obj "lastIndex" (Int 0l));
190191 Bool false)
···210211 | _ -> 0
211212 else 0
212213 in
213213- (try
214214- let result = Pcre2.exec ~rex:regexp.re ~pos:last_index str in
215215- let match_start, match_end = Pcre2.get_substring_ofs result 0 in
214214+ (match Re.exec_opt ~pos:last_index regexp.re str with
215215+ | Some result ->
216216+ let match_start, match_end = Re.Group.offset result 0 in
216217217218 (* For sticky, match must start at lastIndex *)
218219 if sticky && match_start <> last_index then begin
···225226226227 (* Build result array *)
227228 let arr_obj = make_object ~class_id:Class_array () in
228228- let num_groups = Pcre2.num_of_subs result in
229229+ let num_groups = Re.Group.nb_groups result in
229230 let groups = Array.init num_groups (fun i ->
230230- try String (Pcre2.get_substring result i)
231231- with Not_found -> Undefined
231231+ match Re.Group.get_opt result i with
232232+ | Some s -> String s
233233+ | None -> Undefined
232234 ) in
233235 arr_obj.data <- Data_array { values = groups; length = num_groups };
234236 ignore (set_property arr_obj "length" (Int (Int32.of_int num_groups)));
···240242 let groups_obj = make_object () in
241243 List.iter (fun (name, idx) ->
242244 if idx < num_groups then
243243- try
244244- let s = Pcre2.get_named_substring regexp.re name result in
245245- ignore (set_property groups_obj name (String s))
246246- with Not_found ->
247247- ignore (set_property groups_obj name Undefined)
245245+ match Re.Group.get_opt result idx with
246246+ | Some s -> ignore (set_property groups_obj name (String s))
247247+ | None -> ignore (set_property groups_obj name Undefined)
248248 ) regexp.named_groups;
249249 ignore (set_property arr_obj "groups" (Object groups_obj))
250250 end else
···252252253253 Object arr_obj
254254 end
255255- with Not_found ->
255255+ | None ->
256256 if global || sticky then
257257 ignore (set_property obj "lastIndex" (Int 0l));
258258 Null)
···327327 let rec loop pos acc =
328328 if pos > String.length str then List.rev acc
329329 else
330330- try
331331- let result = Pcre2.exec ~rex:regexp.re ~pos str in
332332- let _, match_end = Pcre2.get_substring_ofs result 0 in
330330+ match Re.exec_opt ~pos regexp.re str with
331331+ | Some result ->
332332+ let _, match_end = Re.Group.offset result 0 in
333333 (* Advance at least one char to avoid infinite loops on zero-width matches *)
334334 let next_pos = max (pos + 1) match_end in
335335 loop next_pos (result :: acc)
336336- with Not_found -> List.rev acc
336336+ | None -> List.rev acc
337337 in
338338 loop 0 []
339339···350350 if matches = [] then Null
351351 else
352352 let arr = List.map (fun result ->
353353- String (Pcre2.get_substring result 0)
353353+ String (Re.Group.get result 0)
354354 ) matches in
355355 make_array arr
356356 end else
···367367 let matches = find_all_matches regexp str in
368368 let results = List.map (fun result ->
369369 let arr_obj = make_object ~class_id:Class_array () in
370370- let num_groups = Pcre2.num_of_subs result in
370370+ let num_groups = Re.Group.nb_groups result in
371371 let groups = Array.init num_groups (fun i ->
372372- try String (Pcre2.get_substring result i)
373373- with Not_found -> Undefined
372372+ match Re.Group.get_opt result i with
373373+ | Some s -> String s
374374+ | None -> Undefined
374375 ) in
375376 arr_obj.data <- Data_array { values = groups; length = num_groups };
376377 ignore (set_property arr_obj "length" (Int (Int32.of_int num_groups)));
377377- let match_start, _ = Pcre2.get_substring_ofs result 0 in
378378+ let match_start, _ = Re.Group.offset result 0 in
378379 ignore (set_property arr_obj "index" (Int (Int32.of_int match_start)));
379380 ignore (set_property arr_obj "input" (String str));
380381381382 (* Add named groups *)
382383 if regexp.named_groups <> [] then begin
383384 let groups_obj = make_object () in
384384- List.iter (fun (name, _idx) ->
385385- try
386386- let s = Pcre2.get_named_substring regexp.re name result in
387387- ignore (set_property groups_obj name (String s))
388388- with Not_found ->
389389- ignore (set_property groups_obj name Undefined)
385385+ List.iter (fun (name, idx) ->
386386+ match Re.Group.get_opt result idx with
387387+ | Some s -> ignore (set_property groups_obj name (String s))
388388+ | None -> ignore (set_property groups_obj name Undefined)
390389 ) regexp.named_groups;
391390 ignore (set_property arr_obj "groups" (Object groups_obj))
392391 end else
···417416 match repl.[!i] with
418417 | '$' -> Buffer.add_char buf '$'; incr i
419418 | '&' ->
420420- Buffer.add_string buf (Pcre2.get_substring result 0);
419419+ Buffer.add_string buf (Re.Group.get result 0);
421420 incr i
422421 | '`' ->
423423- let start, _ = Pcre2.get_substring_ofs result 0 in
422422+ let start, _ = Re.Group.offset result 0 in
424423 Buffer.add_string buf (String.sub str 0 start);
425424 incr i
426425 | '\'' ->
427427- let _, stop = Pcre2.get_substring_ofs result 0 in
426426+ let _, stop = Re.Group.offset result 0 in
428427 Buffer.add_string buf (String.sub str stop (String.length str - stop));
429428 incr i
430429 | '0'..'9' as c ->
···435434 match repl.[!i + 1] with
436435 | '0'..'9' as c2 ->
437436 let idx2 = idx * 10 + (Char.code c2 - Char.code '0') in
438438- if idx2 <= Pcre2.num_of_subs result then (idx2, 2)
437437+ if idx2 <= Re.Group.nb_groups result then (idx2, 2)
439438 else (idx, 1)
440439 | _ -> (idx, 1)
441440 else (idx, 1)
442441 in
443443- (try Buffer.add_string buf (Pcre2.get_substring result idx)
444444- with Not_found -> ());
442442+ (match Re.Group.get_opt result idx with
443443+ | Some s -> Buffer.add_string buf s
444444+ | None -> ());
445445 i := !i + consumed
446446 | '<' ->
447447- (* Named group $<name> *)
447447+ (* Named group $<name> - look up index from our named_groups list *)
448448 incr i;
449449 let name_start = !i in
450450 while !i < String.length repl && repl.[!i] <> '>' do
···452452 done;
453453 let name = String.sub repl name_start (!i - name_start) in
454454 if !i < String.length repl then incr i; (* Skip '>' *)
455455- (try
456456- Buffer.add_string buf (Pcre2.get_named_substring regexp.re name result)
457457- with Not_found -> ())
455455+ (match List.assoc_opt name regexp.named_groups with
456456+ | Some idx ->
457457+ (match Re.Group.get_opt result idx with
458458+ | Some s -> Buffer.add_string buf s
459459+ | None -> ())
460460+ | None -> ())
458461 | c -> Buffer.add_char buf '$'; Buffer.add_char buf c; incr i
459462 end else begin
460463 Buffer.add_char buf repl.[!i];
···470473 let last_end = ref 0 in
471474 let matches = find_all_matches regexp str in
472475 List.iter (fun result ->
473473- let start, stop = Pcre2.get_substring_ofs result 0 in
476476+ let start, stop = Re.Group.offset result 0 in
474477 Buffer.add_string result_buf (String.sub str !last_end (start - !last_end));
475478 Buffer.add_string result_buf (do_replace result);
476479 last_end := stop
···479482 String (Buffer.contents result_buf)
480483 end else begin
481484 (* Replace first match only *)
482482- try
483483- let result = Pcre2.exec ~rex:regexp.re str in
484484- let start, stop = Pcre2.get_substring_ofs result 0 in
485485+ match Re.exec_opt regexp.re str with
486486+ | Some result ->
487487+ let start, stop = Re.Group.offset result 0 in
485488 let result_str = String.sub str 0 start ^
486489 do_replace result ^
487490 String.sub str stop (String.length str - stop) in
488491 String result_str
489489- with Not_found -> String str
492492+ | None -> String str
490493 end
491494 | None -> String str)
492495 | _ -> String str
···497500 | Object obj ->
498501 (match get_compiled_regexp obj with
499502 | Some regexp ->
500500- (try
501501- let result = Pcre2.exec ~rex:regexp.re str in
502502- let pos, _ = Pcre2.get_substring_ofs result 0 in
503503+ (match Re.exec_opt regexp.re str with
504504+ | Some result ->
505505+ let pos, _ = Re.Group.offset result 0 in
503506 Int (Int32.of_int pos)
504504- with Not_found -> Int (-1l))
507507+ | None -> Int (-1l))
505508 | None -> Int (-1l))
506509 | _ -> Int (-1l)
507510···511514 | Object obj ->
512515 (match get_compiled_regexp obj with
513516 | Some regexp ->
514514- let parts = Pcre2.split ~rex:regexp.re str in
517517+ let parts = Re.split regexp.re str in
515518 let parts = match limit with
516519 | Some n when n >= 0 ->
517520 let rec take n lst = match n, lst with
···205205 (** Default Zstd compression level (1-22, default 3). *)
206206 let default_level = 3
207207208208- let decompress data ~uncompressed_size =
209209- try Ok (Zstd.decompress uncompressed_size data)
210210- with Zstd.Error msg -> Error (Printf.sprintf "Zstd decompression failed: %s" msg)
208208+ let decompress data ~uncompressed_size:_ =
209209+ match Zstd.decompress data with
210210+ | Ok s -> Ok s
211211+ | Error msg -> Error (Printf.sprintf "Zstd decompression failed: %s" msg)
211212212213 let compress data ~level =
213214 let level = match level with Some l -> l | None -> default_level in
214214- try Ok (Zstd.compress ~level data)
215215- with Zstd.Error msg -> Error (Printf.sprintf "Zstd compression failed: %s" msg)
215215+ Ok (Zstd.compress ~level data)
216216end
217217218218(** {2 Brotli (BROTLI = 4)} *)
+2-2
project/parquet/src/column/parquet_dremel.ml
···2121 values : Parquet_value.t array;
2222 definition_levels : int array;
2323 repetition_levels : int array;
2424- max_def_level : int;
2525- max_rep_level : int;
2424+ max_def_level : int; [@warning "-69"]
2525+ max_rep_level : int; [@warning "-69"]
2626 mutable value_idx : int; (* Current position in values array *)
2727 mutable level_idx : int; (* Current position in levels arrays *)
2828}