Coccinelle release 1.0.0-rc3
[bpt/coccinelle.git] / parsing_cocci / index.ml
index e4b98a2..a6aea02 100644 (file)
@@ -1,27 +1,29 @@
 (*
-* Copyright 2005-2008, 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 2010, 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 145 *)
+(* current max is 154 *)
 
 (* doesn't really work - requires that identical terms with no token
 subterms (eg dots) not appear on the same line *)
@@ -33,56 +35,57 @@ module Ast0 = Ast0_cocci
 address.  Otherwise add 0.  An empty dot list should only match with another
 empty one. *)
 let expression_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 1::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 2::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 3::(if l = [] then [ln] else [0])
-       
+
 let initialiser_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 113::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 114::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 115::(if l = [] then [ln] else [0])
-       
+
 let parameter_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 4::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 5::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 6::(if l = [] then [ln] else [0])
-       
+
 let statement_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 7::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 8::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 9::(if l = [] then [ln] else [0])
-       
+
 let declaration_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 134::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 135::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 136::(if l = [] then [ln] else [0])
-       
+
 let case_line_dots d =
-  let ln = (Ast0.get_info d).Ast0.line_start in
+  let ln = (Ast0.get_info d).Ast0.pos_info.Ast0.line_start in
   match Ast0.unwrap d with
     Ast0.DOTS(l) -> 138::(if l = [] then [ln] else [0])
   | Ast0.CIRCLES(l) -> 139::(if l = [] then [ln] else [0])
   | Ast0.STARS(l) -> 140::(if l = [] then [ln] else [0])
-       
+
 let ident i =
   match Ast0.unwrap i with
-    Ast0.Id(name) -> [10]
-  | Ast0.MetaId(name,_,_) -> [11]
-  | Ast0.MetaFunc(name,_,_) -> [12]
-  | Ast0.MetaLocalFunc(name,_,_) -> [13]
-  | Ast0.OptIdent(id) -> [14]
-  | Ast0.UniqueIdent(id) -> [15]
-       
+      Ast0.Id(name) -> [10]
+    | 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]
+
 let expression e =
   match Ast0.unwrap e with
     Ast0.Ident(id) -> [17]
@@ -118,12 +121,14 @@ let expression e =
 let typeC t =
   match Ast0.unwrap t with
     Ast0.ConstVol(cv,ty) -> [44]
-  | Ast0.BaseType(ty,sign) -> [48]
-  | Ast0.ImplicitInt(sign) -> [129]
+  | Ast0.BaseType(ty,strings) -> [48]
+  | Ast0.Signed(sign,ty) -> [129]
   | Ast0.Pointer(ty,star) -> [49]
   | Ast0.FunctionPointer(ty,lp1,star,rp1,lp2,params,rp2) -> [131]
   | 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]
@@ -131,10 +136,13 @@ let typeC t =
   | Ast0.DisjType(_,type_list,_,_) -> [130]
   | Ast0.OptType(ty) -> [45]
   | Ast0.UniqueType(ty) -> [46]
-       
+
 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.TyDecl(ty,sem) -> [116]
@@ -146,12 +154,12 @@ let declaration d =
 
 let initialiser i =
   match Ast0.unwrap i with
-    Ast0.InitExpr(exp) -> [102] (* added after *)
-  | Ast0.InitList(lb,initlist,rb) -> [103]
-  | Ast0.InitGccDotName(dot,name,eq,ini) -> [104]
+    Ast0.MetaInit(nm,_) -> [106] (* added after *)
+  | Ast0.MetaInitList(nm,_,_) -> [153] (* added after *)
+  | Ast0.InitExpr(exp) -> [102]
+  | Ast0.InitList(lb,initlist,rb,ordered) -> [103]
+  | Ast0.InitGccExt(designators,eq,ini) -> [104]
   | Ast0.InitGccName(name,eq,ini) -> [105]
-  | Ast0.InitGccIndex(lb,exp,rb,eq,ini) -> [106]
-  | Ast0.InitGccRange(lb,exp1,dots,exp2,rb,eq,ini) -> [107]
   | Ast0.IComma(cm) -> [108]
   | Ast0.Idots(d,whencode) -> [109]
   | Ast0.OptIni(id) -> [110]
@@ -168,7 +176,7 @@ let parameterTypeDef p =
   | Ast0.Pcircles(dots) -> [65]
   | Ast0.OptParam(param) -> [66]
   | Ast0.UniqueParam(param) -> [67]
-       
+
 let statement s =
   match Ast0.unwrap s with
     Ast0.FunDecl(bef,fninfo,name,lp,params,rp,lbrace,body,rbrace) -> [68]
@@ -181,7 +189,7 @@ let statement s =
   | Ast0.Do(d,body,whl,lp,exp,rp,sem) -> [75]
   | Ast0.For(fr,lp,e1,sem1,e2,sem2,e3,rp,body,_) -> [76]
   | Ast0.Iterator(nm,lp,args,rp,body,_) -> [142]
-  | Ast0.Switch(switch,lp,exp,rp,lb,cases,rb) -> [125]
+  | Ast0.Switch(switch,lp,exp,rp,lb,decls,cases,rb) -> [125]
   | Ast0.Break(br,sem) -> [100]
   | Ast0.Continue(cont,sem) -> [101]
   | Ast0.Label(l,dd) -> [144]
@@ -195,10 +203,12 @@ let statement s =
   | Ast0.Exp(exp) -> [83]
   | Ast0.TopExp(exp) -> [141]
   | Ast0.Ty(ty) -> [124]
+  | Ast0.TopInit(init) -> [146]
   | Ast0.Dots(d,whencode) -> [84]
   | 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]
@@ -207,14 +217,16 @@ let case_line c =
   match Ast0.unwrap c with
     Ast0.Default(def,colon,code) -> [126]
   | Ast0.Case(case,exp,colon,code) -> [127]
+  | Ast0.DisjCase(_,case_lines,_,_) -> [107]
   | Ast0.OptCase(case) -> [128]
 
 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 *)