Release coccinelle-0.2.3rc1
[bpt/coccinelle.git] / python / no_pycocci_aux.ml
1 (*
2 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
5 *
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
9 *
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
20 *)
21
22
23 (*
24 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
25 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
26 * This file is part of Coccinelle.
27 *
28 * Coccinelle is free software: you can redistribute it and/or modify
29 * it under the terms of the GNU General Public License as published by
30 * the Free Software Foundation, according to version 2 of the License.
31 *
32 * Coccinelle is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License
38 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
39 *
40 * The authors reserve the right to distribute this or future versions of
41 * Coccinelle under other licenses.
42 *)
43
44
45 open Ast_c
46 open Common
47
48 let rec exprrep expr = match expr with
49 Ast_c.Ident (ident) -> Ast_c.str_of_name ident
50 | Ast_c.Constant c -> constantrep c
51 | Ast_c.FunCall (e,args) -> "TODO: FunCall"
52 | Ast_c.CondExpr (e1,e2,e3) -> "TODO: CondExpr"
53 | Ast_c.Sequence (e1,e2) -> "TODO: Sequence"
54 | Ast_c.Assignment (e1,op,e2) -> "TODO: Assignment"
55 | Ast_c.Postfix (e,op) -> "TODO: Postfix"
56 | Ast_c.Infix (e,op) -> "TODO: Infix"
57 | Ast_c.Unary (e,op) -> "TODO: Unary"
58 | Ast_c.Binary (e1,op,e2) -> "TODO: Binary"
59 | Ast_c.ArrayAccess (e1,e2) -> "TODO: ArrayAccess"
60 | Ast_c.RecordAccess (e1,s) -> "TODO: RecordAccess"
61 | Ast_c.RecordPtAccess (e,s) -> "TODO: RecordPtAccess"
62 | Ast_c.SizeOfExpr e -> "TODO: SizeOfExpr"
63 | Ast_c.SizeOfType t -> "TODO: SizeOfType"
64 | Ast_c.Cast (t,e) -> "TODO: Cast"
65 | Ast_c.StatementExpr c -> "TODO: StatementExpr"
66 | Ast_c.Constructor (t,i) -> "TODO: Constructor"
67 | Ast_c.ParenExpr e -> "TODO: ParenExpr"
68 and constantrep c = match c with
69 Ast_c.String (s,isWchar) -> s
70 | Ast_c.MultiString _ -> "TODO: MultiString"
71 | Ast_c.Char (s,isWchar) -> s
72 | Ast_c.Int (s, _t) -> s
73 | Ast_c.Float (s, _t) -> s
74
75 let call_pretty f a =
76 let str = ref ([] : string list) in
77 let pr_elem info = str := (Ast_c.str_of_info info) :: !str in
78 let pr_sp _ = () in
79 f ~pr_elem ~pr_space:pr_sp a;
80 String.concat " " (List.rev !str)
81
82 let stringrep mvb = match mvb with
83 Ast_c.MetaIdVal (s,_) -> s
84 | Ast_c.MetaFuncVal s -> s
85 | Ast_c.MetaLocalFuncVal s -> s
86 | Ast_c.MetaExprVal (((expr,_),[il]),_) -> (exprrep expr)
87 | Ast_c.MetaExprVal _ -> "TODO: <<MetaExprVal>>"
88 | Ast_c.MetaExprListVal expr_list -> "TODO: <<exprlist>>"
89 | Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ
90 | Ast_c.MetaStmtVal statement -> "TODO: stmt"
91 | Ast_c.MetaParamVal params -> "TODO: <<param>>"
92 | Ast_c.MetaParamListVal params -> "TODO: <<paramlist>>"
93 | Ast_c.MetaListlenVal n -> string_of_int n
94 | Ast_c.MetaPosVal (pos1, pos2) ->
95 (* Common.sprintf ("pos(%d,%d)") pos1 pos2 *)
96 "TODO: <<posval>>"
97 | Ast_c.MetaPosValList positions -> "TODO: <<postvallist>>"
98 | Ast_c.MetaInitVal _ -> "TODO: <<metainitval>>"
99