6 force_newline
(); print_string
" "; open_box
0
9 close_box
(); force_newline
()
11 (* --------------------------------------------------------------------- *)
13 let print_around printer term
= function
14 Ast.NOTHING
-> printer term
15 | Ast.BEFORE
(bef
,_
) ->
16 Pretty_print_cocci.print_anything
"<<< " bef
; printer term
18 printer term
; Pretty_print_cocci.print_anything
">>> " aft
19 | Ast.BEFOREAFTER
(bef
,aft
,_
) ->
20 Pretty_print_cocci.print_anything
"<<< " bef
; printer term
;
21 Pretty_print_cocci.print_anything
">>> " aft
23 let mcode fn
= function
24 (x
, _
, Ast.MINUS
(_
,_
,_
,plus_stream
), pos
) ->
25 print_string
"-"; fn x
;
26 Pretty_print_cocci.print_anything
">>> " plus_stream
27 | (x
, _
, Ast.CONTEXT
(_
,plus_streams
), pos
) ->
28 print_around fn x plus_streams
29 | (x
, info
, Ast.PLUS _
, pos
) -> fn x
31 (* --------------------------------------------------------------------- *)
33 let rec print_sequence = function
34 Past.Seq
(e
,seq
) -> print_element e
; force_newline
(); print_sequence seq
36 | Past.SExists
((_
,v
),seq
) -> print_string
"exists "; print_string v
;
37 print_string
" ."; force_newline
(); print_sequence seq
39 and print_term
= function
40 Past.Atomic
(term
) -> Pretty_print_cocci.rule_elem
"" term
41 | Past.IfThen
(test
,thn
,(_
,_
,_
,aft
)) ->
42 print_term test
; print_term thn
;
43 mcode (function _
-> ()) ((),Ast.no_info
,aft
,Ast.NoMetaPos
)
44 | Past.TExists
((_
,v
),term
) -> print_string
"exists "; print_string v
;
45 print_string
" ."; force_newline
(); print_term term
47 and print_element
= function
48 Past.Term
(term
,_
) -> print_term term
49 | Past.Or
(seq1
,seq2
) ->
50 force_newline
(); print_string
"("; force_newline
(); print_sequence seq1
;
51 print_string
"|"; force_newline
(); print_sequence seq2
; print_string
")"
56 | Past.EExists
((_
,v
),elem
) -> print_string
"exists "; print_string v
;
57 print_string
" ."; force_newline
(); print_element elem
59 and print_dots
= function
60 Past.Dots
-> print_string
"..."
61 | Past.Nest
(seq
)-> print_string
"<..."; start_block(); print_sequence seq
;
62 end_block(); print_string
"...>"
63 | Past.When
(dots
,seq
) -> print_dots dots
; print_string
" when != ";
64 open_box
0; print_sequence seq
; close_box
()
66 (* --------------------------------------------------------------------- *)
68 let pretty_print_e e
=