+let rec is_decl s =
+ match Ast0.unwrap s with
+ Ast0.Decl(_,e) -> true
+ | _ -> false
+
+let isonly f l = match Ast0.undots l with [s] -> f s | _ -> false
+let isall f l = List.for_all (isonly f) l
+
+let rec is_toplevel s =
+ match Ast0.unwrap s with
+ Ast0.Decl(_,e) -> true
+ | Ast0.FunDecl(_,_,_,_,_,_,_,_,_) -> true
+ | Ast0.Disj(_,stmts,_,_) -> isall is_toplevel stmts
+ | Ast0.ExprStatement(Some fc,_) -> false
+ | Ast0.Include(_,_) -> true
+ | Ast0.Undef(_,_) -> true
+ | Ast0.Define(_,_,_,_) -> true
+ | _ -> false
+
+let scan_code must_be_code l =