Commit | Line | Data |
---|---|---|
34e49164 C |
1 | open Ast_c |
2 | open Common | |
3 | open Pycaml | |
4 | ||
34e49164 C |
5 | let call_pretty f a = |
6 | let str = ref ([] : string list) in | |
7 | let pr_elem info = str := (Ast_c.str_of_info info) :: !str in | |
8 | let pr_sp _ = () in | |
978fd7e5 | 9 | f ~pr_elem ~pr_space:pr_sp a; |
34e49164 C |
10 | String.concat " " (List.rev !str) |
11 | ||
0708f913 C |
12 | let exprrep = call_pretty Pretty_print_c.pp_expression_gen |
13 | ||
34e49164 C |
14 | let stringrep mvb = match mvb with |
15 | Ast_c.MetaIdVal s -> s | |
16 | | Ast_c.MetaFuncVal s -> s | |
17 | | Ast_c.MetaLocalFuncVal s -> s | |
0708f913 | 18 | | Ast_c.MetaExprVal expr -> exprrep expr |
34e49164 C |
19 | | Ast_c.MetaExprListVal expr_list -> "TODO: <<exprlist>>" |
20 | | Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ | |
0708f913 C |
21 | | Ast_c.MetaInitVal ini -> call_pretty Pretty_print_c.pp_init_gen ini |
22 | | Ast_c.MetaStmtVal statement -> | |
23 | call_pretty Pretty_print_c.pp_statement_gen statement | |
24 | | Ast_c.MetaParamVal param -> | |
25 | call_pretty Pretty_print_c.pp_param_gen param | |
34e49164 C |
26 | | Ast_c.MetaParamListVal params -> "TODO: <<paramlist>>" |
27 | | Ast_c.MetaListlenVal n -> string_of_int n | |
28 | | Ast_c.MetaPosVal (pos1, pos2) -> | |
29 | let print_pos = function | |
30 | Ast_cocci.Real x -> string_of_int x | |
31 | | Ast_cocci.Virt(x,off) -> Printf.sprintf "%d+%d" x off in | |
32 | Common.sprintf ("pos(%s,%s)") (print_pos pos1) (print_pos pos2) | |
33 | | Ast_c.MetaPosValList positions -> "TODO: <<postvallist>>" | |
34 |