Commit 9e57c99f authored by Stefan Berghofer's avatar Stefan Berghofer

Generalized version of syntax_arguments_typed

The type of syntax_arguments_typed is unnecessarily specific,
so that it is not applicable to patterns.
parent a5443911
...@@ -151,7 +151,7 @@ let get_type_arguments t = match t.t_node with ...@@ -151,7 +151,7 @@ let get_type_arguments t = match t.t_node with
| _ -> | _ ->
[||] [||]
let syntax_arguments_typed s print_arg print_type t fmt l = let gen_syntax_arguments_typed ty_of tys_of s print_arg print_type t fmt l =
let args = Array.of_list l in let args = Array.of_list l in
let repl_fun s fmt = let repl_fun s fmt =
let grp = (Str.matched_group 1 s) in let grp = (Str.matched_group 1 s) in
...@@ -159,17 +159,20 @@ let syntax_arguments_typed s print_arg print_type t fmt l = ...@@ -159,17 +159,20 @@ let syntax_arguments_typed s print_arg print_type t fmt l =
let grp = String.sub grp 1 (String.length grp - 1) in let grp = String.sub grp 1 (String.length grp - 1) in
let i = int_of_string grp in let i = int_of_string grp in
if i = 0 if i = 0
then print_type fmt (t_type t) then print_type fmt (ty_of t)
else print_type fmt (t_type args.(i-1)) else print_type fmt (ty_of args.(i-1))
else if grp.[0] = 'v' then else if grp.[0] = 'v' then
let grp = String.sub grp 1 (String.length grp - 1) in let grp = String.sub grp 1 (String.length grp - 1) in
let m = get_type_arguments t in let m = tys_of t in
print_type fmt m.(int_of_string grp) print_type fmt m.(int_of_string grp)
else else
let i = int_of_string grp in let i = int_of_string grp in
print_arg fmt args.(i-1) in print_arg fmt args.(i-1) in
global_substitute_fmt regexp_arg_pos_typed repl_fun s fmt global_substitute_fmt regexp_arg_pos_typed repl_fun s fmt
let syntax_arguments_typed =
gen_syntax_arguments_typed t_type get_type_arguments
(** {2 use printers} *) (** {2 use printers} *)
let print_prelude fmt pl = let print_prelude fmt pl =
......
...@@ -71,6 +71,9 @@ val syntax_arguments : string -> 'a pp -> 'a list pp ...@@ -71,6 +71,9 @@ val syntax_arguments : string -> 'a pp -> 'a list pp
(** (syntax_arguments templ print_arg fmt l) prints in the formatter fmt (** (syntax_arguments templ print_arg fmt l) prints in the formatter fmt
the list l using the template templ and the printer print_arg *) the list l using the template templ and the printer print_arg *)
val gen_syntax_arguments_typed :
('a -> 'b) -> ('a -> 'b array) -> string -> 'a pp -> 'b pp -> 'a -> 'a list pp
val syntax_arguments_typed : val syntax_arguments_typed :
string -> term pp -> ty pp -> term -> term list pp string -> term pp -> ty pp -> term -> term list pp
(** (syntax_arguments templ print_arg fmt l) prints in the formatter fmt (** (syntax_arguments templ print_arg fmt l) prints in the formatter fmt
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment