| Ast0.MINUS mc ->
(match !mc with
(* do better for the common case of replacing a stmt by another one *)
- ([[Ast.StatementTag(s)]],ti) ->
+ ((Ast.REPLACEMENT([[Ast.StatementTag(s)]],c)) as old,ti) ->
(match Ast.unwrap s with
Ast.IfThen(_,_,_) -> true (* potentially dangerous *)
- | _ -> mc := ([[Ast.StatementTag(s)]],ti); false)
+ | _ -> mc := (old,ti); false)
| (_,_) -> true)
| Ast0.CONTEXT mc | Ast0.MIXED mc ->
(match !mc with
| Ast0.MINUS mc ->
(match !mc with
(* do better for the common case of replacing a stmt by another one *)
- ([[Ast.StatementTag(s)]],ti) ->
+ ((Ast.REPLACEMENT([[Ast.StatementTag(s)]],count)) as old,ti) ->
(match Ast.unwrap s with
Ast.IfThen(_,_,_) -> true (* potentially dangerous *)
- | _ -> mc := ([[Ast.StatementTag(s)]],ti); false)
- | (l,_) when any_statements l -> true
+ | _ -> mc := (old,ti); false)
+ | (Ast.REPLACEMENT(l,_),_) when any_statements l -> true
| (l,ti) -> mc := (l,ti); false)
| Ast0.CONTEXT mc | Ast0.MIXED mc ->
(match !mc with
modif_before i or
match Ast0.unwrap i with
Ast0.Id(name) -> modif_before_mcode name
- | Ast0.MetaId(name,_,_) -> modif_before_mcode name
+ | Ast0.MetaId(name,_,_,_) -> modif_before_mcode name
| Ast0.MetaFunc(name,_,_) -> modif_before_mcode name
| Ast0.MetaLocalFunc(name,_,_) -> modif_before_mcode name
+ | Ast0.DisjId(_,id_list,_,_) -> List.exists left_ident id_list
| Ast0.OptIdent(id) -> left_ident id
| Ast0.UniqueIdent(id) -> left_ident id
modif_after i or
match Ast0.unwrap i with
Ast0.Id(name) -> modif_after_mcode name
- | Ast0.MetaId(name,_,_) -> modif_after_mcode name
+ | Ast0.MetaId(name,_,_,_) -> modif_after_mcode name
| Ast0.MetaFunc(name,_,_) -> modif_after_mcode name
| Ast0.MetaLocalFunc(name,_,_) -> modif_after_mcode name
+ | Ast0.DisjId(_,id_list,_,_) -> List.exists right_ident id_list
| Ast0.OptIdent(id) -> right_ident id
| Ast0.UniqueIdent(id) -> right_ident id
and left_declaration d =
modif_before d or
match Ast0.unwrap d with
- Ast0.MetaDecl(name,_) | Ast0.MetaField(name,_) -> modif_before_mcode name
+ Ast0.MetaDecl(name,_) | Ast0.MetaField(name,_)
+ | Ast0.MetaFieldList(name,_,_) ->
+ modif_before_mcode name
| Ast0.Init(Some stg,ty,id,eq,ini,sem) -> modif_before_mcode stg
| Ast0.Init(None,ty,id,eq,ini,sem) -> left_typeC ty
| Ast0.UnInit(Some stg,ty,id,sem) -> modif_before_mcode stg
and right_declaration d =
modif_before d or
match Ast0.unwrap d with
- Ast0.MetaDecl(name,_) | Ast0.MetaField(name,_) -> modif_before_mcode name
+ Ast0.MetaDecl(name,_) | Ast0.MetaField(name,_)
+ | Ast0.MetaFieldList(name,_,_) ->
+ modif_before_mcode name
| Ast0.Init(_,ty,id,eq,ini,sem) -> modif_after_mcode sem
| Ast0.UnInit(_,ty,id,sem) -> modif_after_mcode sem
| Ast0.MacroDecl(name,lp,args,rp,sem) -> modif_after_mcode sem
(* irrelevant *) false
| Ast0.Decl(_,decl) -> left_declaration decl
| Ast0.Seq(lbrace,body,rbrace) -> modif_before_mcode lbrace
- | Ast0.ExprStatement(exp,sem) -> left_expression exp
+ | Ast0.ExprStatement(Some exp,sem) -> left_expression exp
+ | Ast0.ExprStatement(None,sem) -> modif_before_mcode sem
| Ast0.IfThen(iff,lp,exp,rp,branch1,(info,aft)) -> modif_before_mcode iff
| Ast0.IfThenElse(iff,lp,exp,rp,branch1,els,branch2,(info,aft)) ->
modif_before_mcode iff
Ast0.MINUS(mc) ->
(match !mc with
(* do better for the common case of replacing a stmt by another one *)
- ([[Ast.StatementTag(s)]],ti) ->
+ ((Ast.REPLACEMENT([[Ast.StatementTag(s)]],c)) as old,ti) ->
(match Ast.unwrap s with
Ast.IfThen(_,_,_) -> true (* potentially dangerous *)
- | _ -> mc := ([[Ast.StatementTag(s)]],ti); false)
+ | _ -> mc := (old,ti); false)
| (_,_) -> true)
| Ast0.CONTEXT(mc) ->
let (text,tinfo1,tinfo2) = !mc in
let mcodekind = function
Ast0.MINUS(mc) ->
(match !mc with
- ([],_) -> true
+ (Ast.NOREPLACEMENT,_) -> true
| _ -> false)
| Ast0.CONTEXT(mc) -> false
| _ -> false in
Ast0.DOTS([]) | Ast0.CIRCLES([]) | Ast0.STARS([]) -> true
| _ -> k e in
+ let identifier r k e =
+ mcodekind (Ast0.get_mcodekind e) &&
+ match Ast0.unwrap e with
+ Ast0.DisjId(starter,id_list,mids,ender) ->
+ List.for_all r.VT0.combiner_rec_ident id_list
+ | _ -> k e in
+
let expression r k e =
mcodekind (Ast0.get_mcodekind e) &&
match Ast0.unwrap e with
V0.flat_combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
dots dots dots dots dots dots
- donothing expression typeC donothing donothing declaration
+ identifier expression typeC donothing donothing declaration
statement case_line donothing
match Ast0.get_mcodekind s with
Ast0.MINUS(mc) ->
let (text,tinfo) = !mc in
- Ast0.MINUS(ref([Ast.mkToken "{"]::text@[[Ast.mkToken "}"]],tinfo))
+ let inner_text =
+ match text with
+ Ast.NOREPLACEMENT -> [[Ast.mkToken "{}"]]
+ | Ast.REPLACEMENT(anythings,Ast.ONE) ->
+ [Ast.mkToken "{"]::anythings@[[Ast.mkToken "}"]]
+ | Ast.REPLACEMENT(anythings,Ast.MANY) ->
+ failwith "++ not supported when braces must be added" in
+ Ast0.MINUS(ref(Ast.REPLACEMENT(inner_text,Ast.ONE),tinfo))
| Ast0.CONTEXT(mc) ->
let (text,tinfo1,tinfo2) = !mc in
let new_text =
let rec unchanged_minus s =
match Ast0.get_mcodekind s with
- Ast0.MINUS(mc) -> (match !mc with ([],_) -> true | _ -> false)
+ Ast0.MINUS(mc) ->
+ (match !mc with (Ast.NOREPLACEMENT,_) -> true | _ -> false)
| _ -> false
let rec do_branch s =
let top_level t =
Ast0.rewrap t
(match Ast0.unwrap t with
- Ast0.DECL(stmt_dots) -> Ast0.DECL(statement true true stmt_dots)
+ Ast0.NONDECL(stmt_dots) -> Ast0.NONDECL(statement true true stmt_dots)
| Ast0.CODE(stmt_dots) -> Ast0.CODE(statement_dots true true stmt_dots)
| t -> t)