+(*
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
+ * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
+ * Copyright 2005-2009, 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.
+ *)
+
+
(* create an index for each constructor *)
-(* current max is 147 *)
+(* current max is 157 *)
(* doesn't really work - requires that identical terms with no token
subterms (eg dots) not appear on the same line *)
let ident i =
match Ast0.unwrap i with
Ast0.Id(name) -> [10]
- | Ast0.MetaId(name,_,_) -> [11]
+ | Ast0.MetaId(name,_,_,_) -> [11]
| Ast0.MetaFunc(name,_,_) -> [12]
| Ast0.MetaLocalFunc(name,_,_) -> [13]
+ | Ast0.DisjId(_,id_list,_,_) -> [152]
| Ast0.OptIdent(id) -> [14]
| Ast0.UniqueIdent(id) -> [15]
| Ast0.Constant(const) -> [18]
| Ast0.FunCall(fn,lp,args,rp) -> [19]
| Ast0.Assignment(left,op,right,simple) -> [20]
+ | Ast0.Sequence(left,op,right) -> [156]
| Ast0.CondExpr(exp1,why,exp2,colon,exp3) -> [21]
| Ast0.Postfix(exp,op) -> [22]
| Ast0.Infix(exp,op) -> [23]
| Ast0.SizeOfExpr(szf,exp) -> [98] (* added after *)
| Ast0.SizeOfType(szf,lp,ty,rp) -> [99] (* added after *)
| Ast0.TypeExp(ty) -> [123] (* added after *)
+ | Ast0.Constructor(lp,ty,rp,init) -> [155]
| Ast0.MetaErr(name,_,_) -> [32]
| Ast0.MetaExpr(name,_,ty,_,_) -> [33]
| Ast0.MetaExprList(name,_,_) -> [34]
| Ast0.Estars(dots,whencode) -> [40]
| Ast0.OptExp(exp) -> [41]
| Ast0.UniqueExp(exp) -> [42]
+ | Ast0.AsExpr _ -> failwith "not possible"
let typeC t =
match Ast0.unwrap t with
| Ast0.FunctionType(ty,lp1,params,rp1) -> [132]
| Ast0.Array(ty,lb,size,rb) -> [50]
| Ast0.EnumName(kind,name) -> [146]
+ | Ast0.EnumDef(ty,lb,decls,rb) -> [150]
| Ast0.StructUnionName(kind,name) -> [51]
| Ast0.StructUnionDef(ty,lb,decls,rb) -> [117]
| Ast0.TypeName(name) -> [52]
| Ast0.DisjType(_,type_list,_,_) -> [130]
| Ast0.OptType(ty) -> [45]
| Ast0.UniqueType(ty) -> [46]
+ | Ast0.AsType _ -> failwith "not possible"
let declaration d =
match Ast0.unwrap d with
- Ast0.Init(stg,ty,id,eq,exp,sem) -> [54]
+ Ast0.MetaDecl(name,_) -> [148]
+ | Ast0.MetaField(name,_) -> [149]
+ | Ast0.MetaFieldList(name,_,_) -> [152]
+ | Ast0.Init(stg,ty,id,eq,exp,sem) -> [54]
| Ast0.UnInit(stg,ty,id,sem) -> [55]
| Ast0.MacroDecl(name,lp,args,rp,sem) -> [137]
+ | Ast0.MacroDeclInit(name,lp,args,rp,eq,ini,sem) -> [157]
| Ast0.TyDecl(ty,sem) -> [116]
| Ast0.Typedef(stg,ty,id,sem) -> [143]
| Ast0.DisjDecl(_,decls,_,_) -> [97] (* added after *)
| Ast0.Ddots(dots,whencode) -> [133]
| Ast0.OptDecl(decl) -> [56]
| Ast0.UniqueDecl(decl) -> [57]
+ | Ast0.AsDecl _ -> failwith "not possible"
let initialiser i =
match Ast0.unwrap i with
Ast0.MetaInit(nm,_) -> [106] (* added after *)
+ | Ast0.MetaInitList(nm,_,_) -> [153] (* added after *)
| Ast0.InitExpr(exp) -> [102]
- | Ast0.InitList(lb,initlist,rb) -> [103]
+ | Ast0.InitList(lb,initlist,rb,ordered) -> [103]
| Ast0.InitGccExt(designators,eq,ini) -> [104]
| Ast0.InitGccName(name,eq,ini) -> [105]
| Ast0.IComma(cm) -> [108]
| Ast0.Idots(d,whencode) -> [109]
| Ast0.OptIni(id) -> [110]
| Ast0.UniqueIni(id) -> [111]
+ | Ast0.AsInit _ -> failwith "not possible"
let parameterTypeDef p =
match Ast0.unwrap p with
| Ast0.Circles(d,whencode) -> [85]
| Ast0.Stars(d,whencode) -> [86]
| Ast0.Include(inc,name) -> [118]
+ | Ast0.Undef(def,id) -> [151]
| Ast0.Define(def,id,params,body) -> [119]
| Ast0.OptStm(re) -> [87]
| Ast0.UniqueStm(re) -> [88]
+ | Ast0.AsStmt _ -> failwith "not possible"
let case_line c =
match Ast0.unwrap c with
let top_level t =
match Ast0.unwrap t with
- Ast0.DECL(stmt) -> [90]
+ Ast0.NONDECL(stmt) -> [90]
| Ast0.FILEINFO(old_file,new_file) -> [92]
| Ast0.CODE(stmt_dots) -> [94]
| Ast0.ERRORWORDS(exps) -> [95]
| Ast0.OTHER(_) -> [96]
+ | Ast0.TOPCODE(_) -> [154]
(* 99-101 already used *)