Coccinelle release 1.0.0-rc15
[bpt/coccinelle.git] / parsing_cocci / ast0_cocci.mli
index 5d54968..72d8df0 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
@@ -22,6 +24,7 @@
  *)
 
 
+# 0 "./ast0_cocci.mli"
 (* --------------------------------------------------------------------- *)
 (* Modified code *)
 
@@ -33,7 +36,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 +52,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 ref (* pos, - only *) *
+    'a * arity * info * mcodekind * anything list ref (* pos, - only *) *
       int (* adjacency_index *)
 
 and 'a wrap =
@@ -93,9 +97,13 @@ 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
+  | AsIdent       of ident * ident (* as ident, always metavar *)
+  | DisjId        of string mcode * ident list *
+                     string mcode list (* the |s *) * string mcode
   | OptIdent      of ident
   | UniqueIdent   of ident
 
@@ -111,6 +119,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
@@ -130,11 +139,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
@@ -183,6 +195,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
@@ -196,8 +209,10 @@ and typeC = base_typeC wrap
    split out into multiple declarations of a single variable each. *)
 
 and base_declaration =
-    MetaDecl   of Ast_cocci.meta_name mcode * pure
+    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 *
@@ -205,6 +220,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
@@ -219,6 +237,8 @@ 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 *)
@@ -287,7 +307,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)
@@ -302,8 +322,7 @@ and base_statement =
                      string mcode (* while *) * string mcode (* ( *) *
                     expression * string mcode (* ) *) *
                      string mcode (* ; *)
-  | For           of string mcode (* for *) * string mcode (* ( *) *
-                     expression option * string mcode (*;*) *
+  | For           of string mcode (* for *) * string mcode (* ( *) * forinfo *
                     expression option * string mcode (*;*) *
                      expression option * string mcode (* ) *) * statement *
                     (info * mcodekind) (* after info *)
@@ -324,6 +343,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 *)
@@ -344,11 +364,18 @@ 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
   | UniqueStm of statement
 
+and base_forinfo =
+    ForExp of expression option * string mcode (*;*)
+  | ForDecl of (info * mcodekind) (* before the decl *) * declaration
+
+and forinfo = base_forinfo wrap
+
 and fninfo =
     FStorage of Ast_cocci.storage mcode
   | FType of typeC
@@ -380,13 +407,13 @@ and case_line = base_case_line wrap
 and meta_pos =
     MetaPos of Ast_cocci.meta_name mcode * Ast_cocci.meta_name list *
        Ast_cocci.meta_collect
-  | NoMetaPos
 
 (* --------------------------------------------------------------------- *)
 (* 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
@@ -414,6 +441,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
@@ -430,12 +468,14 @@ and anything =
   | InitTag of initialiser
   | DeclTag of declaration
   | StmtTag of statement
+  | ForInfoTag of forinfo
   | 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 *)
+  | MetaPosTag of meta_pos
+  | HiddenVarTag of anything list (* in iso_compile/pattern only *)
 
 val dotsExpr : expression dots -> anything
 val dotsInit : initialiser dots -> anything
@@ -450,6 +490,7 @@ val param : parameterTypeDef -> anything
 val ini : initialiser -> anything
 val decl : declaration -> anything
 val stmt : statement -> anything
+val forinfo : forinfo -> anything
 val case_line : case_line -> anything
 val top : top_level -> anything
 
@@ -470,9 +511,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
-val get_pos_ref : 'a mcode -> meta_pos ref
-val set_pos : meta_pos -> '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
@@ -501,6 +542,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