@@ -133,7 +133,6 @@ let rec create_opts ~loc = function
133
133
| [] -> [% expr []]
134
134
| `Caseless :: xs -> [% expr `Caseless :: [% e create_opts ~loc xs]]
135
135
| `Anchored :: xs -> [% expr `Anchored :: [% e create_opts ~loc xs]]
136
- | `Dollar_endonly :: xs -> [% expr `Dollar_endonly :: [% e create_opts ~loc xs]]
137
136
138
137
let extract_bindings ~(parser : ?pos:position -> string -> string Regexp_types.t ) ~ctx ~pos s =
139
138
let r = parser ~pos s in
@@ -328,29 +327,17 @@ let transform_mixed_match ~loc ~ctx ?matched_expr cases acc =
328
327
(* anchored *)
329
328
PStr [ { pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string (pat, str_loc, _)); _ }, _); _ } ] ) ->
330
329
let pos = str_loc.loc_start in
331
- let mode = if String. starts_with ~prefix: " pcre" ext then `Pcre else `Mik in
332
- let opts =
333
- if String. ends_with ~suffix: " _i" ext then `Caseless :: `Anchored :: Util. default_opts else `Anchored :: Util. default_opts
334
- in
335
- let parser = match mode with `Pcre -> Regexp. parse_exn ~target: `Match | `Mik -> Regexp. parse_mik_exn ~target: `Match in
336
- let re, bs, nG = extract_bindings ~parser ~pos ~ctx pat in
337
- `Mik (opts, re, nG, bs, case.pc_rhs, case.pc_guard)
338
- | Ppat_extension
339
- ( { txt = (" pcres" | " miksearch" | " pcres_i" | " miksearch_i" ) as ext; _ },
340
- (* search, non anchored *)
341
- PStr [ { pstr_desc = Pstr_eval ({ pexp_desc = Pexp_constant (Pconst_string (pat, str_loc, _)); _ }, _); _ } ] ) ->
342
- let pos = str_loc.loc_start in
343
- let mode = if String. starts_with ~prefix: " pcre" ext then `Pcre else `Mik in
344
- let opts = if String. ends_with ~suffix: " _i" ext then `Caseless :: Util. default_opts else Util. default_opts in
330
+ let mode, opts = if String. starts_with ~prefix: " pcre" ext then `Pcre , [] else `Mik , Util. mikmatch_default_opts in
331
+ let opts = if String. ends_with ~suffix: " _i" ext then `Caseless :: opts else opts in
345
332
let parser = match mode with `Pcre -> Regexp. parse_exn ~target: `Match | `Mik -> Regexp. parse_mik_exn ~target: `Match in
346
333
let re, bs, nG = extract_bindings ~parser ~pos ~ctx pat in
347
- `Mik (opts, re, nG, bs, case.pc_rhs, case.pc_guard)
334
+ `Ext (opts, re, nG, bs, case.pc_rhs, case.pc_guard)
348
335
| _ -> `Regular case
349
336
in
350
337
351
338
let prepared_cases = List. map aux cases in
352
339
353
- let has_mik = List. exists (function `Mik _ -> true | _ -> false ) prepared_cases in
340
+ let has_mik = List. exists (function `Ext _ -> true | _ -> false ) prepared_cases in
354
341
355
342
if not has_mik then begin
356
343
match matched_expr with None -> pexp_function ~loc cases, acc | Some m -> pexp_match ~loc m cases, acc
@@ -361,7 +348,7 @@ let transform_mixed_match ~loc ~ctx ?matched_expr cases acc =
361
348
begin
362
349
fun i case ->
363
350
match case with
364
- | `Mik (opts , re , _ , _ , _ , _ ) ->
351
+ | `Ext (opts , re , _ , _ , _ , _ ) ->
365
352
let comp_var = Util. fresh_var () in
366
353
let opts_expr = create_opts ~loc opts in
367
354
let comp_expr = [% expr Re. compile (Re.Perl. re ~opts: [% e opts_expr] [% e re])] in
@@ -385,7 +372,7 @@ let transform_mixed_match ~loc ~ctx ?matched_expr cases acc =
385
372
match [% e input_var] with
386
373
| [% p case.pc_lhs] when [% e Option. value case.pc_guard ~default: [% expr true ]] -> [% e case.pc_rhs]
387
374
| _ -> [% e build_ordered_match input_var (case_idx + 1 ) rest mik_comps]]
388
- | `Mik (_ , _ , _ , bs , rhs , guard ) :: rest , (idx , comp_var , _ ) :: rest_comps when idx = case_idx ->
375
+ | `Ext (_ , _ , _ , bs , rhs , guard ) :: rest , (idx , comp_var , _ ) :: rest_comps when idx = case_idx ->
389
376
let comp_ident = pexp_ident ~loc { txt = Lident comp_var; loc } in
390
377
[% expr
391
378
match Re. exec_opt [% e comp_ident] [% e input_var] with
@@ -398,7 +385,7 @@ let transform_mixed_match ~loc ~ctx ?matched_expr cases acc =
398
385
let guarded_rhs = [% expr if [% e g] then [% e rhs] else [% e build_ordered_match input_var (case_idx + 1 ) rest rest_comps]] in
399
386
wrap_group_bindings ~captured_acc: [] ~loc guarded_rhs 0 bs]
400
387
| None -> [% e build_ordered_match input_var (case_idx + 1 ) rest rest_comps]]
401
- | `Mik _ :: rest , _ ->
388
+ | `Ext _ :: rest , _ ->
402
389
(* shouldn't happen if indices are correct *)
403
390
build_ordered_match input_var (case_idx + 1 ) rest mik_comps
404
391
in
0 commit comments