Commit | Line | Data |
---|---|---|
f537ebc4 C |
1 | (* |
2 | * Copyright 2010, INRIA, University of Copenhagen | |
3 | * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix | |
4 | * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen | |
5 | * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix | |
6 | * This file is part of Coccinelle. | |
7 | * | |
8 | * Coccinelle is free software: you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation, according to version 2 of the License. | |
11 | * | |
12 | * Coccinelle is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>. | |
19 | * | |
20 | * The authors reserve the right to distribute this or future versions of | |
21 | * Coccinelle under other licenses. | |
22 | *) | |
23 | ||
24 | ||
951c7801 C |
25 | open Format |
26 | module Past = Ast_popl | |
27 | ||
28 | let start_block str = | |
29 | force_newline(); print_string " "; open_box 0 | |
30 | ||
31 | let end_block str = | |
32 | close_box(); force_newline () | |
33 | ||
34 | (* --------------------------------------------------------------------- *) | |
35 | ||
36 | let rec print_sequence = function | |
37 | Past.Seq(e,seq) -> print_element e; force_newline(); print_sequence seq | |
38 | | Past.Empty -> () | |
39 | | Past.SExists((_,v),seq) -> print_string "exists "; print_string v; | |
40 | print_string " ."; force_newline(); print_sequence seq | |
41 | ||
42 | and print_element = function | |
43 | Past.Term(term) -> Pretty_print_cocci.rule_elem "" term | |
44 | | Past.Or(seq1,seq2) -> | |
45 | force_newline(); print_string "("; force_newline(); print_sequence seq1; | |
46 | print_string "|"; force_newline(); print_sequence seq2; print_string ")" | |
47 | | Past.DInfo(dots,bef,aft) -> | |
48 | start_block(); | |
49 | List.iter | |
50 | (function b -> print_string ">>>"; print_element b; force_newline()) | |
51 | bef; | |
52 | print_dots dots; | |
53 | List.iter | |
54 | (function b -> force_newline(); print_string "<<<"; print_element b) | |
55 | aft; | |
56 | end_block() | |
57 | | Past.EExists((_,v),elem) -> print_string "exists "; print_string v; | |
58 | print_string " ."; force_newline(); print_element elem | |
59 | ||
60 | and print_dots = function | |
61 | Past.Dots -> print_string "..." | |
62 | | Past.Nest(seq)-> print_string "<..."; start_block(); print_sequence seq; | |
63 | end_block(); print_string "...>" | |
64 | | Past.When(dots,seq) -> print_dots dots; print_string " when != "; | |
65 | open_box 0; print_sequence seq; close_box() | |
66 | | Past.DExists((_,v),dots) -> print_string "exists "; print_string v; | |
67 | print_string " ."; force_newline(); print_dots dots | |
68 | ||
69 | (* --------------------------------------------------------------------- *) | |
70 | ||
71 | let pretty_print_e e = | |
72 | print_element e; | |
73 | print_newline() | |
74 | ||
75 | let pretty_print sl = | |
76 | print_sequence sl; | |
77 | print_newline() | |
78 |