1 diff --git a/comby-kernel.opam b/comby-kernel.opam
2 index 9db7cc5..83e6e7b 100644
3 --- a/comby-kernel.opam
4 +++ b/comby-kernel.opam
5 @@ -20,7 +20,7 @@ build: [
10 + "core-kernel" {>= "v0.16.0"}
14 diff --git a/comby-semantic.opam b/comby-semantic.opam
15 index 88563f6..fbbc122 100644
16 --- a/comby-semantic.opam
17 +++ b/comby-semantic.opam
18 @@ -20,7 +20,7 @@ build: [
23 + "core_kernel" {>= "v0.15.0"}
27 diff --git a/comby.opam b/comby.opam
28 index 9e5d96b..d5be316 100644
31 @@ -31,7 +31,7 @@ depends: [
33 "comby-kernel" {= "1.7.0"}
34 "comby-semantic" {= "1.7.0"}
36 + "core" {>= "v0.16.0"}
37 "hack_parallel" {arch != "arm32" & arch != "arm64"}
40 diff --git a/lib/app/configuration/command_configuration.ml b/lib/app/configuration/command_configuration.ml
41 index 75c3107..29826a9 100644
42 --- a/lib/app/configuration/command_configuration.ml
43 +++ b/lib/app/configuration/command_configuration.ml
48 -open Polymorphic_compare
53 @@ -16,21 +16,21 @@ type 'a next =
55 let fold_directory ?(sorted=false) root ~init ~f =
56 let rec aux acc absolute_path depth =
57 - if Sys.is_file absolute_path = `Yes then
58 + if Sys_unix.is_file absolute_path = `Yes then
59 match f acc ~depth ~absolute_path ~is_file:true with
62 - else if Sys.is_directory absolute_path = `Yes then
63 + else if Sys_unix.is_directory absolute_path = `Yes then
64 match f acc ~depth ~absolute_path ~is_file:false with
68 if Option.is_some (Sys.getenv "COMBY_TEST") || sorted then
69 - Sys.ls_dir absolute_path
70 + Sys_unix.ls_dir absolute_path
71 |> List.sort ~compare:String.compare
74 - Sys.ls_dir absolute_path
75 + Sys_unix.ls_dir absolute_path
77 List.fold dir_contents ~init:acc ~f:(fun acc subdir ->
78 aux acc (Filename.concat absolute_path subdir) (depth + 1))
79 @@ -50,8 +50,8 @@ let parse_source_directories
80 let exact_file_paths, file_patterns =
81 List.partition_map file_filters ~f:(fun path ->
83 - (String.contains path '/' && Sys.is_file path = `Yes)
84 - || (Sys.is_file ("." ^/ path) = `Yes) (* See if it matches something in the current directory *)
85 + (String.contains path '/' && Sys_unix.is_file path = `Yes)
86 + || (Sys_unix.is_file ("." ^/ path) = `Yes) (* See if it matches something in the current directory *)
88 if is_exact path then Either.First path else Either.Second path)
90 @@ -167,8 +167,8 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
91 let f acc ~depth:_ ~absolute_path ~is_file =
92 let is_leaf_directory absolute_path =
94 - Sys.ls_dir absolute_path
95 - |> List.for_all ~f:(fun path -> Sys.is_directory (absolute_path ^/ path) = `No)
96 + Sys_unix.ls_dir absolute_path
97 + |> List.for_all ~f:(fun path -> Sys_unix.is_directory (absolute_path ^/ path) = `No)
99 if is_leaf_directory absolute_path then
100 match parse_directory absolute_path with
101 @@ -178,7 +178,7 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
104 List.concat_map paths ~f:(fun path ->
105 - if Sys.is_directory path = `Yes then
106 + if Sys_unix.is_directory path = `Yes then
107 fold_directory path ~sorted:true ~init:[] ~f
109 parse_toml ?metasyntax path)
110 @@ -428,7 +428,7 @@ let parse_metasyntax metasyntax_path =
111 match metasyntax_path with
112 | None -> Matchers.Metasyntax.default_metasyntax
113 | Some metasyntax_path ->
114 - match Sys.file_exists metasyntax_path with
115 + match Sys_unix.file_exists metasyntax_path with
117 Format.eprintf "Could not open file: %s@." metasyntax_path;
119 @@ -477,14 +477,14 @@ let emit_errors { input_options; output_options; _ } =
120 ; Option.is_some input_options.directory_depth
121 && Option.value_exn (input_options.directory_depth) < 0
122 , "-depth must be 0 or greater."
123 - ; Sys.is_directory input_options.target_directory = `No
124 + ; Sys_unix.is_directory input_options.target_directory = `No
125 , "Directory specified with -d or -directory is not a directory."
126 ; output_options.json_only_diff && not output_options.json_lines
127 , "-json-only-diff can only be supplied with -json-lines."
128 ; (Option.is_some output_options.chunk_matches) && Option.is_some input_options.zip_file
129 , "chunk-matches output format is not supported for zip files."
130 ; Option.is_some output_options.interactive_review &&
131 - (not (String.equal input_options.target_directory (Sys.getcwd ())))
132 + (not (String.equal input_options.target_directory (Sys_unix.getcwd ())))
133 , "Please remove the -d option and `cd` to the directory where you want to \
134 review from. The -review, -editor, or -default-no options should only be run \
135 at the root directory of the project files to patch."
136 @@ -492,11 +492,11 @@ let emit_errors { input_options; output_options; _ } =
137 match input_options.templates with
139 List.find_map inputs ~f:(fun input ->
140 - if Sys.is_file input = `Yes then
141 + if Sys_unix.is_file input = `Yes then
142 (match Toml.Parser.from_filename input with
143 | `Error (s, _) -> Some s
145 - else if not (Sys.is_directory input = `Yes) then
146 + else if not (Sys_unix.is_directory input = `Yes) then
147 Some (Format.sprintf "Directory %S specified with -templates is not a directory." input)
150 @@ -611,7 +611,7 @@ let filter_zip_entries file_filters exclude_directory_prefix exclude_file_prefix
152 let syntax custom_matcher_path =
154 - Sys.file_exists custom_matcher_path with
155 + Sys_unix.file_exists custom_matcher_path with
157 Format.eprintf "Could not open file: %s@." custom_matcher_path;
159 @@ -795,7 +795,7 @@ let create
161 let target_directory =
162 if target_directory = "." then
163 - Filename.realpath target_directory
164 + Filename_unix.realpath target_directory
168 diff --git a/lib/app/configuration/dune b/lib/app/configuration/dune
169 index e0f9748..e417cfe 100644
170 --- a/lib/app/configuration/dune
171 +++ b/lib/app/configuration/dune
174 - (name configuration)
175 - (public_name comby.configuration)
176 - (instrumentation (backend bisect_ppx))
177 - (preprocess (pps ppx_deriving.show ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
178 - (libraries comby-kernel comby-semantic comby.patdiff comby.camlzip core yojson ppx_deriving_yojson toml lwt lwt.unix tar tar-unix))
179 + (name configuration)
180 + (public_name comby.configuration)
182 + (backend bisect_ppx))
184 + (pps ppx_deriving.show ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
193 + ppx_deriving_yojson
199 diff --git a/lib/app/configuration/external_semantic.ml b/lib/app/configuration/external_semantic.ml
200 index bdc7051..ac69b1b 100644
201 --- a/lib/app/configuration/external_semantic.ml
202 +++ b/lib/app/configuration/external_semantic.ml
203 @@ -2,13 +2,10 @@ open Core_kernel
208 - match Sys.getenv "DEBUG_COMBY" with
209 - | exception Not_found -> false
211 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
213 let lsif_hover ~name:_ ~filepath ~line ~column =
214 - String.chop_prefix_if_exists filepath ~prefix:(Sys.getcwd ()) |> fun filepath_relative_root ->
215 + String.chop_prefix_if_exists filepath ~prefix:(Sys_unix.getcwd ()) |> fun filepath_relative_root ->
216 if debug then Format.printf "File relative root: %s@." filepath;
217 if debug then Format.printf "Querying type at %d::%d@." line column;
219 diff --git a/lib/app/dune b/lib/app/dune
220 index 2ed553c..a91f826 100644
226 - (public_name comby)
227 - (instrumentation (backend bisect_ppx))
228 - (preprocess (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
234 + (public_name comby)
236 + (backend bisect_ppx))
238 + (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
239 + (libraries core comby-kernel comby.pipeline))
240 diff --git a/lib/app/interactive/dune b/lib/app/interactive/dune
241 index 815aff5..63c1757 100644
242 --- a/lib/app/interactive/dune
243 +++ b/lib/app/interactive/dune
247 - (public_name comby.interactive)
248 - (preprocess (pps ppx_sexp_conv))
249 - (libraries comby-kernel comby.configuration core shell.filename_extended lwt lwt.unix))
251 + (public_name comby.interactive)
253 + (pps ppx_sexp_conv))
256 + comby.configuration
258 + shell.filename_extended
261 diff --git a/lib/app/interactive/interactive.ml b/lib/app/interactive/interactive.ml
262 index d4bf200..b27105a 100644
263 --- a/lib/app/interactive/interactive.ml
264 +++ b/lib/app/interactive/interactive.ml
268 +module Unix = Core_unix
272 @@ -37,6 +38,7 @@ module Diff = struct
273 ~big_enough:line_big_enough
279 let cmd = sprintf "%s %S %S" prog x y in
280 @@ -52,7 +54,7 @@ module Diff = struct
281 let compare = compare
284 - P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next
285 + P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next ()
287 match float_tolerance with
289 diff --git a/lib/app/pipeline/dune b/lib/app/pipeline/dune
290 index 3369b9e..e6ec880 100644
291 --- a/lib/app/pipeline/dune
292 +++ b/lib/app/pipeline/dune
296 - (public_name comby.pipeline)
297 - (instrumentation (backend bisect_ppx))
298 - (preprocess (pps ppx_sexp_conv ppx_deriving_yojson))
299 - (libraries comby-kernel comby.statistics comby.configuration comby.interactive comby.camlzip core core.uuid yojson ppx_deriving_yojson parany
300 - (select parallel_hack.ml from
301 - (hack_parallel -> parallel_hack.available.ml)
302 - (!hack_parallel -> parallel_hack.parany_fallback.ml))
306 + (public_name comby.pipeline)
308 + (backend bisect_ppx))
310 + (pps ppx_sexp_conv ppx_deriving_yojson))
314 + comby.configuration
320 + ppx_deriving_yojson
325 + (hack_parallel -> parallel_hack.available.ml)
326 + (!hack_parallel -> parallel_hack.parany_fallback.ml))))
327 diff --git a/lib/app/pipeline/parallel_hack.available.ml b/lib/app/pipeline/parallel_hack.available.ml
328 index a901eea..ad33070 100644
329 --- a/lib/app/pipeline/parallel_hack.available.ml
330 +++ b/lib/app/pipeline/parallel_hack.available.ml
333 +module Unix = Core_unix
337 diff --git a/lib/app/statistics/dune b/lib/app/statistics/dune
338 index b14d5b1..12aff7f 100644
339 --- a/lib/app/statistics/dune
340 +++ b/lib/app/statistics/dune
344 - (public_name comby.statistics)
345 - (instrumentation (backend bisect_ppx))
346 - (preprocess (pps ppx_deriving_yojson))
347 - (libraries yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
349 + (public_name comby.statistics)
351 + (backend bisect_ppx))
353 + (pps ppx_deriving_yojson))
354 + (libraries yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
355 diff --git a/lib/app/vendored/patdiff/kernel/src/dune b/lib/app/vendored/patdiff/kernel/src/dune
356 index 7a6353d..b79cba2 100644
357 --- a/lib/app/vendored/patdiff/kernel/src/dune
358 +++ b/lib/app/vendored/patdiff/kernel/src/dune
360 -(library (name patdiff_kernel) (public_name comby.patdiff_kernel)
362 + (name patdiff_kernel)
363 + (public_name comby.patdiff_kernel)
364 (libraries core_kernel.composition_infix core_kernel patience_diff re)
365 - (preprocess (pps ppx_jane)))
368 diff --git a/lib/app/vendored/patdiff/kernel/src/float_tolerance.ml b/lib/app/vendored/patdiff/kernel/src/float_tolerance.ml
369 index 4e064fb..dca77b2 100644
370 --- a/lib/app/vendored/patdiff/kernel/src/float_tolerance.ml
371 +++ b/lib/app/vendored/patdiff/kernel/src/float_tolerance.ml
372 @@ -287,7 +287,7 @@ end = struct
373 ~running_step:(fun (car, pos) cadr ->
375 | Same car_lines, Same cadr_lines ->
376 - Skip (Same (Array.concat [ car_lines; cadr_lines ]), pos)
377 + Skip {state = (Same (Array.concat [ car_lines; cadr_lines ]), pos)}
378 | Unified _, _ | _, Unified _ ->
381 @@ -296,7 +296,7 @@ end = struct
382 (cadr : string Range.t)]
383 | (Prev _ | Next _ | Replace _), (Prev _ | Next _ | Replace _)
384 | Same _, (Prev _ | Next _ | Replace _)
385 - | (Prev _ | Next _ | Replace _), Same _ -> Yield ((car, pos), (cadr, Middle)))
386 + | (Prev _ | Next _ | Replace _), Same _ -> Yield {value = (car, pos); state = (cadr, Middle)})
387 ~inner_finished:(fun (last, pos) ->
390 @@ -308,7 +308,7 @@ end = struct
392 ~finishing_step:(function
394 - | Some result -> Yield (result, None))
395 + | Some result -> Yield {value = result; state = None})
399 @@ -448,7 +448,7 @@ end = struct
400 ~init:{ prev_start; next_start; ranges = [] }
401 ~running_step:(fun t drop_or_keep ->
402 match (drop_or_keep : Drop_or_keep.t) with
403 - | Keep range -> Skip { t with ranges = range :: t.ranges }
404 + | Keep range -> Skip {state = { t with ranges = range :: t.ranges }}
406 let hunk = to_hunk t in
408 @@ -457,11 +457,11 @@ end = struct
412 - if List.is_empty (Hunk.ranges hunk) then Skip t else Yield (hunk, t))
413 + if List.is_empty (Hunk.ranges hunk) then Skip {state = t} else Yield {value = hunk; state = t})
414 ~inner_finished:(fun t -> if List.is_empty t.ranges then None else Some t)
415 ~finishing_step:(function
417 - | Some t -> Yield (to_hunk t, None))
418 + | Some t -> Yield {value = to_hunk t; state = None})
422 diff --git a/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml b/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
423 index 4f53a0b..88ee0e3 100644
424 --- a/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
425 +++ b/lib/app/vendored/patdiff/kernel/src/patdiff_core.ml
426 @@ -138,6 +138,7 @@ module Make (Output_impls : Output_impls) = struct
427 ~big_enough:line_big_enough
433 type word_or_newline =
434 @@ -345,6 +346,7 @@ module Make (Output_impls : Output_impls) = struct
435 ~big_enough:word_big_enough
441 let ranges_are_just_whitespace (ranges : _ Patience_diff.Range.t list) =
442 diff --git a/lib/app/vendored/patdiff/lib/src/compare_core.ml b/lib/app/vendored/patdiff/lib/src/compare_core.ml
443 index fafb201..8b40d09 100644
444 --- a/lib/app/vendored/patdiff/lib/src/compare_core.ml
445 +++ b/lib/app/vendored/patdiff/lib/src/compare_core.ml
449 +module Unix = Core_unix
451 let lines_of_contents contents =
452 let lines = Array.of_list (String.split_lines contents) in
453 @@ -100,6 +101,7 @@ let compare_lines (config : Configuration.t) ?prev_diff ?next_diff ~prev ~next (
454 ~big_enough:line_big_enough
460 let cmd = sprintf "%s %S %S" prog x y in
461 @@ -116,7 +118,7 @@ let compare_lines (config : Configuration.t) ?prev_diff ?next_diff ~prev ~next (
462 let compare = compare
465 - P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next
466 + P.get_hunks ~transform ~context ~big_enough:line_big_enough ~prev ~next ()
469 match config.float_tolerance with
470 @@ -361,7 +363,7 @@ let rec diff_dirs_internal (config : Configuration.t) ~prev_dir ~next_dir ~file_
471 | None -> Fn.const true
472 | Some file_filter -> file_filter
474 - Sys.ls_dir (File_name.real_name_exn dir)
475 + Sys_unix.ls_dir (File_name.real_name_exn dir)
476 |> List.filter ~f:(fun x ->
477 let x = File_name.real_name_exn dir ^/ x in
478 match Unix.stat x with
479 diff --git a/lib/app/vendored/patdiff/lib/src/compare_core.mli b/lib/app/vendored/patdiff/lib/src/compare_core.mli
480 index e919512..caa8dcb 100644
481 --- a/lib/app/vendored/patdiff/lib/src/compare_core.mli
482 +++ b/lib/app/vendored/patdiff/lib/src/compare_core.mli
486 +module Unix = Core_unix
490 diff --git a/lib/app/vendored/patdiff/lib/src/configuration.ml b/lib/app/vendored/patdiff/lib/src/configuration.ml
491 index 6879daa..7d59706 100644
492 --- a/lib/app/vendored/patdiff/lib/src/configuration.ml
493 +++ b/lib/app/vendored/patdiff/lib/src/configuration.ml
494 @@ -481,7 +481,7 @@ let rec load_exn' ~set config_file =
495 | Error _another_exn -> raise exn
497 (let new_file = config_file ^ ".new" in
498 - match Sys.file_exists new_file with
499 + match Sys_unix.file_exists new_file with
500 | `Yes | `Unknown -> ()
502 (try Sexp.save_hum new_file (On_disk.V1.sexp_of_t c) with
503 @@ -564,7 +564,7 @@ let get_config ?filename () =
504 (* ~/.patdiff exists *)
505 Option.bind (Sys.getenv "HOME") ~f:(fun home ->
506 let f = home ^/ ".patdiff" in
507 - match Sys.file_exists f with
508 + match Sys_unix.file_exists f with
510 | `No | `Unknown -> None)
512 diff --git a/lib/app/vendored/patdiff/lib/src/dune b/lib/app/vendored/patdiff/lib/src/dune
513 index 007acad..b6a0f80 100644
514 --- a/lib/app/vendored/patdiff/lib/src/dune
515 +++ b/lib/app/vendored/patdiff/lib/src/dune
517 -(library (name patdiff) (public_name comby.patdiff)
518 - (libraries core_kernel.composition_infix core core.linux_ext comby.patdiff_kernel
521 + (public_name comby.patdiff)
523 + core_kernel.composition_infix
526 + core_unix.linux_ext
528 + comby.patdiff_kernel
530 - (preprocess (pps ppx_jane)))
533 diff --git a/lib/app/vendored/patdiff/lib/src/html_output.ml b/lib/app/vendored/patdiff/lib/src/html_output.ml
534 index 3d08f91..93ae8af 100644
535 --- a/lib/app/vendored/patdiff/lib/src/html_output.ml
536 +++ b/lib/app/vendored/patdiff/lib/src/html_output.ml
540 +module Unix = Core_unix
542 include Patdiff_kernel.Html_output.Private.Make (struct
544 diff --git a/lib/kernel/match/dune b/lib/kernel/match/dune
545 index 03b120a..4d48b61 100644
546 --- a/lib/kernel/match/dune
547 +++ b/lib/kernel/match/dune
551 - (public_name comby-kernel.match)
552 - (instrumentation (backend bisect_ppx))
553 - (preprocess (pps ppx_deriving.eq ppx_sexp_conv ppx_deriving_yojson))
554 - (libraries core_kernel yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
556 + (public_name comby-kernel.match)
558 + (backend bisect_ppx))
560 + (pps ppx_deriving.eq ppx_sexp_conv ppx_deriving_yojson))
564 + ppx_deriving_yojson
565 + ppx_deriving_yojson.runtime))
566 diff --git a/lib/kernel/matchers/alpha.ml b/lib/kernel/matchers/alpha.ml
567 index d6116f7..7d16171 100644
568 --- a/lib/kernel/matchers/alpha.ml
569 +++ b/lib/kernel/matchers/alpha.ml
570 @@ -13,20 +13,11 @@ module R = MakeRegexp(Regexp)
571 let configuration_ref = ref (Configuration.create ())
572 let weaken_delimiter_hole_matching = false
575 - match Sys.getenv "DEBUG_COMBY" with
576 - | exception Not_found -> false
578 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
581 - match Sys.getenv "DEBUG_COMBY_HOLE" with
582 - | exception Not_found -> false
584 +let debug_hole = Sys.getenv "DEBUG_COMBY_HOLE" |> Option.is_some
586 -let debug_position =
587 - match Sys.getenv "DEBUG_COMBY_POS" with
588 - | exception Not_found -> false
590 +let debug_position = Sys.getenv "DEBUG_COMBY_POS" |> Option.is_some
592 let f _ = return Types.Unit
594 @@ -147,7 +138,7 @@ module Make (Lang : Types.Language.S) (Meta : Types.Metasyntax.S) (Ext : Types.E
596 >>= fun _ -> f Types.Unit
598 - let sequence_chain (plist : ('c, Match.t) parser sexp_list) : ('c, Match.t) parser =
599 + let sequence_chain (plist : ('c, Match.t) parser list) : ('c, Match.t) parser =
600 List.fold plist ~init:(return Types.Unit) ~f:(>>)
602 let with_debug_matcher s tag =
603 @@ -745,7 +736,7 @@ module Make (Lang : Types.Language.S) (Meta : Types.Metasyntax.S) (Ext : Types.E
604 let hole_parser ?at_depth sort dimension =
605 let open Types.Hole in
607 - let open Polymorphic_compare in
609 List.fold ~init:[] hole_parsers ~f:(fun acc (sort', parser) -> if sort' = sort then parser::acc else acc)
611 let skip_signal hole = skip (string "_signal_hole") |>> fun () -> Types.Hole hole in
612 diff --git a/lib/kernel/matchers/dune b/lib/kernel/matchers/dune
613 index 12ed326..4625458 100644
614 --- a/lib/kernel/matchers/dune
615 +++ b/lib/kernel/matchers/dune
619 - (public_name comby-kernel.matchers)
620 - (instrumentation (backend bisect_ppx))
621 - (preprocess (pps ppx_here ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
622 - (libraries comby-kernel.replacement comby-kernel.parsers comby-kernel.match comby-kernel.vangstrom core_kernel mparser mparser-pcre re yojson ppx_deriving_yojson))
624 + (public_name comby-kernel.matchers)
626 + (backend bisect_ppx))
628 + (pps ppx_here ppx_sexp_conv ppx_sexp_message ppx_deriving_yojson))
630 + comby-kernel.replacement
631 + comby-kernel.parsers
633 + comby-kernel.vangstrom
639 + ppx_deriving_yojson))
640 diff --git a/lib/kernel/matchers/evaluate.ml b/lib/kernel/matchers/evaluate.ml
641 index 9ea71a0..4f63ab6 100644
642 --- a/lib/kernel/matchers/evaluate.ml
643 +++ b/lib/kernel/matchers/evaluate.ml
644 @@ -3,10 +3,7 @@ open Core_kernel
649 - match Sys.getenv "DEBUG_COMBY" with
650 - | exception Not_found -> false
652 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
654 type result = bool * Match.environment option
656 @@ -102,7 +99,7 @@ let apply
659 List.find_map cases ~f:(fun (template, case_expression) -> evaluate template case_expression)
660 - |> Option.value_map ~f:ident ~default:(false, Some env)
661 + |> Option.value_map ~f:Fn.id ~default:(false, Some env)
663 (* rewrite ... { ... } *)
664 | Rewrite (Template t, (match_template, rewrite_template)) ->
665 diff --git a/lib/kernel/matchers/omega.ml b/lib/kernel/matchers/omega.ml
666 index 61cc69a..3445307 100644
667 --- a/lib/kernel/matchers/omega.ml
668 +++ b/lib/kernel/matchers/omega.ml
669 @@ -32,15 +32,9 @@ let push_source_ref : string ref = ref ""
671 let filepath_ref : string option ref = ref None
674 - match Sys.getenv "DEBUG_COMBY" with
675 - | exception Not_found -> false
677 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
680 - match Sys.getenv "REWRITE" with
681 - | exception Not_found -> false
683 +let rewrite = Sys.getenv "REWRITE" |> Option.is_some
685 let actual = Buffer.create 10
687 @@ -540,7 +534,7 @@ module Make (Language : Types.Language.S) (Meta : Metasyntax.S) (Ext : External.
689 let hole_parser sort dimension : (production * 'a) t t =
690 let hole_parser = (* This must be fold, can't be find *)
691 - let open Polymorphic_compare in
693 List.fold ~init:[] Template.Matching.hole_parsers ~f:(fun acc (sort', parser) ->
694 if sort' = sort then parser::acc else acc)
696 diff --git a/lib/kernel/matchers/preprocess.ml b/lib/kernel/matchers/preprocess.ml
697 index 84f3ed0..b6d10e7 100644
698 --- a/lib/kernel/matchers/preprocess.ml
699 +++ b/lib/kernel/matchers/preprocess.ml
704 - match Sys.getenv "DEBUG_COMBY" with
705 - | exception Not_found -> false
707 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
709 let append_rule (module Parser : Types.Rule.S) rule parent_rule =
711 diff --git a/lib/kernel/matchers/regexp.ml b/lib/kernel/matchers/regexp.ml
712 index ef0bd59..906820b 100644
713 --- a/lib/kernel/matchers/regexp.ml
714 +++ b/lib/kernel/matchers/regexp.ml
715 @@ -3,7 +3,7 @@ open Vangstrom
717 match Sys.getenv "DEBUG_COMBY" with
718 | exception Not_found -> false
720 + | (_ : string) -> true
722 module type Regexp_engine_intf = sig
724 diff --git a/lib/kernel/matchers/rewrite.ml b/lib/kernel/matchers/rewrite.ml
725 index 32c4740..545cba5 100644
726 --- a/lib/kernel/matchers/rewrite.ml
727 +++ b/lib/kernel/matchers/rewrite.ml
728 @@ -4,10 +4,7 @@ open Core_kernel
733 - match Sys.getenv "DEBUG_COMBY" with
734 - | exception Not_found -> false
736 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
739 let uuid_for_id_counter = ref 0 in
740 @@ -46,24 +43,24 @@ let parse_first_label ?(metasyntax = Metasyntax.default_metasyntax) template =
742 parse_string ~consume:All parser template
744 - | Ok label -> List.find_map label ~f:ident
745 + | Ok label -> List.find_map label ~f:Fn.id
749 ?(metasyntax = Metasyntax.default_metasyntax)
752 - let label_table = String.Table.create () in
753 + let label_table = Hashtbl.create (module String) in
754 let template_ref = ref template in
755 let current_label_ref = ref (parse_first_label ~metasyntax !template_ref) in
756 while Option.is_some !current_label_ref do
757 let label = Option.value_exn !current_label_ref in
759 - match String.Table.find label_table label with
760 + match Hashtbl.find label_table label with
764 - if String.(label <> "") then String.Table.add_exn label_table ~key:label ~data:id;
765 + if String.(label <> "") then Hashtbl.add_exn label_table ~key:label ~data:id;
768 let left, right = replacement_sentinel metasyntax in
769 diff --git a/lib/kernel/matchers/template.ml b/lib/kernel/matchers/template.ml
770 index 423a07f..136236c 100644
771 --- a/lib/kernel/matchers/template.ml
772 +++ b/lib/kernel/matchers/template.ml
773 @@ -4,10 +4,7 @@ open Core_kernel
778 - match Sys.getenv "DEBUG_COMBY" with
779 - | exception Not_found -> false
781 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
783 module Make (Metasyntax : Types.Metasyntax.S) (External : Types.External.S) : Types.Template.S = struct
785 diff --git a/lib/kernel/parsers/dune b/lib/kernel/parsers/dune
786 index 28b020c..0cc1fa5 100644
787 --- a/lib/kernel/parsers/dune
788 +++ b/lib/kernel/parsers/dune
792 - (public_name comby-kernel.parsers)
793 - (instrumentation (backend bisect_ppx))
794 - (preprocess (pps ppx_sexp_conv))
795 - (libraries core_kernel comby-kernel.vangstrom mparser))
797 + (public_name comby-kernel.parsers)
799 + (backend bisect_ppx))
801 + (pps ppx_sexp_conv))
802 + (libraries core_kernel comby-kernel.vangstrom mparser))
803 diff --git a/lib/kernel/replacement/dune b/lib/kernel/replacement/dune
804 index 3e62de6..485b716 100644
805 --- a/lib/kernel/replacement/dune
806 +++ b/lib/kernel/replacement/dune
810 - (public_name comby-kernel.replacement)
811 - (instrumentation (backend bisect_ppx))
812 - (preprocess (pps ppx_deriving_yojson))
813 - (libraries comby-kernel.match core_kernel yojson ppx_deriving_yojson ppx_deriving_yojson.runtime))
815 + (public_name comby-kernel.replacement)
817 + (backend bisect_ppx))
819 + (pps ppx_deriving_yojson))
824 + ppx_deriving_yojson
825 + ppx_deriving_yojson.runtime))
826 diff --git a/lib/semantic/dune b/lib/semantic/dune
827 index 9a244d3..186a2ed 100644
828 --- a/lib/semantic/dune
829 +++ b/lib/semantic/dune
832 - (name comby_semantic)
833 - (public_name comby-semantic)
834 - (instrumentation (backend bisect_ppx))
835 - (preprocess (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
842 + (name comby_semantic)
843 + (public_name comby-semantic)
845 + (backend bisect_ppx))
847 + (pps ppx_deriving.show ppx_deriving.eq ppx_sexp_conv))
848 + (libraries core_kernel lwt cohttp cohttp-lwt-unix yojson))
849 diff --git a/lib/semantic/lsif.ml b/lib/semantic/lsif.ml
850 index 49747bc..d6b3e19 100644
851 --- a/lib/semantic/lsif.ml
852 +++ b/lib/semantic/lsif.ml
853 @@ -3,10 +3,7 @@ open Lwt
858 - match Sys.getenv "DEBUG_COMBY" with
859 - | exception Not_found -> false
861 +let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
863 module Formatting = struct
865 diff --git a/src/dune b/src/dune
866 index 444a5a3..f006195 100644
871 - (libraries comby core ppx_deriving_yojson ppx_deriving_yojson.runtime
872 - (select if_hack_parallel.ml from
873 - (hack_parallel -> if_hack_parallel.available.ml)
874 - (!hack_parallel -> if_hack_parallel.unavailable.ml))
876 - (preprocess (pps ppx_deriving_yojson ppx_let ppx_deriving.show ppx_sexp_conv))
880 + core_unix.command_unix
881 + ppx_deriving_yojson
882 + ppx_deriving_yojson.runtime
884 + if_hack_parallel.ml
886 + (hack_parallel -> if_hack_parallel.available.ml)
887 + (!hack_parallel -> if_hack_parallel.unavailable.ml)))
889 + (pps ppx_deriving_yojson ppx_let ppx_deriving.show ppx_sexp_conv))
890 (modules main if_hack_parallel)
897 - (files (main.exe as comby)))
899 + (main.exe as comby)))
900 diff --git a/src/main.ml b/src/main.ml
901 index 1def81d..79af76b 100644
906 +module Unix = Core_unix
907 open Command.Let_syntax
910 @@ -47,7 +48,7 @@ let substitute_environment_only_and_exit metasyntax_path anonymous_arguments jso
911 match metasyntax_path with
912 | None -> Matchers.Metasyntax.default_metasyntax
913 | Some metasyntax_path ->
914 - match Sys.file_exists metasyntax_path with
915 + match Sys_unix.file_exists metasyntax_path with
917 Format.eprintf "Could not open file: %s@." metasyntax_path;
919 @@ -95,7 +96,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
920 and verbose = flag "verbose" no_arg ~doc:(Format.sprintf "Log to %s" verbose_out_file)
921 and rule = flag "rule" (optional_with_default "where true" string) ~doc:"rule Apply rules to matches."
922 and match_timeout = flag "timeout" (optional_with_default 3 int) ~doc:"seconds Set match timeout on a source. Default: 3 seconds"
923 - and target_directory = flag "directory" ~aliases:["d"] (optional_with_default (Sys.getcwd ()) string) ~doc:(Format.sprintf "path Run recursively on files in a directory relative to the root. Default is current directory: %s" @@ Sys.getcwd ())
924 + and target_directory = flag "directory" ~aliases:["d"] (optional_with_default (Sys_unix.getcwd ()) string) ~doc:(Format.sprintf "path Run recursively on files in a directory relative to the root. Default is current directory: %s" @@ Sys_unix.getcwd ())
925 and directory_depth = flag "depth" (optional int) ~doc:"n Depth to recursively descend into directories"
926 and templates = flag "templates" ~aliases:["config"; "configuration"] (optional (Arg_type.comma_separated string)) ~doc:"paths CSV of directories containing templates, or TOML configuration files"
927 and file_filters = flag "extensions" ~aliases:["e"; "file-extensions"; "f"] (optional (Arg_type.comma_separated string)) ~doc:"extensions Comma-separated extensions to include, like \".go\" or \".c,.h\". It is just a file suffix, so you can use it to filter file names like \"main.go\". The extension will be used to infer a matcher, unless -custom-matcher or -matcher is specified"
928 @@ -147,7 +148,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
930 List.map l ~f:(fun pattern ->
931 if String.contains pattern '/' then
932 - match Filename.realpath pattern with
933 + match Filename_unix.realpath pattern with
934 | exception Unix.Unix_error _ ->
936 "No such file or directory: %s. Comby interprets \
937 @@ -204,7 +205,7 @@ let base_command_parameters : (unit -> 'result) Command.Param.t =
938 let omega = omega || omega_env in
939 let fast_offset_conversion_env = Option.is_some @@ Sys.getenv "FAST_OFFSET_CONVERSION_COMBY" in
940 let fast_offset_conversion = fast_offset_conversion_env || fast_offset_conversion in
941 - let arch = Unix.Utsname.machine (Core.Unix.uname ()) in
942 + let arch = Unix.Utsname.machine (Unix.uname ()) in
943 let compute_mode = match sequential, parany, arch with
944 | true, _, _ -> `Sequential
946 @@ -304,7 +305,7 @@ let parse_comby_dot_file () =
949 If_hack_parallel.check_entry_point ();
950 - Command.run default_command ~version:"1.8.1" ~extend:(fun _ ->
951 - match Sys.file_exists ".comby" with
952 + Command_unix.run default_command ~version:"1.8.1" ~extend:(fun _ ->
953 + match Sys_unix.file_exists ".comby" with
954 | `Yes -> parse_comby_dot_file ()
956 diff --git a/test/alpha/dune b/test/alpha/dune
957 index d7e5532..020677c 100644
958 --- a/test/alpha/dune
959 +++ b/test/alpha/dune
962 (name alpha_test_integration)
965 - test_special_matcher_cases
966 - test_substring_disabled)
967 + (modules test_special_matcher_cases test_substring_disabled)
969 - (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
976 + (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
977 + (libraries comby cohttp-lwt-unix core camlzip))
981 -(deps (source_tree example) (source_tree example/src/.ignore-me)))
984 + (source_tree example)
985 + (source_tree example/src/.ignore-me)))
986 diff --git a/test/common/dune b/test/common/dune
987 index 6851f2e..bc3c055 100644
988 --- a/test/common/dune
989 +++ b/test/common/dune
992 test_template_constraints
993 test_custom_metasyntax
994 - test_rewrite_attributes
996 + test_rewrite_attributes)
998 - (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
1005 + (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
1006 + (libraries comby cohttp-lwt-unix core camlzip))
1010 -(deps (source_tree example) (source_tree example/src/.ignore-me)))
1013 + (source_tree example)
1014 + (source_tree example/src/.ignore-me)))
1015 diff --git a/test/common/test_cli.ml b/test/common/test_cli.ml
1016 index 3606367..d5d0c0b 100644
1017 --- a/test/common/test_cli.ml
1018 +++ b/test/common/test_cli.ml
1023 +module Filename = Filename_unix
1024 +module Sys = Sys_unix
1025 module Time = Core_kernel.Time_ns.Span
1026 +module Unix = Core_unix
1028 let binary_path = "../../../../comby"
1030 diff --git a/test/common/test_cli_helper.ml b/test/common/test_cli_helper.ml
1031 index 5791ee6..18372ae 100644
1032 --- a/test/common/test_cli_helper.ml
1033 +++ b/test/common/test_cli_helper.ml
1037 module Time = Core_kernel.Time_ns.Span
1038 +module Unix = Core_unix
1040 let binary_path = "../../../../comby"
1042 diff --git a/test/omega/dune b/test/omega/dune
1043 index 3b31a7e..bf68dcb 100644
1044 --- a/test/omega/dune
1045 +++ b/test/omega/dune
1047 (name omega_test_integration)
1057 test_special_matcher_cases
1058 test_substring_disabled)
1060 - (preprocess (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
1067 + (pps ppx_expect ppx_sexp_message ppx_deriving_yojson))
1068 + (libraries comby cohttp-lwt-unix core camlzip))
1072 -(deps (source_tree example) (source_tree example/src/.ignore-me)))
1075 + (source_tree example)
1076 + (source_tree example/src/.ignore-me)))