Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions comby-kernel.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ depends: [
"dune" {>= "2.8.0"}
"ocaml" {>= "4.08.1"}
"core_kernel"
"mparser" {>= "1.3"}
"mparser-pcre"
"ppx_deriving"
"ppx_deriving_yojson" {>= "3.6.0"}
"yojson" {>= "1.6.0" < "2.0.0"}
Expand Down
7 changes: 3 additions & 4 deletions comby.opam
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@ depends: [
"comby-kernel" {= version}
"comby-semantic" {= version}
"core"
"cstruct-lwt"
"hack_parallel" {arch != "arm32" & arch != "arm64"}
"lwt"
"lwt_react"
"lwt_ssl"
"mparser" {>= "1.3"}
"mparser-pcre"
"parany" {>= "12.0.3"}
"patience_diff" {>= "v0.14" & < "v0.15"}
"ppx_deriving"
"ppx_deriving_yojson" {>= "3.6.0"}
"yojson" {>= "1.6.0" < "2.0.0"}
"pcre"
"shell"
"tar"
"tar-unix"
"tar" {< "3.0.0"}
"tar-unix" {< "3.0.0"}
"toml" {>= "6.0.0"}
"bisect_ppx" {with-test & dev & >= "2.5.0"}
]
Expand Down
538 changes: 0 additions & 538 deletions docs/third-party-licenses/ALL.txt

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions docs/third-party-licenses/pull-and-update-release-scripts.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

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"
LIBS="ppx_deriving_yojson core ppxlib ppx_deriving hack_parallel opium pcre-ocaml ocaml-tls camlzip bisect_ppx ocaml-ci-scripts patdiff lwt toml"

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

# LGPL
mkdir mparser && \
wget -P mparser https://raw.githubusercontent.com/comby-tools/mparser/master/LICENSE.txt

# ISC
mkdir ocaml-ci-scripts && \
wget -P ocaml-ci-scripts https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/LICENSE.md
Expand Down
34 changes: 11 additions & 23 deletions lib/app/configuration/command_configuration.ml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ type user_input_options =
; override_matcher : string option
; regex_pattern : bool
; ripgrep_args : string option
; omega : bool
}

type compute_mode =
Expand Down Expand Up @@ -628,24 +627,14 @@ let extension file_filters =
| _, Some extension -> "." ^ extension
| extension, None -> "." ^ extension)

let of_extension
(module Engine : Matchers.Engine.S)
(module External : Matchers.External.S)
file_filters
=
let of_extension (module External : Matchers.External.S) file_filters =
let external_handler = External.handler in
let extension = extension file_filters in
match Engine.select_with_extension extension ~external_handler with
match Matchers.select_with_extension extension ~external_handler with
| Some matcher -> matcher, Some extension, None
| None -> (module Engine.Generic), Some extension, None
| None -> (module Matchers.Generic), Some extension, None

