Release coccinelle-0.2.5-rc2
[bpt/coccinelle.git] / parsing_cocci / ast0_cocci.mli
index 1b448fa..ce7c7b9 100644 (file)
@@ -1,3 +1,27 @@
+(*
+ * 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.
+ *)
+
+
 (* --------------------------------------------------------------------- *)
 (* Modified code *)
 
@@ -10,21 +34,27 @@ val default_token_info : token_info
 
 type mcodekind =
     MINUS       of (Ast_cocci.anything list list * token_info) ref
-  | PLUS
+  | PLUS        of Ast_cocci.count
   | CONTEXT     of (Ast_cocci.anything Ast_cocci.befaft *
                      token_info * token_info) ref
   | MIXED       of (Ast_cocci.anything Ast_cocci.befaft *
                      token_info * token_info) ref
 
-type info = { line_start : int; line_end : int;
-             logical_start : int; logical_end : int;
+type position_info = { line_start : int; line_end : int;
+                      logical_start : int; logical_end : int;
+                      column : int; offset : int; }
+
+type info = { pos_info : position_info;
              attachable_start : bool; attachable_end : bool;
              mcode_start : mcodekind list; mcode_end : mcodekind list;
-             column : int; offset : int;
              (* the following are only for + code *)
-             strings_before : string list; strings_after : string list }
+             strings_before : (Ast_cocci.added_string * position_info) list;
+             strings_after : (Ast_cocci.added_string * position_info) list }
+
+type 'a mcode =
+    'a * arity * info * mcodekind * meta_pos ref (* pos, - only *) *
+      int (* adjacency_index *)
 
-type 'a mcode = 'a * arity * info * mcodekind * meta_pos ref (* pos, - only *)
 and 'a wrap =
     { node : 'a;
       info : info;
@@ -62,10 +92,10 @@ and 'a dots = 'a base_dots wrap
 (* Identifier *)
 
 and base_ident =
-    Id of string mcode
-  | MetaId        of Ast_cocci.meta_name mcode * ident list * pure
-  | MetaFunc      of Ast_cocci.meta_name mcode * ident list * pure
-  | MetaLocalFunc of Ast_cocci.meta_name mcode * ident list * pure
+    Id            of string mcode
+  | MetaId        of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
+  | MetaFunc      of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
+  | MetaLocalFunc of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
   | OptIdent      of ident
   | UniqueIdent   of ident
 
@@ -74,7 +104,7 @@ and ident = base_ident wrap
 (* --------------------------------------------------------------------- *)
 (* Expression *)
 
-and base_expression = 
+and base_expression =
     Ident          of ident
   | Constant       of Ast_cocci.constant mcode
   | FunCall        of expression * string mcode (* ( *) *
@@ -100,8 +130,8 @@ and base_expression =
   | SizeOfType     of string mcode (* sizeof *) * string mcode (* ( *) *
                       typeC * string mcode (* ) *)
   | TypeExp        of typeC
-  | MetaErr        of Ast_cocci.meta_name mcode * expression list * pure
-  | MetaExpr       of Ast_cocci.meta_name mcode * expression list *
+  | MetaErr        of Ast_cocci.meta_name mcode * constraints * pure
+  | MetaExpr       of Ast_cocci.meta_name mcode * constraints *
                      Type_cocci.typeC list option * Ast_cocci.form * pure
   | MetaExprList   of Ast_cocci.meta_name mcode (* only in arglists *) *
                      listlen * pure
@@ -118,15 +148,24 @@ and base_expression =
 
 and expression = base_expression wrap
 
-and listlen = Ast_cocci.meta_name mcode option
+and constraints =
+    NoConstraint
+  | NotIdCstrt     of Ast_cocci.reconstraint
+  | NotExpCstrt    of expression list
+  | SubExpCstrt    of Ast_cocci.meta_name list
+
+and listlen =
+    MetaListLen of Ast_cocci.meta_name mcode
+  | CstListLen of int
+  | AnyListLen
 
 (* --------------------------------------------------------------------- *)
 (* Types *)
 
-and base_typeC = 
+and base_typeC =
     ConstVol        of Ast_cocci.const_vol mcode * typeC
-  | BaseType        of Ast_cocci.baseType mcode * Ast_cocci.sign mcode option
-  | ImplicitInt     of Ast_cocci.sign mcode
+  | BaseType        of Ast_cocci.baseType * string mcode list
+  | Signed          of Ast_cocci.sign mcode * typeC option
   | Pointer         of typeC * string mcode (* * *)
   | FunctionPointer of typeC *
                  string mcode(* ( *)*string mcode(* * *)*string mcode(* ) *)*
@@ -136,6 +175,9 @@ and base_typeC =
                        string mcode (* ) *)
   | Array           of typeC * string mcode (* [ *) *
                       expression option * string mcode (* ] *)
+  | EnumName        of string mcode (*enum*) * ident option (* name *)
+  | EnumDef  of typeC (* either StructUnionName or metavar *) *
+       string mcode (* { *) * expression dots * string mcode (* } *)
   | StructUnionName of Ast_cocci.structUnion mcode * ident option (* name *)
   | StructUnionDef  of typeC (* either StructUnionName or metavar *) *
        string mcode (* { *) * declaration dots * string mcode (* } *)
@@ -154,7 +196,9 @@ and typeC = base_typeC wrap
    split out into multiple declarations of a single variable each. *)
 
 and base_declaration =
