File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,11 @@ module Regexp = struct
93
93
| Capture_as (_ , e ) -> " (" ^ recurse p_alt e ^ " )"
94
94
| Call _ -> error ~loc " (&...) is not implemented for %pcre." )
95
95
in
96
- recurse 0
96
+ (function
97
+ | {Location. txt = Capture_as (_ , e ); _} ->
98
+ recurse 0 e
99
+ | e ->
100
+ recurse 0 e)
97
101
end
98
102
99
103
let dyn_bindings = ref []
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ let test3 s =
61
61
| {|m(o+)re re(gular)? no(is)e, (no )*be(t+)?er|} -> ()
62
62
| s' -> assert (s = s'))
63
63
64
+ let test4 = function% pcre (* Issue 8 *)
65
+ | {|(?<x>[-+]?[[:digit:]]+.[[:digit:]]*)|} -> [x]
66
+ | {|(?<x>(abc))[[:space:]]*(?<y>(xyz))|} -> [x; y]
67
+ | _ -> assert false
68
+
64
69
let () =
65
70
test2 " <>" ;
66
71
test2 " <a>" ;
@@ -74,7 +79,9 @@ let () =
74
79
test2 " one" ;
75
80
test2 " two" ;
76
81
test3 " - + + -" ;
77
- test3 " catch-all"
82
+ test3 " catch-all" ;
83
+ assert (test4 " ::123.456::" = [" 123.456" ]);
84
+ assert (test4 " ::abc xyz::" = [" abc" ; " xyz" ])
78
85
79
86
(* It should work in a functor, and Re_pcre.regxp should be lifted to the
80
87
* top-level. *)
You can’t perform that action at this time.
0 commit comments