(*
-* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
-* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
-* This file is part of Coccinelle.
-*
-* Coccinelle is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, according to version 2 of the License.
-*
-* Coccinelle is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
-*
-* The authors reserve the right to distribute this or future versions of
-* Coccinelle under other licenses.
-*)
+ * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
+
+
+(*
+ * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
+ * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
+ * This file is part of Coccinelle.
+ *
+ * Coccinelle is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, according to version 2 of the License.
+ *
+ * Coccinelle is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The authors reserve the right to distribute this or future versions of
+ * Coccinelle under other licenses.
+ *)
(* Detects subtrees that are all minus/plus and nodes that are "binding
let donothing r k e = k e in
let mcode (_,_,info,mcodekind,_,_) =
match mcodekind with
- Ast0.PLUS -> insert info.Ast0.pos_info.Ast0.line_start
+ Ast0.PLUS _ -> insert info.Ast0.pos_info.Ast0.line_start
| _ -> () in
let fn =
V0.flat_combiner bind option_default
(* --------------------------------------------------------------------- *)
-type kind = Neutral | AllMarked | NotAllMarked (* marked means + or - *)
+type kind =
+ Neutral | AllMarked of Ast.count | NotAllMarked (* marked means + or - *)
(* --------------------------------------------------------------------- *)
(* The first part analyzes each of the minus tree and the plus tree
let kind2c = function
Neutral -> "neutral"
- | AllMarked -> "allmarked"
+ | AllMarked _ -> "allmarked"
| NotAllMarked -> "notallmarked"
let node2c = function
let bind c1 c2 =
let lub = function
(k1,k2) when k1 = k2 -> k1
- | (Neutral,AllMarked) -> AllMarked
- | (AllMarked,Neutral) -> AllMarked
+ | (Neutral,AllMarked c) -> AllMarked c
+ | (AllMarked c,Neutral) -> AllMarked c
| _ -> NotAllMarked in
match (c1,c2) with
(* token/token *)
let mcode (_,_,info,mcodekind,pos,_) =
let offset = info.Ast0.pos_info.Ast0.offset in
match mcodekind with
- Ast0.MINUS(_) -> Token(AllMarked,offset,mcodekind,[])
- | Ast0.PLUS -> Token(AllMarked,offset,mcodekind,[])
+ Ast0.MINUS(_) -> Token(AllMarked Ast.ONE,offset,mcodekind,[])
+ | Ast0.PLUS c -> Token(AllMarked c,offset,mcodekind,[])
| Ast0.CONTEXT(_) -> Token(NotAllMarked,offset,mcodekind,[offset])
| _ -> failwith "not possible"
let offset = info.Ast0.pos_info.Ast0.offset in
match mcodekind with
Ast0.MINUS(_) -> Token(Neutral,offset,mcodekind,[])
- | Ast0.PLUS -> Token(Neutral,offset,mcodekind,[])
+ | Ast0.PLUS _ -> Token(Neutral,offset,mcodekind,[])
| Ast0.CONTEXT(_) -> Token(Neutral,offset,mcodekind,[offset])
| _ -> failwith "not possible"
(* distinguish from the offset of some real token *)
let offset = (-1) * info.Ast0.pos_info.Ast0.offset in
match mcodekind with
- Ast0.MINUS(_) -> Token(AllMarked,offset,mcodekind,[])
- | Ast0.PLUS -> Token(AllMarked,offset,mcodekind,[])
+ Ast0.MINUS(_) -> Token(AllMarked Ast.ONE,offset,mcodekind,[])
+ | Ast0.PLUS c -> Token(AllMarked c,offset,mcodekind,[])
| Ast0.CONTEXT(_) ->
(* Unlike the other mcode cases, we drop the offset from the context
offsets. This is because we don't know whether the term this is
intermingled with plus code. it is used in disj_cases *)
let classify is_minus all_marked table code =
let mkres builder k il tl bil btl l e =
- (if k = AllMarked
- then Ast0.set_mcodekind e (all_marked()) (* definitive *)
- else
+ (match k with
+ AllMarked count ->
+ Ast0.set_mcodekind e (all_marked count) (* definitive *)
+ | _ ->
let check_index il tl =
if List.for_all is_context tl
then
classify true
(function _ -> Ast0.MINUS(ref([],Ast0.default_token_info)))
minus_table m in
- let _ = classify false (function _ -> Ast0.PLUS) plus_table p in
+ let _ = classify false (function c -> Ast0.PLUS c) plus_table p in
traverse minus_table plus_table;
(m,p)::loop(minus,plus)
end