Release coccinelle-0.2.0
[bpt/coccinelle.git] / parsing_cocci / ast0_cocci.ml
index 993e234..850afbb 100644 (file)
@@ -1,23 +1,23 @@
 (*
-* 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-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.
+ *)
 
 
 module Ast = Ast_cocci
@@ -35,9 +35,11 @@ let default_token_info =
 
 (* MIXED is like CONTEXT, since sometimes MIXED things have to revert to
 CONTEXT - see insert_plus.ml *)
+type count = ONE (* + *) | MANY (* ++ *)
+
 type mcodekind =
     MINUS       of (Ast.anything list list * token_info) ref
-  | PLUS
+  | PLUS        of Ast.count
   | CONTEXT     of (Ast.anything Ast.befaft * token_info * token_info) ref
   | MIXED       of (Ast.anything Ast.befaft * token_info * token_info) ref
 
@@ -98,10 +100,10 @@ and 'a dots = 'a base_dots wrap
 (* Identifier *)
 
 and base_ident =
-    Id of string mcode
-  | MetaId        of Ast.meta_name mcode * ident list * pure
-  | MetaFunc      of Ast.meta_name mcode * ident list * pure
-  | MetaLocalFunc of Ast.meta_name mcode * ident list * pure
+    Id            of string mcode
+  | MetaId        of Ast.meta_name mcode * Ast.idconstraint * pure
+  | MetaFunc      of Ast.meta_name mcode * Ast.idconstraint * pure
+  | MetaLocalFunc of Ast.meta_name mcode * Ast.idconstraint * pure
   | OptIdent      of ident
   | UniqueIdent   of ident
 
@@ -136,8 +138,8 @@ and base_expression =
   | SizeOfType     of string mcode (* sizeof *) * string mcode (* ( *) *
                       typeC * string mcode (* ) *)
   | TypeExp        of typeC (* type name used as an expression, only in args *)
-  | MetaErr        of Ast.meta_name mcode * expression list * pure
-  | MetaExpr       of Ast.meta_name mcode * expression list *
+  | MetaErr        of Ast.meta_name mcode * constraints * pure
+  | MetaExpr       of Ast.meta_name mcode * constraints *
                      Type_cocci.typeC list option * Ast.form * pure
   | MetaExprList   of Ast.meta_name mcode (* only in arg lists *) *
                      listlen * pure
@@ -154,6 +156,11 @@ and base_expression =
 
 and expression = base_expression wrap
 
+and constraints =
+    NoConstraint
+  | NotIdCstrt     of Ast.idconstraint
+  | NotExpCstrt    of expression list
+
 and listlen = Ast.meta_name mcode option
 
 (* --------------------------------------------------------------------- *)
@@ -304,6 +311,7 @@ and base_statement =
                     statement * (info * mcodekind) (* after info *)
   | Switch        of string mcode (* switch *) * string mcode (* ( *) *
                     expression * string mcode (* ) *) * string mcode (* { *) *
+                    statement (*decl*) dots *
                     case_line dots * string mcode (* } *)
   | Break         of string mcode (* break *) * string mcode (* ; *)
   | Continue      of string mcode (* continue *) * string mcode (* ; *)
@@ -358,6 +366,8 @@ and base_case_line =
     Default of string mcode (* default *) * string mcode (*:*) * statement dots
   | Case of string mcode (* case *) * expression * string mcode (*:*) *
        statement dots
+  | DisjCase of string mcode * case_line list *
+       string mcode list (* the |s *) * string mcode
   | OptCase of case_line
 
 and case_line = base_case_line wrap
@@ -628,7 +638,7 @@ let rec reverse_type ty =
        (* not right... *)
        EnumName
          (make_mcode "enum",
-          context_wrap(MetaId(make_mcode ("",tag),[],Impure)))
+          context_wrap(MetaId(make_mcode ("",tag),Ast.IdNoConstraint,Impure)))
       else
        EnumName(make_mcode "enum",context_wrap(Id(make_mcode tag)))
   | Type_cocci.StructUnionName(su,mv,tag) ->
@@ -637,7 +647,7 @@ let rec reverse_type ty =
        (* not right... *)
        StructUnionName
          (reverse_structUnion su,
-          Some(context_wrap(MetaId(make_mcode ("",tag),[],Impure))))
+          Some(context_wrap(MetaId(make_mcode ("",tag),Ast.IdNoConstraint,Impure))))
       else
        StructUnionName
          (reverse_structUnion su,