2 * Copyright 2012, INRIA
3 * Julia Lawall, Gilles Muller
4 * Copyright 2010-2011, INRIA, University of Copenhagen
5 * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
6 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
7 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
8 * This file is part of Coccinelle.
10 * Coccinelle is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, according to version 2 of the License.
14 * Coccinelle is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
22 * The authors reserve the right to distribute this or future versions of
23 * Coccinelle under other licenses.
31 let str = ref ([] : string list
) in
32 let pr_elem info
= str := (Ast_c.str_of_info info
) :: !str in
34 f ~
pr_elem ~pr_space
:pr_sp a
;
35 String.concat
" " (List.rev
!str)
37 let exprrep = call_pretty Pretty_print_c.pp_expression_gen
39 let commalistrep list_printer elem_printer comma_printer x
=
40 (call_pretty list_printer x
,
43 call_pretty elem_printer
(comma_printer x
) (* drop commas *))
47 commalistrep Pretty_print_c.pp_arg_list_gen
Pretty_print_c.pp_arg_gen
51 commalistrep Pretty_print_c.pp_param_list_gen
Pretty_print_c.pp_param_gen
55 commalistrep Pretty_print_c.pp_init_list_gen
Pretty_print_c.pp_init_gen
59 commalistrep Pretty_print_c.pp_field_list_gen
Pretty_print_c.pp_field_gen
62 let stringrep = function
63 Ast_c.MetaIdVal
(s
,_
) -> s
64 | Ast_c.MetaFuncVal s
-> s
65 | Ast_c.MetaLocalFuncVal s
-> s
66 | Ast_c.MetaExprVal
(expr
,_
) -> exprrep expr
67 | Ast_c.MetaExprListVal expr_list
->
68 call_pretty Pretty_print_c.pp_arg_list_gen expr_list
69 | Ast_c.MetaTypeVal typ
-> call_pretty Pretty_print_c.pp_type_gen typ
70 | Ast_c.MetaInitVal ini
-> call_pretty Pretty_print_c.pp_init_gen ini
71 | Ast_c.MetaInitListVal ini
-> call_pretty Pretty_print_c.pp_init_list_gen ini
72 | Ast_c.MetaDeclVal decl
->
73 call_pretty Pretty_print_c.pp_decl_gen decl
74 | Ast_c.MetaFieldVal field
->
75 call_pretty Pretty_print_c.pp_field_gen field
76 | Ast_c.MetaFieldListVal field
->
77 call_pretty Pretty_print_c.pp_field_list_gen field
78 | Ast_c.MetaStmtVal statement
->
79 call_pretty Pretty_print_c.pp_statement_gen statement
80 | Ast_c.MetaParamVal param
->
81 call_pretty Pretty_print_c.pp_param_gen param
82 | Ast_c.MetaParamListVal params
->
83 call_pretty Pretty_print_c.pp_param_list_gen params
84 | Ast_c.MetaListlenVal n
-> string_of_int n
85 | Ast_c.MetaPosVal
(pos1
, pos2
) ->
86 let print_pos = function
87 Ast_cocci.Real x
-> string_of_int x
88 | Ast_cocci.Virt
(x
,off
) -> Printf.sprintf
"%d+%d" x off
in
89 Common.sprintf
("pos(%s,%s)") (print_pos pos1
) (print_pos pos2
)
90 | Ast_c.MetaPosValList positions
-> "TODO: <<postvallist>>"