[] any_list_list in
let mcode r mc =
match Ast.get_mcodekind mc with
- Ast.MINUS(_,_,_,any_list_list) -> do_any_list_list r any_list_list
+ Ast.MINUS(_,_,_,any_list_list) ->
+ (match any_list_list with
+ Ast.NOREPLACEMENT -> []
+ | Ast.REPLACEMENT(any_list_list,_) ->
+ do_any_list_list r any_list_list)
| Ast.CONTEXT(_,any_befaft) ->
(match any_befaft with
Ast.BEFORE(any_list_list,_) | Ast.AFTER(any_list_list,_) ->
let names =
(V.combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing
donothing expression donothing donothing donothing donothing donothing
donothing donothing donothing donothing donothing).V.combiner_top_level
rule in
| Ast_c.MetaTypeVal(ty) -> Visitor_c.vk_type bigf ty
| Ast_c.MetaInitVal(ty) -> Visitor_c.vk_ini bigf ty
+ | Ast_c.MetaInitListVal(ty) -> Visitor_c.vk_ini_list bigf ty
+ | Ast_c.MetaDeclVal(decl) -> Visitor_c.vk_decl bigf decl
+ | Ast_c.MetaFieldVal(field) -> Visitor_c.vk_struct_field bigf field
+ | Ast_c.MetaFieldListVal(fields) -> Visitor_c.vk_struct_fields bigf fields
| Ast_c.MetaStmtVal(stm) -> Visitor_c.vk_statement bigf stm
| Ast_c.MetaPosVal _ | Ast_c.MetaPosValList _
| Ast_c.MetaListlenVal _ -> ())
Ast_c.MetaTypeVal(Visitor_c.vk_type_s bigf ty)
| Ast_c.MetaInitVal(ini) ->
Ast_c.MetaInitVal(Visitor_c.vk_ini_s bigf ini)
+ | Ast_c.MetaInitListVal(ini) ->
+ Ast_c.MetaInitListVal(Visitor_c.vk_inis_s bigf ini)
+ | Ast_c.MetaDeclVal(stm) ->
+ Ast_c.MetaDeclVal(Visitor_c.vk_decl_s bigf stm)
+ | Ast_c.MetaFieldVal(stm) ->
+ Ast_c.MetaFieldVal(Visitor_c.vk_struct_field_s bigf stm)
+ | Ast_c.MetaFieldListVal(stm) ->
+ Ast_c.MetaFieldListVal(Visitor_c.vk_struct_fields_s bigf stm)
| Ast_c.MetaStmtVal(stm) ->
Ast_c.MetaStmtVal(Visitor_c.vk_statement_s bigf stm)
| Ast_c.MetaPosVal _ | Ast_c.MetaPosValList _
types;
pr "}"
+let pp_len pr len =
+ let pp_name (_,n) = pr n in
+ match len with
+ Ast.AnyLen -> ()
+ | Ast.MetaLen len -> pr "["; pp_name len; pr "]"
+ | Ast.CstLen len -> pr "["; pr (string_of_int len); pr "]"
+
let pp_meta_decl pr env decl =
let no_arity = function Ast.NONE -> () | _ -> failwith "no arity allowed" in
let pp_name (_,n) = pr n in
match decl with
- Ast.MetaIdDecl(ar, name) ->
+ Ast.MetaMetaDecl(ar, name) ->
+ (* ignore virtual *)
+ no_arity ar; pr "metavariable "; pp_name name; pr ";\n"
+ | Ast.MetaIdDecl(ar, name) ->
(* ignore virtual *)
no_arity ar; pr "identifier "; pp_name name; pr ";\n"
| Ast.MetaFreshIdDecl(name, Ast.NoVal) ->
no_arity ar; pr "type "; pp_name name; pr ";\n"
| Ast.MetaInitDecl(ar, name) ->
no_arity ar; pr "initialiser "; pp_name name; pr ";\n"
+ | Ast.MetaInitListDecl(ar, name, len) ->
+ no_arity ar; pr "initialiser list "; pp_name name; pp_len pr len; pr ";\n"
| Ast.MetaListlenDecl(name) -> ()
| Ast.MetaParamDecl(ar, name) ->
no_arity ar; pr "parameter "; pp_name name; pr ";\n"
- | Ast.MetaParamListDecl(ar, name, Ast.AnyLen) ->
- no_arity ar; pr "parameter list "; pp_name name; pr ";\n"
- | Ast.MetaParamListDecl(ar, name, Ast.MetaLen len) ->
- no_arity ar; pr "parameter list "; pp_name name;
- pr "["; pp_name len; pr "]"; pr ";\n"
- | Ast.MetaParamListDecl(ar, name, Ast.CstLen len) ->
- no_arity ar; pr "parameter list "; pr (string_of_int len);
- pr "["; pr (string_of_int len); pr "]"; pr ";\n"
+ | Ast.MetaParamListDecl(ar, name, len) ->
+ no_arity ar; pr "parameter list "; pp_name name; pp_len pr len; pr ";\n"
| Ast.MetaConstDecl(ar, name, types) ->
no_arity ar; pr "constant "; print_types pr env types;
pp_name name; pr ";\n"
| Ast.MetaLocalIdExpDecl(ar, name, types) ->
no_arity ar; pr "local idexpression ";
print_types pr env types; pp_name name; pr ";\n"
- | Ast.MetaExpListDecl(ar, name, Ast.AnyLen) ->
- no_arity ar; pr "parameter list "; pp_name name; pr ";\n"
- | Ast.MetaExpListDecl(ar, name, Ast.MetaLen len) ->
- no_arity ar; pr "parameter list ";
- pp_name name; pr "["; pp_name len; pr "]"; pr ";\n"
- | Ast.MetaExpListDecl(ar, name, Ast.CstLen len) ->
- no_arity ar; pr "parameter list ";
- pp_name name; pr "["; pr (string_of_int len); pr "]"; pr ";\n"
+ | Ast.MetaExpListDecl(ar, name, len) ->
+ no_arity ar; pr "parameter list "; pp_name name; pp_len pr len; pr ";\n"
+ | Ast.MetaDeclDecl(ar, name) ->
+ no_arity ar; pr "declaration "; pp_name name; pr ";\n"
+ | Ast.MetaFieldDecl(ar, name) ->
+ no_arity ar; pr "field "; pp_name name; pr ";\n"
+ | Ast.MetaFieldListDecl(ar, name, len) ->
+ no_arity ar; pr "field list "; pp_name name; pp_len pr len; pr ";\n"
| Ast.MetaStmDecl(ar, name) ->
no_arity ar; pr "statement "; pp_name name; pr ";\n"
| Ast.MetaStmListDecl(ar, name) ->
no_arity ar; pr "local function "; pp_name name; pr ";\n"
| Ast.MetaPosDecl(ar, name) ->
no_arity ar; pr "position "; pp_name name; pr ";\n"
+ | Ast.MetaAnalysisDecl(code, name) ->
+ pr "analysis"; pr code; pr " "; pp_name name; pr ";\n"
| Ast.MetaDeclarerDecl(ar, name) ->
no_arity ar; pr "declarer "; pp_name name; pr ";\n"
| Ast.MetaIteratorDecl(ar, name) ->
Ast.CocciRule(_,_,[body],_,_) -> (* could extend to use attributes *)
(body,
match Ast.unwrap body with
- Ast.DECL(s) -> [[Ast.StatementTag s]]
+ Ast.NONDECL(s) -> [[Ast.StatementTag s]]
| Ast.CODE(ss) -> [[Ast.StmtDotsTag ss]]
| _ -> error body "bad rule body")
| _ -> failwith "bad rule" in
Ast_c.AbstractLineTok _ -> pr (Ast_c.str_of_info info)
| Ast_c.FakeTok (s,_) -> pr s
| _ ->
- Printf.printf "line: %s\n" (Common.dump info);
+ Printf.printf "line: %s\n" (Dumper.dump info);
error rule "not an abstract line" in
let pr_space _ = pr " " in
Unparse_cocci.pp_list_list_any
([env], (fun s _ _ _ _ -> pr s), pr_c, pr_space, pr_space, pr,
- (fun _ _ -> ()), (function _ -> ()), (function _ -> ()))
+ (fun _ _ -> ()), (function _ -> ()), (function _ -> ()),
+ (function _ -> ()))
true printable Unparse_cocci.InPlace;
print_end pr;
pr "\n")