Skip to content

Commit 3a0a6fd

Browse files
committed
Backport to ocaml 4.02.3.
1 parent cab8f03 commit 3a0a6fd

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

jbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
(public_name ppx_regexp)
66
(kind ppx_rewriter)
77
(modules (ppx_regexp))
8-
(preprocess (pps (ppx_metaquot)))
8+
(flags (-ppx "ocamlfind ppx_tools/ppx_metaquot"))
99
(libraries (re re.pcre ocaml-migrate-parsetree))))
1010

1111
(executables

ppx_regexp.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*)
1616

1717
open Migrate_parsetree
18-
open Ast_404
19-
let ocaml_version = Versions.ocaml_404
18+
open Ast_402
19+
let ocaml_version = Versions.ocaml_402
2020

2121
open Ast_mapper
2222
open Ast_helper
@@ -27,7 +27,7 @@ open Longident
2727
let error ~loc msg = raise (Location.Error (Location.error ~loc msg))
2828

2929
let warn ~loc msg e =
30-
let e_msg = Exp.constant (Const.string msg) in
30+
let e_msg = Exp.constant (Const_string (msg, None)) in
3131
let structure = {pstr_desc = Pstr_eval (e_msg, []); pstr_loc = loc} in
3232
Exp.attr e ({txt = "ocaml.ppwarning"; loc}, PStr [structure])
3333

@@ -108,12 +108,12 @@ let transform_cases ~loc e cases =
108108
if case.pc_guard <> None then
109109
error ~loc "Guards are not implemented for match%pcre." else
110110
(match case.pc_lhs with
111-
| {ppat_desc = Ppat_constant (Pconst_string (re_src,_)); ppat_loc = loc} ->
111+
| {ppat_desc = Ppat_constant (Const_string (re_src,_)); ppat_loc = loc} ->
112112
let re_str, bs, nG = extract_bindings ~loc re_src in
113113
(try ignore (Re_pcre.regexp re_str) with
114114
| Re_perl.Not_supported -> error ~loc "Unsupported regular expression."
115115
| Re_perl.Parse_error -> error ~loc "Invalid regular expression.");
116-
(Exp.constant (Const.string re_str), nG, bs, case.pc_rhs)
116+
(Exp.constant (Const_string (re_str, None)), nG, bs, case.pc_rhs)
117117
| {ppat_desc = Ppat_any} ->
118118
error ~loc "Universal wildcard must be the last pattern."
119119
| {ppat_loc = loc} ->
@@ -126,9 +126,9 @@ let transform_cases ~loc e cases =
126126
| cases ->
127127
let open Lexing in
128128
let pos = loc.Location.loc_start in
129-
let e0 = Exp.constant (Const.string pos.pos_fname) in
130-
let e1 = Exp.constant (Const.int pos.pos_lnum) in
131-
let e2 = Exp.constant (Const.int (pos.pos_cnum - pos.pos_bol)) in
129+
let e0 = Exp.constant (Const_string (pos.pos_fname, None)) in
130+
let e1 = Exp.constant (Const_int pos.pos_lnum) in
131+
let e2 = Exp.constant (Const_int (pos.pos_cnum - pos.pos_bol)) in
132132
let e = [%expr raise (Match_failure ([%e e0], [%e e1], [%e e2]))] in
133133
(cases, warn ~loc "A universal case is recommended for %pcre." e))
134134
in
@@ -148,7 +148,7 @@ let transform_cases ~loc e cases =
148148
| [] -> rhs
149149
| (varG, iG, mustG) :: bs ->
150150
let eG =
151-
[%expr Re.Group.get _g [%e Exp.constant (Const.int (offG + iG + 1))]]
151+
[%expr Re.Group.get _g [%e Exp.constant (Const_int (offG + iG + 1))]]
152152
in
153153
let eG =
154154
if mustG then eG else
@@ -161,7 +161,7 @@ let transform_cases ~loc e cases =
161161
let rec handle_cases i offG = function
162162
| [] -> [%expr assert false]
163163
| (_, nG, bs, rhs) :: cases ->
164-
let e_i = Exp.constant (Const.int i) in
164+
let e_i = Exp.constant (Const_int i) in
165165
[%expr
166166
if Re.Mark.test _g (snd [%e e_comp]).([%e e_i]) then
167167
[%e wrap_groups rhs offG bs]

ppx_regexp.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ depends: [
1010
"jbuilder" {build}
1111
"ocaml-migrate-parsetree"
1212
"re"
13-
"ppx_metaquot" {build}
13+
"ppx_tools" {build}
1414
"topkg-jbuilder" {build}
1515
]
16-
available: [ocaml-version >= "4.03.0"]
16+
available: [ocaml-version >= "4.02.3" & opam-version < "4.03.0"]

0 commit comments

Comments
 (0)