File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ module Re = Core
25
25
exception Parse_error
26
26
exception Not_supported
27
27
28
+ let by_code f c c' =
29
+ let c = Char. code c in
30
+ let c' = Char. code c' in
31
+ Char. chr (f c c')
32
+ ;;
33
+
28
34
let parse s =
29
35
let buf = Parse_buffer. create s in
30
36
let accept = Parse_buffer. accept buf in
@@ -105,6 +111,7 @@ let parse s =
105
111
then Re. char c :: Re. char '-' :: s
106
112
else (
107
113
let c' = char () in
114
+ let c' = by_code Int. max c c' in
108
115
bracket (Re. rg c c' :: s))
109
116
else bracket (Re. char c :: s))
110
117
and char () =
Original file line number Diff line number Diff line change @@ -198,7 +198,10 @@ let _ =
198
198
(* Character set *)
199
199
expect_pass " rg" (fun () ->
200
200
eq_match " [0-9]+" " 0123456789" ;
201
- eq_match " [0-9]+" " a" );
201
+ eq_match " [0-9]+" " a" ;
202
+ eq_match " [9-0]+" " 2" ;
203
+ eq_match " [5-5]" " 5" ;
204
+ eq_match " [5-4]" " 1" );
202
205
expect_pass " compl" (fun () ->
203
206
eq_match " [^0-9a-z]+" " A:Z+" ;
204
207
eq_match " [^0-9a-z]+" " 0" ;
You can’t perform that action at this time.
0 commit comments