@@ -31,17 +31,17 @@ module Regexp = struct
31
31
let to_string ~ctx =
32
32
let p_alt, p_seq, p_suffix, p_atom = 0 , 1 , 2 , 3 in
33
33
let delimit_if b s = if b then " (?:" ^ s ^ " )" else s in
34
+ let get_parsed ~loc idr =
35
+ let var_name = idr.txt in
36
+ let content =
37
+ match Util.Ctx. find var_name ctx with
38
+ | Some value -> value
39
+ | None -> Util. error ~loc " Variable '%s' not found. %%pcre and %%mik only support global let bindings for substitution." var_name
40
+ in
41
+ content
42
+ in
34
43
let rec recurse p (e' : _ Location.loc ) =
35
44
let loc = e'.Location. loc in
36
- let get_parsed idr =
37
- let var_name = idr.txt in
38
- let content =
39
- match Util.Ctx. find var_name ctx with
40
- | Some value -> value
41
- | None -> Util. error ~loc " Variable '%s' not found. %%pcre and %%mik only support global let bindings for substitution." var_name
42
- in
43
- content
44
- in
45
45
match e'.Location. txt with
46
46
| Code s ->
47
47
(* Delimiters not needed as Regexp.parse_exn only returns single
@@ -60,10 +60,10 @@ module Regexp = struct
60
60
| Capture _ -> Util. error ~loc " Unnamed capture is not allowed for %%pcre and %%mik."
61
61
| Capture_as (_ , _ , e ) -> " (" ^ recurse p_alt e ^ " )"
62
62
| Named_subs (idr , _ , _ , _ ) ->
63
- let content = get_parsed idr in
63
+ let content = get_parsed ~loc idr in
64
64
" (" ^ recurse p_alt content ^ " )"
65
65
| Unnamed_subs (idr , _ ) ->
66
- let content = get_parsed idr in
66
+ let content = get_parsed ~loc idr in
67
67
recurse p_atom content
68
68
| Pipe_all (_ , _ , e ) -> recurse p_alt e
69
69
| Call _ -> Util. error ~loc " (&...) is not implemented for %%pcre and %%mik."
0 commit comments