let select_matcher custom_metasyntax custom_matcher override_matcher file_filters omega =
let (module Engine : Matchers.Engine.S) =
if omega then
(module Matchers.Omega)
else
(module Matchers.Alpha)
in
let select_matcher custom_metasyntax custom_matcher override_matcher file_filters =
let module External = struct
let handler = External_semantic.lsif_hover
end
Expand All @@ -656,15 +645,15 @@ let select_matcher custom_metasyntax custom_matcher override_matcher file_filter
(* custom matcher, optional custom metasyntax *)
let metasyntax = parse_metasyntax custom_metasyntax in
let syntax = syntax custom_matcher in
if debug then Format.printf "Engine.create@.";
Engine.create ~metasyntax syntax, None, Some metasyntax
if debug then Format.printf "Matchers.create@.";
Matchers.create ~metasyntax syntax, None, Some metasyntax
| _, Some language, custom_metasyntax ->
(* forced language, optional custom metasyntax *)
let metasyntax = parse_metasyntax custom_metasyntax in
let (module Metasyntax) = Matchers.Metasyntax.create metasyntax in
let (module Language) = force_language language in
if debug then Format.printf "Engine.Make@.";
( (module Engine.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
( (module Matchers.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
, None
, Some metasyntax )
| _, _, Some custom_metasyntax ->
Expand All @@ -673,13 +662,13 @@ let select_matcher custom_metasyntax custom_matcher override_matcher file_filter
let (module Metasyntax) = Matchers.Metasyntax.create metasyntax in
let (module Language) = force_language (extension file_filters) in
if debug then Format.printf "Engine.Make2@.";
( (module Engine.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
( (module Matchers.Make (Language) (Metasyntax) (External) : Matchers.Matcher.S)
, None
, Some metasyntax )
| _, _, None ->
(* infer language from file filters, use default metasyntax *)
if debug then Format.printf "Engine.Infer@.";
of_extension (module Engine) (module External) file_filters
if debug then Format.printf "Matchers.Infer@.";
of_extension (module External) file_filters

let regex_of_specifications specifications =
Format.sprintf "(%s)"
Expand Down Expand Up @@ -722,7 +711,6 @@ let create
; override_matcher
; regex_pattern
; ripgrep_args
; omega
}
; run_options
; output_options =
Expand Down Expand Up @@ -831,7 +819,7 @@ let create
Printer.Rewrite.print replacement_output source_path replacements result source_content
in
let ((module M) as matcher), _, metasyntax =
select_matcher custom_metasyntax custom_matcher override_matcher file_filters omega
select_matcher custom_metasyntax custom_matcher override_matcher file_filters
in
return
{ matcher
Expand Down
1 change: 0 additions & 1 deletion lib/app/configuration/command_configuration.mli
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type user_input_options =
; override_matcher : string option
; regex_pattern : bool
; ripgrep_args : string option
; omega : bool
}

type compute_mode =
Expand Down
1 change: 1 addition & 0 deletions lib/app/configuration/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
comby.patdiff
comby.camlzip
core
pcre
yojson
ppx_deriving_yojson
toml
Expand Down
1 change: 1 addition & 0 deletions lib/app/pipeline/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
comby.camlzip
core
core.uuid
cstruct-lwt
yojson
ppx_deriving_yojson
parany
Expand Down
4 changes: 1 addition & 3 deletions lib/kernel/comby_kernel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Replacement = Replacement
type replacement = Replacement.result

module Matchers = struct
module Engine = Matchers.Engine
module Language = Matchers.Language
module Matcher = Matchers.Matcher
module Configuration = Matchers.Configuration
Expand All @@ -20,11 +19,10 @@ module Matchers = struct
type metasyntax = Matchers.Metasyntax.t

module External = Matchers.External
module Alpha = Matchers.Alpha
module Omega = Matchers.Omega
module Languages = Matchers.Languages
module Template = Matchers.Template
module Ast = Matchers.Ast
include Matchers.Matcher_engine

module Rule = struct
include Matchers.Rule
Expand Down
188 changes: 88 additions & 100 deletions lib/kernel/comby_kernel.mli
Original file line number Diff line number Diff line change
Expand Up @@ -661,106 +661,94 @@ module Matchers : sig
val select_with_extension : string -> (module Language.S) option
end

module Engine : sig
module type S = sig
module Make (_ : Language.S) (_ : Metasyntax.S) (_ : External.S) : Matcher.S

(** {4 Supported Matchers} *)
module Text : Matcher.S

module Paren : Matcher.S
module Dyck : Matcher.S
module JSON : Matcher.S
module JSONC : Matcher.S
module GraphQL : Matcher.S
module Dhall : Matcher.S
module Latex : Matcher.S
module Assembly : Matcher.S
module Clojure : Matcher.S
module Lisp : Matcher.S
module Generic : Matcher.S
module Bash : Matcher.S
module Ruby : Matcher.S
module Elixir : Matcher.S
module Python : Matcher.S
module Html : Matcher.S
module Xml : Matcher.S
module SQL : Matcher.S
module Erlang : Matcher.S
module C : Matcher.S
module Csharp : Matcher.S
module Java : Matcher.S
module CSS : Matcher.S
module Kotlin : Matcher.S
module Scala : Matcher.S
module Nim : Matcher.S
module Matlab : Matcher.S
module Dart : Matcher.S
module Php : Matcher.S
module Go : Matcher.S
module Javascript : Matcher.S
module Jsx : Matcher.S
module Typescript : Matcher.S
module Tsx : Matcher.S
module Swift : Matcher.S
module Rust : Matcher.S
module R : Matcher.S
module OCaml : Matcher.S
module Reason : Matcher.S
module Fsharp : Matcher.S
module Pascal : Matcher.S
module Julia : Matcher.S
module Fortran : Matcher.S
module Haskell : Matcher.S
module HCL : Matcher.S
module Elm : Matcher.S
module Zig : Matcher.S
module Coq : Matcher.S
module Move : Matcher.S
module Solidity : Matcher.S
module C_nested_comments : Matcher.S

(** [all] returns all default matchers. *)
val all : (module Matcher.S) list

(** [select_with_extension metasyntax external file_extension] is a
convenience function that returns a matcher associated with a
[file_extension]. E.g., use ".c" to get the C matcher. For a full list
of extensions associated with matchers, run comby -list. If
[metasyntax] is specified, the matcher will use a custom metasyntax
definition instead of the default. An experimental [external] callback
is a general callback for handling external properties in the rewrite
template. *)
val select_with_extension
: ?metasyntax:Metasyntax.t
-> ?external_handler:External.t
-> string
-> (module Matcher.S) option

(** [create metasyntax external syntax] creates a matcher for a language
defined by [syntax]. If [metasyntax] is specified, the matcher will use
a custom metasyntax definition instead of the default. An experimental
[external] callback is a general callback for handling external
properties in the rewrite template. *)
val create
: ?metasyntax:metasyntax
-> ?external_handler:External.t
-> Language.Syntax.t
-> (module Matcher.S)
end
end

(** {3 Alpha Matcher}

Alpha is the match engine that defines default matchers for languages.
*)
module Alpha : Engine.S

(** {3 Omega Matcher}

Alternative, partial, experimental match engine.
*)
module Omega : Engine.S
(** {3 Matchers}

Default matchers for each supported language, plus helpers to construct
matchers from a file extension or a custom language syntax. *)
module Make (_ : Language.S) (_ : Metasyntax.S) (_ : External.S) : Matcher.S

(** {4 Supported Matchers} *)
module Text : Matcher.S

module Paren : Matcher.S
module Dyck : Matcher.S
module JSON : Matcher.S
module JSONC : Matcher.S
module GraphQL : Matcher.S
module Dhall : Matcher.S
module Latex : Matcher.S
module Assembly : Matcher.S
module Clojure : Matcher.S
module Lisp : Matcher.S
module Generic : Matcher.S
module Bash : Matcher.S
module Ruby : Matcher.S
module Elixir : Matcher.S
module Python : Matcher.S
module Html : Matcher.S
module Xml : Matcher.S
module SQL : Matcher.S
module Erlang : Matcher.S
module C : Matcher.S
module Csharp : Matcher.S
module Java : Matcher.S
module CSS : Matcher.S
module Kotlin : Matcher.S
module Scala : Matcher.S
module Nim : Matcher.S
module Matlab : Matcher.S
module Dart : Matcher.S
module Php : Matcher.S
module Go : Matcher.S
module Javascript : Matcher.S
module Jsx : Matcher.S
module Typescript : Matcher.S
module Tsx : Matcher.S
module Swift : Matcher.S
module Rust : Matcher.S
module R : Matcher.S
module OCaml : Matcher.S
module Reason : Matcher.S
module Fsharp : Matcher.S
module Pascal : Matcher.S
module Julia : Matcher.S
module Fortran : Matcher.S
module Haskell : Matcher.S
module HCL : Matcher.S
module Elm : Matcher.S
module Zig : Matcher.S
module Coq : Matcher.S
module Move : Matcher.S
module Solidity : Matcher.S
module C_nested_comments : Matcher.S

(** [all] returns all default matchers. *)
val all : (module Matcher.S) list

(** [select_with_extension metasyntax external file_extension] is a
convenience function that returns a matcher associated with a
[file_extension]. E.g., use ".c" to get the C matcher. For a full list
of extensions associated with matchers, run comby -list. If
[metasyntax] is specified, the matcher will use a custom metasyntax
definition instead of the default. An experimental [external] callback
is a general callback for handling external properties in the rewrite
template. *)
val select_with_extension
: ?metasyntax:Metasyntax.t
-> ?external_handler:External.t
-> string
-> (module Matcher.S) option

(** [create metasyntax external syntax] creates a matcher for a language
defined by [syntax]. If [metasyntax] is specified, the matcher will use
a custom metasyntax definition instead of the default. An experimental
[external] callback is a general callback for handling external
properties in the rewrite template. *)
val create
: ?metasyntax:metasyntax
-> ?external_handler:External.t
-> Language.Syntax.t
-> (module Matcher.S)

(** {3 Rewrite}

Expand Down
Loading