X-Git-Url: https://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/9f8e26f459677a621822918b7539ae94214621ac..9bc82bae75129fec4d981ebf245f2f7d7ca73a41:/engine/pretty_print_engine.ml diff --git a/engine/pretty_print_engine.ml b/engine/pretty_print_engine.ml index 5c1e1d0..f44b961 100644 --- a/engine/pretty_print_engine.ml +++ b/engine/pretty_print_engine.ml @@ -1,4 +1,30 @@ (* + * Copyright 2010, INRIA, University of Copenhagen + * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix + * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen + * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix + * This file is part of Coccinelle. + * + * Coccinelle is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, according to version 2 of the License. + * + * Coccinelle is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Coccinelle. If not, see . + * + * The authors reserve the right to distribute this or future versions of + * Coccinelle under other licenses. + *) + + +(* + * Copyright 2010, INRIA, University of Copenhagen + * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix * This file is part of Coccinelle. @@ -25,21 +51,25 @@ open Common.Infix open Lib_engine -let pp = Common.pp +let pp = Common.pp let pp_meta (_,x) = pp x let rec pp_binding_kind = function - | Ast_c.MetaIdVal s -> pp ("id " ^ s) + | Ast_c.MetaIdVal (s,_) -> pp ("id " ^ s) | Ast_c.MetaFuncVal s -> pp ("func " ^ s) | Ast_c.MetaLocalFuncVal s -> pp ("localfunc " ^ s) - | Ast_c.MetaExprVal expr -> Pretty_print_c.pp_expression_simple expr + | Ast_c.MetaExprVal (expr,_) -> Pretty_print_c.pp_expression_simple expr | Ast_c.MetaExprListVal expr_list -> pp "<>" - | Ast_c.MetaInitVal ini -> + | Ast_c.MetaInitVal ini -> Pretty_print_c.pp_init_simple ini - | Ast_c.MetaTypeVal typ -> + | Ast_c.MetaTypeVal typ -> Pretty_print_c.pp_type_simple typ - | Ast_c.MetaStmtVal statement -> + | Ast_c.MetaDeclVal decl -> + Pretty_print_c.pp_decl_simple decl + | Ast_c.MetaFieldVal decl -> + Pretty_print_c.pp_field_simple decl + | Ast_c.MetaStmtVal statement -> Pretty_print_c.pp_statement_simple statement | Ast_c.MetaParamVal params -> pp "<>" | Ast_c.MetaParamListVal params -> pp "<>" @@ -49,7 +79,7 @@ let rec pp_binding_kind = function Ast_cocci.Real x -> string_of_int x | Ast_cocci.Virt(x,off) -> Printf.sprintf "%d+%d" x off in pp (Common.sprintf ("pos(%s,%s)") (print_pos pos1) (print_pos pos2)) - | Ast_c.MetaPosValList l -> + | Ast_c.MetaPosValList l -> pp (Common.sprintf ("poss[%s]") (String.concat ", " (List.map @@ -58,11 +88,12 @@ let rec pp_binding_kind = function fl ce minl minc maxl maxc) l))) -and pp_binding subst = +and pp_binding subst = begin pp "["; - Common.print_between (fun () -> pp ";"; Format.print_cut() ) - (fun ((_,s), kind) -> pp s; pp " --> "; pp_binding_kind kind) + Common.print_between (fun () -> pp ";"; Format.print_cut() ) + (fun ((r,s), kind) -> + pp r; pp "."; pp s; pp " --> "; pp_binding_kind kind) subst; pp "]"; end @@ -71,14 +102,14 @@ and pp_binding subst = let pp_binding_kind2 = function | ParenVal s -> pp "pv("; pp_meta s; pp ")" | NormalMetaVal x -> pp_binding_kind x - | LabelVal (Absolute xs) -> + | LabelVal (Absolute xs) -> begin pp "labelval"; pp "("; Common.print_between (fun () -> pp ",") Format.print_int xs; pp ")"; end - | LabelVal (Prefix xs) -> + | LabelVal (Prefix xs) -> begin pp "prefixlabelval"; pp "("; @@ -88,8 +119,8 @@ let pp_binding_kind2 = function | GoodVal -> pp "goodval" | BadVal -> pp "badval" - -let rec pp_predicate = function + +let rec pp_predicate = function | InLoop -> pp "InLoop" | TrueBranch -> pp "TrueBranch" | FalseBranch -> pp "FalseBranch" @@ -111,19 +142,19 @@ let rec pp_predicate = function | BindBad s -> pp "BindBad("; pp_meta s; pp ")" | FakeBrace -> pp "FakeBrace" -and pp_binding2 subst = +and pp_binding2 subst = begin pp "["; - Common.print_between (fun () -> pp ";";Format.print_cut(); ) + Common.print_between (fun () -> pp ";";Format.print_cut(); ) (fun (s, kind) -> pp s; pp " --> "; pp_binding_kind2 kind) subst; pp "]"; end -and pp_binding2_ctlsubst subst = +and pp_binding2_ctlsubst subst = begin pp "["; - Common.print_between (fun () -> pp ";"; Format.print_cut(); ) + Common.print_between (fun () -> pp ";"; Format.print_cut(); ) (function Ast_ctl.Subst (s, kind) -> pp_meta s; pp " --> "; pp_binding_kind2 kind; @@ -138,7 +169,7 @@ let predicate_to_string pred = Common.format_to_string (function _ -> pp_predicate pred) -let pp_pred_smodif = fun (pred, smodif) -> +let pp_pred_smodif = fun (pred, smodif) -> begin pp_predicate pred; (* @@ -150,9 +181,9 @@ let pp_pred_smodif = fun (pred, smodif) -> end -let pp_ctlcocci show_plus inline_let_def ctl = +let pp_ctlcocci show_plus inline_let_def ctl = begin - if show_plus + if show_plus then begin Pretty_print_cocci.print_plus_flag := true; Pretty_print_cocci.print_minus_flag := true; @@ -161,7 +192,7 @@ let pp_ctlcocci show_plus inline_let_def ctl = Pretty_print_cocci.print_plus_flag := false; Pretty_print_cocci.print_minus_flag := false; end; - Common.pp_do_in_box (fun () -> + Common.pp_do_in_box (fun () -> Pretty_print_ctl.pp_ctl (pp_pred_smodif,(fun s -> pp_meta s)) inline_let_def ctl; );