Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / parsing_cocci / ast0_cocci.mli
index 38f35c2..7ada39a 100644 (file)
@@ -1,5 +1,7 @@
 (*
- * Copyright 2010, INRIA, University of Copenhagen
+ * 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
@@ -33,7 +35,7 @@ type token_info =
 val default_token_info : token_info
 
 type mcodekind =
-    MINUS       of (Ast_cocci.anything list list * token_info) ref
+    MINUS       of (Ast_cocci.anything Ast_cocci.replacement * token_info) ref
   | PLUS        of Ast_cocci.count
   | CONTEXT     of (Ast_cocci.anything Ast_cocci.befaft *
                      token_info * token_info) ref
@@ -49,10 +51,11 @@ type info = { pos_info : position_info;
              mcode_start : mcodekind list; mcode_end : mcodekind list;
              (* the following are only for + code *)
              strings_before : (Ast_cocci.added_string * position_info) list;
-             strings_after : (Ast_cocci.added_string * position_info) list }
+             strings_after : (Ast_cocci.added_string * position_info) list;
+             isSymbolIdent : bool; (* is the token a symbol identifier or not *) }
 
 type 'a mcode =
-    'a * arity * info * mcodekind * meta_pos list ref (* pos, - only *) *
+    'a * arity * info * mcodekind * anything list ref (* pos, - only *) *
       int (* adjacency_index *)
 
 and 'a wrap =
@@ -93,7 +96,8 @@ and 'a dots = 'a base_dots wrap
 
 and base_ident =
     Id            of string mcode
-  | MetaId        of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
+  | MetaId        of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint *
+       Ast_cocci.seed * pure
   | MetaFunc      of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
   | MetaLocalFunc of Ast_cocci.meta_name mcode * Ast_cocci.idconstraint * pure
   | DisjId        of string mcode * ident list *
@@ -113,6 +117,7 @@ and base_expression =
                       expression dots * string mcode (* ) *)
   | Assignment     of expression * Ast_cocci.assignOp mcode * expression *
                      bool (* true if it can match an initialization *)
+  | Sequence       of expression * string mcode (* , *) * expression
   | CondExpr       of expression * string mcode (* ? *) * expression option *
                      string mcode (* : *) * expression
   | Postfix        of expression * Ast_cocci.fixOp mcode
@@ -132,11 +137,14 @@ and base_expression =
   | SizeOfType     of string mcode (* sizeof *) * string mcode (* ( *) *
                       typeC * string mcode (* ) *)
   | TypeExp        of typeC
+  | Constructor    of string mcode (* ( *) * typeC * string mcode (* ) *) *
+                     initialiser
   | 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
+  | AsExpr         of expression * expression (* as expr, always metavar *)
   | EComma         of string mcode (* only in arglists *)
   | DisjExpr       of string mcode * expression list * string mcode list *
                      string mcode
@@ -185,6 +193,7 @@ and base_typeC =
        string mcode (* { *) * declaration dots * string mcode (* } *)
   | TypeName        of string mcode
   | MetaType        of Ast_cocci.meta_name mcode * pure
+  | AsType          of typeC * typeC (* as type, always metavar *)
   | DisjType        of string mcode * typeC list * (* only after iso *)
                        string mcode list (* the |s *)  * string mcode
   | OptType         of typeC
@@ -201,6 +210,7 @@ and base_declaration =
     MetaDecl   of Ast_cocci.meta_name mcode * pure (* variables *)
   | MetaField  of Ast_cocci.meta_name mcode * pure (* structure fields *)
   | MetaFieldList of Ast_cocci.meta_name mcode * listlen * pure
+  | AsDecl        of declaration * declaration
   | Init       of Ast_cocci.storage mcode option * typeC * ident *
        string mcode (*=*) * initialiser * string mcode (*;*)
   | UnInit     of Ast_cocci.storage mcode option * typeC * ident *
@@ -208,6 +218,9 @@ and base_declaration =
   | TyDecl of typeC * string mcode (* ; *)
   | MacroDecl of ident (* name *) * string mcode (* ( *) *
         expression dots * string mcode (* ) *) * string mcode (* ; *)
