4 (* --------------------------------------------------------------------- *)
7 match Ast.unwrap s
with
9 (match Ast.unwrap ast
with
10 Ast.ExprStatement
(_
,_
) -> Past.Term ast
11 | Ast.Exp
(_
) -> Past.Term ast
12 | Ast.Decl
(_
,_
,_
) -> Past.Term ast
13 | _
-> failwith
"complex statements not supported")
14 | Ast.Disj
(stm1
::stm2
::stmts
) ->
18 Past.Or
(Past.Seq
(prev
,Past.Empty
),stm_list cur
))
19 (Past.Or
(stm_list stm1
,stm_list stm2
)) stmts
20 | Ast.Dots
(dots
,whencodes
,_
,_
) ->
22 [Ast.WhenNot
(a
)] -> Past.DInfo
(Past.When
(Past.Dots
,stm_list a
),[],[])
23 | _
-> failwith
"only one when != supported")
24 | Ast.Nest
(stmt_dots
,whencodes
,false,_
,_
) ->
25 let nest = Past.Nest
(stm_list stmt_dots
) in
27 [Ast.WhenNot
(a
)] -> Past.DInfo
(Past.When
(nest,stm_list a
),[],[])
28 | _
-> failwith
"only when != supported")
29 | Ast.While
(header
,body
,(_
,_
,_
,aft
)) | Ast.For
(header
,body
,(_
,_
,_
,aft
)) ->
30 (* only allowed if only the header is significant *)
31 (match (Ast.unwrap body
,aft
) with
32 (Ast.Atomic
(re
),Ast.CONTEXT
(_
,Ast.NOTHING
)) ->
33 (match Ast.unwrap re
with
34 Ast.MetaStmt
(_
,Type_cocci.Unitary
,_
,false) -> Past.Term header
35 | _
-> failwith
"unsupported statement1")
36 | _
-> failwith
"unsupported statement2")
38 Pretty_print_cocci.statement
"" s
;
39 failwith
"unsupported statement3"
42 match Ast.unwrap s
with
45 (function cur
-> function rest
-> Past.Seq
(stm cur
, rest
))
47 | _
-> failwith
"only DOTS handled"
50 match Ast.unwrap s
with
51 Ast.CODE
(stmt_dots
) -> stm_list stmt_dots
52 | _
-> failwith
"only CODE handled"