1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
(*
* This file is part of Coccinelle, licensed under the terms of the GPL v2.
* See copyright.txt in the Coccinelle source code for more information.
* The Coccinelle source code can be obtained at http://coccinelle.lip6.fr
*)
open Format
module Past = Ast_popl
let start_block str =
force_newline(); print_string " "; open_box 0
let end_block str =
close_box(); force_newline ()
(* --------------------------------------------------------------------- *)
let rec print_sequence = function
Past.Seq(e,seq) -> print_element e; force_newline(); print_sequence seq
| Past.Empty -> ()
| Past.SExists((_,v),seq) -> print_string "exists "; print_string v;
print_string " ."; force_newline(); print_sequence seq
and print_element = function
Past.Term(term) -> Pretty_print_cocci.rule_elem "" term
| Past.Or(seq1,seq2) ->
force_newline(); print_string "("; force_newline(); print_sequence seq1;
print_string "|"; force_newline(); print_sequence seq2; print_string ")"
| Past.DInfo(dots,bef,aft) ->
start_block();
List.iter
(function b -> print_string ">>>"; print_element b; force_newline())
bef;
print_dots dots;
List.iter
(function b -> force_newline(); print_string "<<<"; print_element b)
aft;
end_block()
| Past.EExists((_,v),elem) -> print_string "exists "; print_string v;
print_string " ."; force_newline(); print_element elem
and print_dots = function
Past.Dots -> print_string "..."
| Past.Nest(seq)-> print_string "<..."; start_block(); print_sequence seq;
end_block(); print_string "...>"
| Past.When(dots,seq) -> print_dots dots; print_string " when != ";
open_box 0; print_sequence seq; close_box()
| Past.DExists((_,v),dots) -> print_string "exists "; print_string v;
print_string " ."; force_newline(); print_dots dots
(* --------------------------------------------------------------------- *)
let pretty_print_e e =
print_element e;
print_newline()
let pretty_print sl =
print_sequence sl;
print_newline()
|