15
15
*)
16
16
17
17
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
20
20
21
21
open Ast_mapper
22
22
open Ast_helper
@@ -27,7 +27,7 @@ open Longident
27
27
let error ~loc msg = raise (Location. Error (Location. error ~loc msg))
28
28
29
29
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
31
31
let structure = {pstr_desc = Pstr_eval (e_msg, [] ); pstr_loc = loc} in
32
32
Exp. attr e ({txt = " ocaml.ppwarning" ; loc}, PStr [structure])
33
33
@@ -108,12 +108,12 @@ let transform_cases ~loc e cases =
108
108
if case.pc_guard <> None then
109
109
error ~loc " Guards are not implemented for match%pcre." else
110
110
(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 } ->
112
112
let re_str, bs, nG = extract_bindings ~loc re_src in
113
113
(try ignore (Re_pcre. regexp re_str) with
114
114
| Re_perl. Not_supported -> error ~loc " Unsupported regular expression."
115
115
| 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)
117
117
| {ppat_desc = Ppat_any } ->
118
118
error ~loc " Universal wildcard must be the last pattern."
119
119
| {ppat_loc = loc } ->
@@ -126,9 +126,9 @@ let transform_cases ~loc e cases =
126
126
| cases ->
127
127
let open Lexing in
128
128
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
132
132
let e = [% expr raise (Match_failure ([% e e0], [% e e1], [% e e2]))] in
133
133
(cases, warn ~loc " A universal case is recommended for %pcre." e))
134
134
in
@@ -148,7 +148,7 @@ let transform_cases ~loc e cases =
148
148
| [] -> rhs
149
149
| (varG , iG , mustG ) :: bs ->
150
150
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 ))]]
152
152
in
153
153
let eG =
154
154
if mustG then eG else
@@ -161,7 +161,7 @@ let transform_cases ~loc e cases =
161
161
let rec handle_cases i offG = function
162
162
| [] -> [% expr assert false ]
163
163
| (_ , nG , bs , rhs ) :: cases ->
164
- let e_i = Exp. constant (Const. int i) in
164
+ let e_i = Exp. constant (Const_int i) in
165
165
[% expr
166
166
if Re.Mark. test _g (snd [% e e_comp]).([% e e_i]) then
167
167
[% e wrap_groups rhs offG bs]
0 commit comments