Commit | Line | Data |
---|---|---|
174d1640 C |
1 | (* sams as for python; perhaps this could be put somewhere else *) |
2 | ||
3 | open Ast_c | |
4 | open Common | |
5 | ||
6 | let call_pretty f a = | |
7 | let str = ref ([] : string list) in | |
8 | let pr_elem info = str := (Ast_c.str_of_info info) :: !str in | |
9 | let pr_sp _ = () in | |
10 | f ~pr_elem ~pr_space:pr_sp a; | |
11 | String.concat " " (List.rev !str) | |
12 | ||
13 | let exprrep = call_pretty Pretty_print_c.pp_expression_gen | |
14 | ||
15 | let stringrep = function | |
16 | Ast_c.MetaIdVal (s,_) -> s | |
17 | | Ast_c.MetaFuncVal s -> s | |
18 | | Ast_c.MetaLocalFuncVal s -> s | |
19 | | Ast_c.MetaExprVal (expr,_) -> exprrep expr | |
413ffc02 C |
20 | | Ast_c.MetaExprListVal expr_list -> |
21 | call_pretty Pretty_print_c.pp_arg_list_gen expr_list | |
174d1640 C |
22 | | Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ |
23 | | Ast_c.MetaInitVal ini -> call_pretty Pretty_print_c.pp_init_gen ini | |
413ffc02 C |
24 | | Ast_c.MetaDeclVal declaration -> |
25 | call_pretty Pretty_print_c.pp_decl_gen declaration | |
26 | | Ast_c.MetaFieldVal field -> | |
27 | call_pretty Pretty_print_c.pp_field_gen field | |
190f1acf C |
28 | | Ast_c.MetaFieldListVal field -> |
29 | call_pretty Pretty_print_c.pp_field_list_gen field | |
174d1640 C |
30 | | Ast_c.MetaStmtVal statement -> |
31 | call_pretty Pretty_print_c.pp_statement_gen statement | |
32 | | Ast_c.MetaParamVal param -> | |
33 | call_pretty Pretty_print_c.pp_param_gen param | |
413ffc02 C |
34 | | Ast_c.MetaParamListVal params -> |
35 | call_pretty Pretty_print_c.pp_param_list_gen params | |
174d1640 C |
36 | | Ast_c.MetaListlenVal n -> string_of_int n |
37 | | Ast_c.MetaPosVal (pos1, pos2) -> | |
38 | let print_pos = function | |
39 | Ast_cocci.Real x -> string_of_int x | |
40 | | Ast_cocci.Virt(x,off) -> Printf.sprintf "%d+%d" x off in | |
41 | Common.sprintf ("pos(%s,%s)") (print_pos pos1) (print_pos pos2) | |
42 | | Ast_c.MetaPosValList positions -> "TODO: <<postvallist>>" | |
43 |