-    Init       of Ast_cocci.storage mcode option * typeC * ident *
+    MetaDecl   of Ast_cocci.meta_name mcode * pure
+  | MetaField  of Ast_cocci.meta_name mcode * pure (* structure fields *)
+  | Init       of Ast_cocci.storage mcode option * typeC * ident *
        string mcode (*=*) * initialiser * string mcode (*;*)
   | UnInit     of Ast_cocci.storage mcode option * typeC * ident *
        string mcode (* ; *)
@@ -174,24 +218,27 @@ and declaration = base_declaration wrap
 (* Initializers *)
 
 and base_initialiser =
-    InitExpr of expression 
-  | InitList of string mcode (*{*) * initialiser_list * string mcode (*}*)
-  | InitGccDotName of
-      string mcode (*.*) * ident (* name *) * string mcode (*=*) *
+    MetaInit of Ast_cocci.meta_name mcode * pure
+  | InitExpr of expression
+  | InitList of string mcode (*{*) * initialiser_list * string mcode (*}*) *
+       bool (* true if ordered, false if unordered *)
+  | InitGccExt of
+      designator list (* name *) * string mcode (*=*) *
        initialiser (* gccext: *)
   | InitGccName of ident (* name *) * string mcode (*:*) *
        initialiser
-  | InitGccIndex of
-      string mcode (*[*) * expression * string mcode (*]*) *
-       string mcode (*=*) * initialiser
-  | InitGccRange of
-      string mcode (*[*) * expression * string mcode (*...*) *
-        expression * string mcode (*]*) * string mcode (*=*) * initialiser
   | IComma of string mcode
   | Idots  of string mcode (* ... *) * initialiser option (* whencode *)
   | OptIni    of initialiser
   | UniqueIni of initialiser
 
+and designator =
+    DesignatorField of string mcode (* . *) * ident
+  | DesignatorIndex of string mcode (* [ *) * expression * string mcode (* ] *)
+  | DesignatorRange of
+      string mcode (* [ *) * expression * string mcode (* ... *) *
+      expression * string mcode (* ] *)
+
 and initialiser = base_initialiser wrap
 
 and initialiser_list = initialiser dots
@@ -265,6 +312,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 (* ; *)
@@ -279,6 +327,7 @@ and base_statement =
   | Exp           of expression  (* only in dotted statement lists *)
   | TopExp        of expression (* for macros body *)
   | Ty            of typeC (* only at top level *)
+  | TopInit       of initialiser (* only at top level *)
   | Disj          of string mcode * statement dots list * string mcode list *
                     string mcode
   | Nest          of string mcode * statement dots * string mcode *
@@ -295,6 +344,7 @@ and base_statement =
        string mcode (* { *) * statement dots *
        string mcode (* } *)
   | Include of string mcode (* #include *) * Ast_cocci.inc_file mcode(* file *)
+  | Undef of string mcode (* #define *) * ident (* name *)
   | Define of string mcode (* #define *) * ident (* name *) *
        define_parameters (*params*) * statement dots
   | OptStm   of statement
@@ -310,6 +360,8 @@ and ('a,'b) whencode =
     WhenNot of 'a
   | WhenAlways of 'b
   | WhenModifier of Ast_cocci.when_modifier
+  | WhenNotTrue of expression
+  | WhenNotFalse of expression
 
 and statement = base_statement wrap
 
@@ -317,6 +369,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
@@ -347,10 +401,17 @@ and parsed_rule =
       (rule * Ast_cocci.metavar list *
         (string list * string list * Ast_cocci.dependency * string *
            Ast_cocci.exists)) *
-       (rule * Ast_cocci.metavar list)
-  | ScriptRule of
-      string * Ast_cocci.dependency * (string * Ast_cocci.meta_name) list *
+       (rule * Ast_cocci.metavar list) * Ast_cocci.ruletype
+  | ScriptRule of string (* name *) *
+      string * Ast_cocci.dependency *
+       (Ast_cocci.script_meta_name *
+          Ast_cocci.meta_name * Ast_cocci.metavar) list (*inherited vars*) *
+       Ast_cocci.meta_name list (*script vars*) *
        string
+  | InitialScriptRule of string (* name *) *
+      string (*language*) * Ast_cocci.dependency * string (*code*)
+  | FinalScriptRule of string (* name *) *
+      string (*language*) * Ast_cocci.dependency * string (*code*)
 
 (* --------------------------------------------------------------------- *)
 
@@ -373,6 +434,8 @@ and anything =
   | CaseLineTag of case_line
   | TopTag of top_level
   | IsoWhenTag of Ast_cocci.when_modifier (*only for when code, in iso phase*)
+  | IsoWhenTTag of expression(*only for when code, in iso phase*)
+  | IsoWhenFTag of expression(*only for when code, in iso phase*)
   | MetaPosTag of meta_pos (* only in iso phase *)
 
 val dotsExpr : expression dots -> anything
@@ -437,6 +500,7 @@ val fresh_index : unit -> int
 val set_mcode_data : 'a -> 'a mcode -> 'a mcode
 val make_mcode : 'a -> 'a mcode
 val make_mcode_info : 'a -> info -> 'a mcode
+val make_minus_mcode : 'a -> 'a mcode
 
 val ast0_type_to_type : typeC -> Type_cocci.typeC
 val reverse_type : Type_cocci.typeC -> base_typeC