+  | MacroDeclInit of ident (* name *) * string mcode (* ( *) *
+        expression dots * string mcode (* ) *) * string mcode (*=*) *
+        initialiser * string mcode (* ; *)
   | Typedef of string mcode (* typedef *) * typeC * typeC * string mcode (*;*)
   | DisjDecl   of string mcode * declaration list * string mcode list *
                  string mcode
@@ -223,6 +236,7 @@ and declaration = base_declaration wrap
 and base_initialiser =
     MetaInit of Ast_cocci.meta_name mcode * pure
   | MetaInitList of Ast_cocci.meta_name mcode * listlen * pure
+  | AsInit of initialiser * initialiser (* as init, always metavar *)
   | InitExpr of expression
   | InitList of string mcode (*{*) * initialiser_list * string mcode (*}*) *
        bool (* true if ordered, false if unordered *)
@@ -291,7 +305,7 @@ and base_statement =
     Decl          of (info * mcodekind) (* before the decl *) * declaration
   | Seq           of string mcode (* { *) * statement dots *
                     string mcode (* } *)
-  | ExprStatement of expression * string mcode (*;*)
+  | ExprStatement of expression option * string mcode (*;*)
   | IfThen        of string mcode (* if *) * string mcode (* ( *) *
                     expression * string mcode (* ) *) *
                     statement * (info * mcodekind)
@@ -328,6 +342,7 @@ and base_statement =
   | MetaStmt      of Ast_cocci.meta_name mcode * pure
   | MetaStmtList  of Ast_cocci.meta_name mcode (*only in statement lists*) *
                     pure
+  | AsStmt        of statement * statement (* as statement, always metavar *)
   | Exp           of expression  (* only in dotted statement lists *)
   | TopExp        of expression (* for macros body *)
   | Ty            of typeC (* only at top level *)
@@ -390,7 +405,8 @@ and meta_pos =
 (* Top-level code *)
 
 and base_top_level =
-    DECL of statement
+    NONDECL of statement (* cannot match all of a top-level declaration *)
+  | TOPCODE of statement dots
   | CODE of statement dots
   | FILEINFO of string mcode (* old file *) * string mcode (* new file *)
   | ERRORWORDS of expression list
@@ -418,6 +434,17 @@ and parsed_rule =
 
 (* --------------------------------------------------------------------- *)
 
+and dependency =
+    Dep of string (* rule applies for the current binding *)
+  | AntiDep of dependency (* rule doesn't apply for the current binding *)
+  | EverDep of string (* rule applies for some binding *)
+  | NeverDep of string (* rule never applies for any binding *)
+  | AndDep of dependency * dependency
+  | OrDep of dependency * dependency
+  | NoDep | FailDep
+
+(* --------------------------------------------------------------------- *)
+
 and anything =
     DotsExprTag of expression dots
   | DotsInitTag of initialiser dots
@@ -439,7 +466,8 @@ and anything =
   | 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 *)
+  | MetaPosTag of meta_pos
+  | HiddenVarTag of anything list (* in iso_compile/pattern only *)
 
 val dotsExpr : expression dots -> anything
 val dotsInit : initialiser dots -> anything
@@ -474,9 +502,9 @@ val unwrap_mcode : 'a mcode -> 'a
 val rewrap : 'a wrap -> 'b -> 'b wrap
 val rewrap_mcode : 'a mcode -> 'b -> 'b mcode
 val copywrap : 'a wrap -> 'b -> 'b wrap
-val get_pos : 'a mcode -> meta_pos list
-val get_pos_ref : 'a mcode -> meta_pos list ref
-val set_pos : meta_pos list -> 'a mcode -> 'a mcode
+val get_pos : 'a mcode -> anything list
+val get_pos_ref : 'a mcode -> anything list ref
+val set_pos : anything list -> 'a mcode -> 'a mcode
 val get_info : 'a wrap -> info
 val set_info : 'a wrap -> info -> 'a wrap
 val get_index : 'a wrap -> int
@@ -505,6 +533,8 @@ val make_mcode : 'a -> 'a mcode
 val make_mcode_info : 'a -> info -> 'a mcode
 val make_minus_mcode : 'a -> 'a mcode
 
+val meta_pos_name : anything -> Ast_cocci.meta_name mcode
+
 val ast0_type_to_type : typeC -> Type_cocci.typeC
 val reverse_type : Type_cocci.typeC -> base_typeC
 exception TyConv