Skip to content

Commit 71cdc72

Browse files
authored
v2 prep (#396)
1 parent ccdeb2b commit 71cdc72

71 files changed

Lines changed: 856 additions & 5389 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

comby-kernel.opam

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ depends: [
2121
"dune" {>= "2.8.0"}
2222
"ocaml" {>= "4.08.1"}
2323
"core_kernel"
24-
"mparser" {>= "1.3"}
25-
"mparser-pcre"
2624
"ppx_deriving"
2725
"ppx_deriving_yojson" {>= "3.6.0"}
2826
"yojson" {>= "1.6.0" < "2.0.0"}

comby.opam

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@ depends: [
3232
"comby-kernel" {= version}
3333
"comby-semantic" {= version}
3434
"core"
35+
"cstruct-lwt"
3536
"hack_parallel" {arch != "arm32" & arch != "arm64"}
3637
"lwt"
3738
"lwt_react"
3839
"lwt_ssl"
39-
"mparser" {>= "1.3"}
40-
"mparser-pcre"
4140
"parany" {>= "12.0.3"}
4241
"patience_diff" {>= "v0.14" & < "v0.15"}
4342
"ppx_deriving"
4443
"ppx_deriving_yojson" {>= "3.6.0"}
4544
"yojson" {>= "1.6.0" < "2.0.0"}
4645
"pcre"
4746
"shell"
48-
"tar"
49-
"tar-unix"
47+
"tar" {< "3.0.0"}
48+
"tar-unix" {< "3.0.0"}
5049
"toml" {>= "6.0.0"}
5150
"bisect_ppx" {with-test & dev & >= "2.5.0"}
5251
]

docs/third-party-licenses/ALL.txt

Lines changed: 0 additions & 538 deletions
Large diffs are not rendered by default.

docs/third-party-licenses/pull-and-update-release-scripts.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
LIBS="ppx_deriving_yojson core ppxlib ppx_deriving hack_parallel opium pcre-ocaml ocaml-tls camlzip bisect_ppx mparser ocaml-ci-scripts patdiff lwt toml"
3+
LIBS="ppx_deriving_yojson core ppxlib ppx_deriving hack_parallel opium pcre-ocaml ocaml-tls camlzip bisect_ppx ocaml-ci-scripts patdiff lwt toml"
44

55
rm ALL.txt 2> /dev/null
66
for l in $LIBS; do rm -rf $l; done
@@ -49,10 +49,6 @@ wget -P camlzip https://raw.githubusercontent.com/xavierleroy/camlzip/master/LIC
4949
mkdir bisect_ppx && \
5050
wget -P bisect_ppx https://raw.githubusercontent.com/aantron/bisect_ppx/master/LICENSE.md
5151

52-
# LGPL
53-
mkdir mparser && \
54-
wget -P mparser https://raw.githubusercontent.com/comby-tools/mparser/master/LICENSE.txt
55-
5652
# ISC
5753
mkdir ocaml-ci-scripts && \
5854
wget -P ocaml-ci-scripts https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/LICENSE.md

lib/app/configuration/command_configuration.ml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ type user_input_options =
219219
; override_matcher : string option
220220
; regex_pattern : bool
221221
; ripgrep_args : string option
222-
; omega : bool
223222
}
224223

225224
type compute_mode =
@@ -628,24 +627,14 @@ let extension file_filters =
628627
| _, Some extension -> "." ^ extension
629628
| extension, None -> "." ^ extension)
630629

631-
let of_extension
632-
(module Engine : Matchers.Engine.S)
633-
(module External : Matchers.External.S)
634-
file_filters
635-
=
630+
let of_extension (module External : Matchers.External.S) file_filters =
636631
let external_handler = External.handler in
637632
let extension = extension file_filters in
638-
match Engine.select_with_extension extension ~external_handler with
633+
match Matchers.select_with_extension extension ~external_handler with
639634
| Some matcher -> matcher, Some extension, None
640-
| None -> (module Engine.Generic), Some extension, None
635+
| None -> (module Matchers.Generic), Some extension, None
641636

