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

« back to all changes in this revision

Viewing changes to parsing_c/unparse_cocci.ml

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-09-08 13:06:20 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090908130620-s33aehu14xddef4u
Tags: 0.1.10.deb-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/control: build-depend on python2.6-dev,
    set XB-Python-Version to 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
  pr s line lcol rcol in
46
46
let print_text s = pr s unknown unknown unknown in
47
47
let close_box _ = () in
48
 
let force_newline () = print_text "\n" in
 
48
let force_newline _ = print_text "\n" in
49
49
 
50
50
let start_block () = force_newline(); indent() in
51
51
let end_block () = unindent(); force_newline () in
111
111
  List.iter
112
112
    (function (s,ln,col) -> force_newline(); fn1(); print_string s ln col)
113
113
    info.Ast.straft in
114
 
 
115
114
let print_meta (r,x) = print_text x in
116
115
 
117
116
let print_pos = function
146
145
      | _ -> force_newline());
147
146
      fn s line lcol;
148
147
      let _ = print_comments (Some info.Ast.line) info.Ast.straft in
 
148
      (* newline after a pragma
 
149
         should really store parsed versions of the strings, but make a cheap
 
150
         effort here
 
151
         print_comments takes care of interior newlines *)
 
152
      (match List.rev info.Ast.straft with
 
153
        (str,_,_)::_ when String.length str > 0 && String.get str 0 = '#' ->
 
154
          force_newline()
 
155
      | _ -> ());
149
156
      ()
150
157
      (* printing for rule generation *)
151
158
  | (true, Ast.MINUS(_,_,_,plus_stream)) ->
256
263
  | Ast.Constant(const) -> mcode constant const
257
264
  | Ast.FunCall(fn,lp,args,rp) ->
258
265
      expression fn; mcode print_string_box lp;
259
 
      dots (function _ -> ()) expression args;
 
266
      let comma e =
 
267
        expression e;
 
268
        match Ast.unwrap e with
 
269
          Ast.EComma(cm) -> pr_space()
 
270
        | _ -> () in
 
271
      dots (function _ -> ()) comma args;
260
272
      close_box(); mcode print_string rp
261
273
  | Ast.Assignment(left,op,right,_) ->
262
274
      expression left; pr_space(); mcode assignOp op;
608
620
  | Ast.Pdots(dots) | Ast.Pcircles(dots) -> raise CantBeInPlus
609
621
  | Ast.OptParam(param) | Ast.UniqueParam(param) -> raise CantBeInPlus
610
622
 
611
 
and parameter_list l = dots (function _ -> ()) parameterTypeDef l
 
623
and parameter_list l =
 
624
  let comma p =
 
625
    parameterTypeDef p;
 
626
    match Ast.unwrap p with
 
627
      Ast.PComma(cm) -> pr_space()
 
628
    | _ -> () in
 
629
  dots (function _ -> ()) comma l
612
630
in
613
631
 
614
632
 
791
809
      indent_if_needed body (function _ -> statement arity body);
792
810
      mcode (fun _ _ _ -> ()) ((),Ast.no_info,aft,Ast.NoMetaPos)
793
811
 
794
 
  | Ast.Switch(header,lb,cases,rb) ->
 
812
  | Ast.Switch(header,lb,decls,cases,rb) ->
795
813
      rule_elem arity header; pr_space(); rule_elem arity lb;
 
814
      dots force_newline (statement arity) decls;
796
815
      List.iter (function x -> case_line arity x; force_newline()) cases;
797
816
      rule_elem arity rb
798
817