mirror of
https://github.com/comby-tools/comby.git
synced 2024-10-26 13:19:23 +03:00
Use Yojson.Safe.t
for compatibility with Yojson 2 (#342)
This commit is contained in:
parent
1014a038d1
commit
1871a4b116
@ -25,6 +25,7 @@ depends: [
|
|||||||
"mparser-pcre"
|
"mparser-pcre"
|
||||||
"ppx_deriving"
|
"ppx_deriving"
|
||||||
"ppx_deriving_yojson" {>= "3.6.0"}
|
"ppx_deriving_yojson" {>= "3.6.0"}
|
||||||
|
"yojson" {>= "1.6.0"}
|
||||||
"pcre"
|
"pcre"
|
||||||
# vendored dependencies
|
# vendored dependencies
|
||||||
"bigstringaf"
|
"bigstringaf"
|
||||||
|
@ -41,6 +41,7 @@ depends: [
|
|||||||
"patience_diff" {>= "v0.14" & < "v0.15"}
|
"patience_diff" {>= "v0.14" & < "v0.15"}
|
||||||
"ppx_deriving"
|
"ppx_deriving"
|
||||||
"ppx_deriving_yojson" {>= "3.6.0"}
|
"ppx_deriving_yojson" {>= "3.6.0"}
|
||||||
|
"yojson" {>= "1.6.0"}
|
||||||
"pcre"
|
"pcre"
|
||||||
"shell"
|
"shell"
|
||||||
"tar"
|
"tar"
|
||||||
|
@ -17,8 +17,8 @@ module Match : sig
|
|||||||
}
|
}
|
||||||
[@@deriving eq, sexp]
|
[@@deriving eq, sexp]
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
val default : t
|
val default : t
|
||||||
end
|
end
|
||||||
@ -33,8 +33,8 @@ module Match : sig
|
|||||||
}
|
}
|
||||||
[@@deriving eq, sexp]
|
[@@deriving eq, sexp]
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
val default : t
|
val default : t
|
||||||
end
|
end
|
||||||
@ -49,8 +49,8 @@ module Match : sig
|
|||||||
type t
|
type t
|
||||||
[@@deriving eq]
|
[@@deriving eq]
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
(** [create] creates a new, empty environment *)
|
(** [create] creates a new, empty environment *)
|
||||||
val create : unit -> t
|
val create : unit -> t
|
||||||
@ -100,8 +100,8 @@ module Match : sig
|
|||||||
; matched : string
|
; matched : string
|
||||||
}
|
}
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
(** [create] creates a new match with empty range by default. *)
|
(** [create] creates a new match with empty range by default. *)
|
||||||
val create : ?range:range -> unit -> t
|
val create : ?range:range -> unit -> t
|
||||||
@ -137,8 +137,8 @@ module Replacement : sig
|
|||||||
; environment : Match.environment
|
; environment : Match.environment
|
||||||
}
|
}
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
val to_json
|
val to_json
|
||||||
: ?path:string
|
: ?path:string
|
||||||
@ -146,7 +146,7 @@ module Replacement : sig
|
|||||||
-> ?rewritten_source:string
|
-> ?rewritten_source:string
|
||||||
-> diff:string
|
-> diff:string
|
||||||
-> unit
|
-> unit
|
||||||
-> Yojson.Safe.json
|
-> Yojson.Safe.t
|
||||||
|
|
||||||
(** A replacement result is the rewritten source, and the replacement
|
(** A replacement result is the rewritten source, and the replacement
|
||||||
fragments. *)
|
fragments. *)
|
||||||
@ -155,7 +155,7 @@ module Replacement : sig
|
|||||||
; in_place_substitutions : t list
|
; in_place_substitutions : t list
|
||||||
}
|
}
|
||||||
|
|
||||||
val result_to_yojson : result -> Yojson.Safe.json
|
val result_to_yojson : result -> Yojson.Safe.t
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -296,8 +296,8 @@ module Matchers : sig
|
|||||||
; aliases : alias list
|
; aliases : alias list
|
||||||
}
|
}
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
(** A module signature for metasyntax to parameterize a matcher *)
|
(** A module signature for metasyntax to parameterize a matcher *)
|
||||||
module type S = sig
|
module type S = sig
|
||||||
@ -584,8 +584,8 @@ module Matchers : sig
|
|||||||
; comments : comment_kind list
|
; comments : comment_kind list
|
||||||
}
|
}
|
||||||
|
|
||||||
val to_yojson : t -> Yojson.Safe.json
|
val to_yojson : t -> Yojson.Safe.t
|
||||||
val of_yojson : Yojson.Safe.json -> (t, string) Result.t
|
val of_yojson : Yojson.Safe.t -> (t, string) Result.t
|
||||||
|
|
||||||
(** The module signature that defines language syntax for a matcher *)
|
(** The module signature that defines language syntax for a matcher *)
|
||||||
module type S = sig
|
module type S = sig
|
||||||
|
@ -7,4 +7,5 @@
|
|||||||
core_kernel
|
core_kernel
|
||||||
comby-kernel.match
|
comby-kernel.match
|
||||||
comby-kernel.matchers
|
comby-kernel.matchers
|
||||||
comby-kernel.replacement))
|
comby-kernel.replacement
|
||||||
|
yojson))
|
||||||
|
@ -67,7 +67,7 @@ let copy env =
|
|||||||
let exists env key =
|
let exists env key =
|
||||||
Option.is_some (lookup env key)
|
Option.is_some (lookup env key)
|
||||||
|
|
||||||
let to_yojson env : Yojson.Safe.json =
|
let to_yojson env : Yojson.Safe.t =
|
||||||
let s =
|
let s =
|
||||||
Map.fold_right env ~init:[] ~f:(fun ~key:variable ~data:{value; range} acc ->
|
Map.fold_right env ~init:[] ~f:(fun ~key:variable ~data:{value; range} acc ->
|
||||||
let item =
|
let item =
|
||||||
@ -81,7 +81,7 @@ let to_yojson env : Yojson.Safe.json =
|
|||||||
in
|
in
|
||||||
`List s
|
`List s
|
||||||
|
|
||||||
let of_yojson (json : Yojson.Safe.json) =
|
let of_yojson (json : Yojson.Safe.t) =
|
||||||
let open Yojson.Safe.Util in
|
let open Yojson.Safe.Util in
|
||||||
let env = create () in
|
let env = create () in
|
||||||
match json with
|
match json with
|
||||||
|
@ -19,6 +19,6 @@ val to_json
|
|||||||
-> ?rewritten_source:string
|
-> ?rewritten_source:string
|
||||||
-> diff:string
|
-> diff:string
|
||||||
-> unit
|
-> unit
|
||||||
-> Yojson.Safe.json
|
-> Yojson.Safe.t
|
||||||
|
|
||||||
val empty_result : result
|
val empty_result : result
|
||||||
|
Loading…
Reference in New Issue
Block a user