Release coccinelle-0.2.3rc4
[bpt/coccinelle.git] / python / yes_pycocci_aux.ml
CommitLineData
9f8e26f4 1(*
90aeb998
C
2 * Copyright 2010, INRIA, University of Copenhagen
3 * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
4 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
5636bb2c
C
5 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
6 * This file is part of Coccinelle.
7 *
8 * Coccinelle is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, according to version 2 of the License.
11 *
12 * Coccinelle is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * The authors reserve the right to distribute this or future versions of
21 * Coccinelle under other licenses.
22 *)
23
24
34e49164
C
25open Ast_c
26open Common
27open Pycaml
28
34e49164
C
29let call_pretty f a =
30 let str = ref ([] : string list) in
31 let pr_elem info = str := (Ast_c.str_of_info info) :: !str in
32 let pr_sp _ = () in
978fd7e5 33 f ~pr_elem ~pr_space:pr_sp a;
34e49164
C
34 String.concat " " (List.rev !str)
35
0708f913
C
36let exprrep = call_pretty Pretty_print_c.pp_expression_gen
37
34e49164 38let stringrep mvb = match mvb with
5636bb2c 39 Ast_c.MetaIdVal (s,_) -> s
34e49164
C
40| Ast_c.MetaFuncVal s -> s
41| Ast_c.MetaLocalFuncVal s -> s
5636bb2c 42| Ast_c.MetaExprVal (expr,_) -> exprrep expr
34e49164
C
43| Ast_c.MetaExprListVal expr_list -> "TODO: <<exprlist>>"
44| Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ
0708f913
C
45| Ast_c.MetaInitVal ini -> call_pretty Pretty_print_c.pp_init_gen ini
46| Ast_c.MetaStmtVal statement ->
47 call_pretty Pretty_print_c.pp_statement_gen statement
48| Ast_c.MetaParamVal param ->
49 call_pretty Pretty_print_c.pp_param_gen param
34e49164
C
50| Ast_c.MetaParamListVal params -> "TODO: <<paramlist>>"
51| Ast_c.MetaListlenVal n -> string_of_int n
52| Ast_c.MetaPosVal (pos1, pos2) ->
53 let print_pos = function
54 Ast_cocci.Real x -> string_of_int x
55 | Ast_cocci.Virt(x,off) -> Printf.sprintf "%d+%d" x off in
56 Common.sprintf ("pos(%s,%s)") (print_pos pos1) (print_pos pos2)
57| Ast_c.MetaPosValList positions -> "TODO: <<postvallist>>"
58