642-
let select_matcher custom_metasyntax custom_matcher override_matcher file_filters omega =
643-
let (module Engine : Matchers.Engine.S) =
644-
if omega then
645-
(module Matchers.Omega)
646-
else
647-
(module Matchers.Alpha)
648-
in
637+
let select_matcher custom_metasyntax custom_matcher override_matcher file_filters =
649638
let module External = struct
650639
let handler = External_semantic.lsif_hover
651640
end
@@ -656,15 +645,15 @@ let select_matcher custom_metasyntax custom_matcher override_matcher file_filter
656645
(* custom matcher, optional custom metasyntax *)
657646
let metasyntax = parse_metasyntax custom_metasyntax in
658647
let syntax = syntax custom_matcher in
659-
if debug then Format.printf "Engine.create@.";
660-
Engine.create ~metasyntax syntax, None, Some metasyntax
648+
if debug then Format.printf "Matchers.create@.";
649+
Matchers.create ~metasyntax syntax, None, Some metasyntax
661650
| _, Some language, custom_metasyntax ->
662651
(* forced language, optional custom metasyntax *)
663652
let metasyntax = parse_metasyntax custom_metasyntax in
664653
let (module Metasyntax) = Matchers.Metasyntax.create metasyntax in
665654
let (module Language) = force_language language in
666655
if debug then Format.printf "Engine.Make@.";
667-
( (module Engine.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
656+
( (module Matchers.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
668657
, None
669658
, Some metasyntax )
670659
| _, _, Some custom_metasyntax ->
@@ -673,13 +662,13 @@ let select_matcher custom_metasyntax custom_matcher override_matcher file_filter
673662
let (module Metasyntax) = Matchers.Metasyntax.create metasyntax in
674663
let (module Language) = force_language (extension file_filters) in
675664
if debug then Format.printf "Engine.Make2@.";
676-
( (module Engine.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
665+
( (module Matchers.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
677666
, None
678667
, Some metasyntax )
679668
| _, _, None ->
680669
(* infer language from file filters, use default metasyntax *)
681-
if debug then Format.printf "Engine.Infer@.";
682-
of_extension (module Engine) (module External) file_filters
670+
if debug then Format.printf "Matchers.Infer@.";
671+
of_extension (module External) file_filters
683672

684673
let regex_of_specifications specifications =
685674
Format.sprintf "(%s)"
@@ -722,7 +711,6 @@ let create
722711
; override_matcher
723712
; regex_pattern
724713
; ripgrep_args
725-
; omega
726714
}
727715
; run_options
728716
; output_options =
@@ -831,7 +819,7 @@ let create
831819
Printer.Rewrite.print replacement_output source_path replacements result source_content
832820
in
833821
let ((module M) as matcher), _, metasyntax =
834-
select_matcher custom_metasyntax custom_matcher override_matcher file_filters omega
822+
select_matcher custom_metasyntax custom_matcher override_matcher file_filters
835823
in
836824
return
837825
{ matcher

lib/app/configuration/command_configuration.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ type user_input_options =
6060
; override_matcher : string option
6161
; regex_pattern : bool
6262
; ripgrep_args : string option
63-
; omega : bool
6463
}
6564

6665
type compute_mode =

lib/app/configuration/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
comby.patdiff
1212
comby.camlzip
1313
core
14+
pcre
1415
yojson
1516
ppx_deriving_yojson
1617
toml

lib/app/pipeline/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
comby.camlzip
1414
core
1515
core.uuid
16+
cstruct-lwt
1617
yojson
1718
ppx_deriving_yojson
1819
parany

lib/kernel/comby_kernel.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module Replacement = Replacement
77
type replacement = Replacement.result
88

99
module Matchers = struct
10-
module Engine = Matchers.Engine
1110
module Language = Matchers.Language
1211
module Matcher = Matchers.Matcher
1312
module Configuration = Matchers.Configuration
@@ -20,11 +19,10 @@ module Matchers = struct
2019
type metasyntax = Matchers.Metasyntax.t
2120

2221
module External = Matchers.External
23-
module Alpha = Matchers.Alpha
24-
module Omega = Matchers.Omega
2522
module Languages = Matchers.Languages
2623
module Template = Matchers.Template
2724
module Ast = Matchers.Ast
25+
include Matchers.Matcher_engine
2826

2927
module Rule = struct
3028
include Matchers.Rule

lib/kernel/comby_kernel.mli

Lines changed: 88 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -661,106 +661,94 @@ module Matchers : sig
661661
val select_with_extension : string -> (module Language.S) option
662662
end
663663

664-
module Engine : sig
665-
module type S = sig
666-
module Make (_ : Language.S) (_ : Metasyntax.S) (_ : External.S) : Matcher.S
667-
668-
(** {4 Supported Matchers} *)
669-
module Text : Matcher.S
670-
671-
module Paren : Matcher.S
672-
module Dyck : Matcher.S
673-
module JSON : Matcher.S
674-
module JSONC : Matcher.S
675-
module GraphQL : Matcher.S
676-
module Dhall : Matcher.S
677-
module Latex : Matcher.S
678-
module Assembly : Matcher.S
679-
module Clojure : Matcher.S
680-
module Lisp : Matcher.S
681-
module Generic : Matcher.S
682-
module Bash : Matcher.S
683-
module Ruby : Matcher.S
684-
module Elixir : Matcher.S
685-
module Python : Matcher.S
686-
module Html : Matcher.S
687-
module Xml : Matcher.S
688-
module SQL : Matcher.S
689-
module Erlang : Matcher.S
690-
module C : Matcher.S
691-
module Csharp : Matcher.S
692-
module Java : Matcher.S
693-
module CSS : Matcher.S
694-
module Kotlin : Matcher.S
695-
module Scala : Matcher.S
696-
module Nim : Matcher.S
697-
module Matlab : Matcher.S
698-
module Dart : Matcher.S
699-
module Php : Matcher.S
700-
module Go : Matcher.S
701-
module Javascript : Matcher.S
702-
module Jsx : Matcher.S
703-
module Typescript : Matcher.S
704-
module Tsx : Matcher.S
705-
module Swift : Matcher.S
706-
module Rust : Matcher.S
707-
module R : Matcher.S
708-
module OCaml : Matcher.S
709-
module Reason : Matcher.S
710-
module Fsharp : Matcher.S
711-
module Pascal : Matcher.S
712-
module Julia : Matcher.S
713-
module Fortran : Matcher.S
714-
module Haskell : Matcher.S
715-
module HCL : Matcher.S
716-
module Elm : Matcher.S
717-
module Zig : Matcher.S
718-
module Coq : Matcher.S
719-
module Move : Matcher.S
720-
module Solidity : Matcher.S
721-
module C_nested_comments : Matcher.S
722-
723-
(** [all] returns all default matchers. *)
724-
val all : (module Matcher.S) list
725-
726-
(** [select_with_extension metasyntax external file_extension] is a
727-
convenience function that returns a matcher associated with a
728-
[file_extension]. E.g., use ".c" to get the C matcher. For a full list
729-
of extensions associated with matchers, run comby -list. If
730-
[metasyntax] is specified, the matcher will use a custom metasyntax
731-
definition instead of the default. An experimental [external] callback
732-
is a general callback for handling external properties in the rewrite
733-
template. *)
734-
val select_with_extension
735-
: ?metasyntax:Metasyntax.t
736-
-> ?external_handler:External.t
737-
-> string
738-
-> (module Matcher.S) option
739-
740-
(** [create metasyntax external syntax] creates a matcher for a language
741-
defined by [syntax]. If [metasyntax] is specified, the matcher will use
742-
a custom metasyntax definition instead of the default. An experimental
743-
[external] callback is a general callback for handling external
744-
properties in the rewrite template. *)
745-
val create
746-
: ?metasyntax:metasyntax
747-
-> ?external_handler:External.t
748-
-> Language.Syntax.t
749-
-> (module Matcher.S)
750-
end
751-
end
752-
753-
(** {3 Alpha Matcher}
754-
755-
Alpha is the match engine that defines default matchers for languages.
756-
*)
757-
module Alpha : Engine.S
758-
759-
(** {3 Omega Matcher}
760-
761-
Alternative, partial, experimental match engine.
762-
*)
763-
module Omega : Engine.S
664+
(** {3 Matchers}
665+
666+
Default matchers for each supported language, plus helpers to construct
667+
matchers from a file extension or a custom language syntax. *)
668+
module Make (_ : Language.S) (_ : Metasyntax.S) (_ : External.S) : Matcher.S
669+
670+
(** {4 Supported Matchers} *)
671+
module Text : Matcher.S
672+
673+
module Paren : Matcher.S
674+
module Dyck : Matcher.S
675+
module JSON : Matcher.S
676+
module JSONC : Matcher.S
677+
module GraphQL : Matcher.S
678+
module Dhall : Matcher.S
679+
module Latex : Matcher.S
680+
module Assembly : Matcher.S
681+
module Clojure : Matcher.S
682+
module Lisp : Matcher.S
683+
module Generic : Matcher.S
684+
module Bash : Matcher.S
685+
module Ruby : Matcher.S
686+
module Elixir : Matcher.S
687+
module Python : Matcher.S
688+
module Html : Matcher.S
689+
module Xml : Matcher.S
690+
module SQL : Matcher.S
691+
module Erlang : Matcher.S
692+
module C : Matcher.S
693+
module Csharp : Matcher.S
694+
module Java : Matcher.S
695+
module CSS : Matcher.S
696+
module Kotlin : Matcher.S
697+
module Scala : Matcher.S
698+
module Nim : Matcher.S
699+
module Matlab : Matcher.S
700+
module Dart : Matcher.S
701+
module Php : Matcher.S
702+
module Go : Matcher.S
703+
module Javascript : Matcher.S
704+
module Jsx : Matcher.S
705+
module Typescript : Matcher.S
706+
module Tsx : Matcher.S
707+
module Swift : Matcher.S
708+
module Rust : Matcher.S
709+
module R : Matcher.S
710+
module OCaml : Matcher.S
711+
module Reason : Matcher.S
712+
module Fsharp : Matcher.S
713+
module Pascal : Matcher.S
714+
module Julia : Matcher.S
715+
module Fortran : Matcher.S
716+
module Haskell : Matcher.S
717+
module HCL : Matcher.S
718+
module Elm : Matcher.S
719+
module Zig : Matcher.S
720+
module Coq : Matcher.S
721+
module Move : Matcher.S
722+
module Solidity : Matcher.S
723+
module C_nested_comments : Matcher.S
724+
725+
(** [all] returns all default matchers. *)
726+
val all : (module Matcher.S) list
727+
728+
(** [select_with_extension metasyntax external file_extension] is a
729+
convenience function that returns a matcher associated with a
730+
[file_extension]. E.g., use ".c" to get the C matcher. For a full list
731+
of extensions associated with matchers, run comby -list. If
732+
[metasyntax] is specified, the matcher will use a custom metasyntax
733+
definition instead of the default. An experimental [external] callback
734+
is a general callback for handling external properties in the rewrite
735+
template. *)
736+
val select_with_extension
737+
: ?metasyntax:Metasyntax.t
738+
-> ?external_handler:External.t
739+
-> string
740+
-> (module Matcher.S) option
741+
742+
(** [create metasyntax external syntax] creates a matcher for a language
743+
defined by [syntax]. If [metasyntax] is specified, the matcher will use
744+
a custom metasyntax definition instead of the default. An experimental
745+
[external] callback is a general callback for handling external
746+
properties in the rewrite template. *)
747+
val create
748+
: ?metasyntax:metasyntax
749+
-> ?external_handler:External.t
750+
-> Language.Syntax.t
751+
-> (module Matcher.S)
764752

765753
(** {3 Rewrite}
766754

0 commit comments

Comments
 (0)