2 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
24 module Past
= Ast_popl
27 force_newline
(); print_string
" "; open_box
0
30 close_box
(); force_newline
()
32 (* --------------------------------------------------------------------- *)
34 let rec print_sequence = function
35 Past.Seq
(e
,seq
) -> print_element e
; force_newline
(); print_sequence seq
37 | Past.SExists
((_
,v
),seq
) -> print_string
"exists "; print_string v
;
38 print_string
" ."; force_newline
(); print_sequence seq
40 and print_element
= function
41 Past.Term
(term
) -> Pretty_print_cocci.rule_elem
"" term
42 | Past.Or
(seq1
,seq2
) ->
43 force_newline
(); print_string
"("; force_newline
(); print_sequence seq1
;
44 print_string
"|"; force_newline
(); print_sequence seq2
; print_string
")"
45 | Past.DInfo
(dots
,bef
,aft
) ->
48 (function b
-> print_string
">>>"; print_element b
; force_newline
())
52 (function b
-> force_newline
(); print_string
"<<<"; print_element b
)
55 | Past.EExists
((_
,v
),elem
) -> print_string
"exists "; print_string v
;
56 print_string
" ."; force_newline
(); print_element elem
58 and print_dots
= function
59 Past.Dots
-> print_string
"..."
60 | Past.Nest
(seq
)-> print_string
"<..."; start_block(); print_sequence seq
;
61 end_block(); print_string
"...>"
62 | Past.When
(dots
,seq
) -> print_dots dots
; print_string
" when != ";
63 open_box
0; print_sequence seq
; close_box
()
64 | Past.DExists
((_
,v
),dots
) -> print_string
"exists "; print_string v
;
65 print_string
" ."; force_newline
(); print_dots dots
67 (* --------------------------------------------------------------------- *)
69 let pretty_print_e e
=