~ubuntu-branches/ubuntu/trusty/coccinelle/trusty-proposed

« back to all changes in this revision

Viewing changes to parsing_cocci/pretty_print_cocci.ml

  • Committer: Bazaar Package Importer
  • Author(s): Євгеній Мещеряков
  • Date: 2010-06-21 14:54:01 UTC
  • mfrom: (7.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100621145401-virakyz93l2mwbk4
Tags: 0.2.2.deb-2
* Build depend on libpycaml-ocaml-dev and remove build dependency on
  python2.5-dev (closes: #567942)
* Urgency medium because of fix for an RC bug
* Updated patches:
  - system-pycaml.diff - do not add pycaml to ocamldep include path,
    otherwise it tries to compile pycaml.ml
* Use dh-ocaml to calculate dependencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
 
 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
 
2
 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
3
3
 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4
4
 * This file is part of Coccinelle.
5
5
 *
80
80
      print_anything "<<< " bef; printer term; print_anything ">>> " aft
81
81
 
82
82
let print_string_befaft fn x info =
83
 
  List.iter (function (s,_,_) -> print_string s; force_newline())
84
 
    info.Ast.strbef;
 
83
  let print = function Ast.Noindent s | Ast.Indent s -> print_string s in
 
84
  List.iter (function (s,_,_) -> print s; force_newline()) info.Ast.strbef;
85
85
  fn x;
86
 
  List.iter (function (s,_,_) -> force_newline(); print_string s)
87
 
    info.Ast.straft
 
86
  List.iter (function (s,_,_) -> force_newline(); print s) info.Ast.straft
88
87
 
89
88
let print_meta (r,x) = print_string r; print_string ":"; print_string x
90
89
 
795
794
    | Ast.ConstVolTag(x) -> const_vol x
796
795
    | Ast.Token(x,Some info) -> print_string_befaft print_string x info
797
796
    | Ast.Token(x,None) -> print_string x
798
 
    | Ast.Pragma(xs) -> print_between force_newline print_string xs
 
797
    | Ast.Pragma(xs) ->
 
798
        let print = function Ast.Noindent s | Ast.Indent s -> print_string s in
 
799
        print_between force_newline print xs
799
800
    | Ast.Code(x) -> let _ = top_level x in ()
800
801
    | Ast.ExprDotsTag(x) -> dots (function _ -> ()) expression x
801
802
    | Ast.ParamDotsTag(x) -> parameter_list x
824
825
  | Ast.NoDep   -> print_string "no_dep"
825
826
  | Ast.FailDep -> print_string "fail_dep"
826
827
 
 
828
let script_header str lang deps code =
 
829
  print_string "@@";
 
830
  force_newline();
 
831
  print_string (str ^ ":" ^ lang);
 
832
  (match deps with
 
833
    Ast.NoDep -> ()
 
834
  | _ -> print_string " depends on "; dep true deps);
 
835
  force_newline();
 
836
  print_string "@@";
 
837
  force_newline();
 
838
  print_string code;
 
839
  force_newline()
 
840
 
827
841
let unparse z =
828
842
  match z with
829
 
    Ast.InitialScriptRule (lang,code) ->
830
 
      print_string "@@";
831
 
      force_newline();
832
 
      print_string ("initialize:" ^ lang);
833
 
      force_newline();
834
 
      print_string "@@";
835
 
      force_newline();
836
 
      print_string code;
837
 
      force_newline()
838
 
  | Ast.FinalScriptRule (lang,code) ->
839
 
      print_string "@@";
840
 
      force_newline();
841
 
      print_string ("finalize:" ^ lang);
842
 
      force_newline();
843
 
      print_string "@@";
844
 
      force_newline();
845
 
      print_string code;
846
 
      force_newline()
 
843
    Ast.InitialScriptRule (lang,deps,code) ->
 
844
      script_header "initialize" lang deps code
 
845
  | Ast.FinalScriptRule (lang,deps,code) ->
 
846
      script_header "finalize" lang deps code
847
847
  | Ast.ScriptRule (lang,deps,bindings,code) ->
848
 
      print_string "@@";
849
 
      force_newline();
850
 
      print_string ("script:" ^ lang);
851
 
      (match deps with
852
 
        Ast.NoDep -> ()
853
 
      | _ -> print_string " depends on "; dep true deps);
854
 
      force_newline();
855
 
      print_string "@@";
856
 
      force_newline();
857
 
      print_string code;
858
 
      force_newline()
 
848
      script_header "script" lang deps code
859
849
  | Ast.CocciRule (nm, (deps, drops, exists), x, _, _) ->
860
850
      print_string "@@";
861
851
      force_newline();