(*
+ * 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.
*)
-(* Constraints on Meta-* Identifiers, Functions *)
-type idconstraint =
- IdNoConstraint
- | IdNegIdSet of string list
- | IdRegExp of string * Str.regexp
- | IdNotRegExp of string * Str.regexp
-
(* --------------------------------------------------------------------- *)
(* Modified code *)
+type added_string = Noindent of string | Indent of string
+
type info = { line : int; column : int;
- strbef : (string * int (* line *) * int (* col *)) list;
- straft : (string * int (* line *) * int (* col *)) list }
+ strbef : (added_string * int (* line *) * int (* col *)) list;
+ straft : (added_string * int (* line *) * int (* col *)) list }
type line = int
type meta_name = string * string
type 'a wrap =
| EComma of string mcode (* only in arg lists *)
| DisjExpr of expression list
- | NestExpr of expression dots * expression option * multi
+ | NestExpr of string mcode (* <.../<+... *) *
+ expression dots *
+ string mcode (* ...>/...+> *) *
+ expression option * multi
(* can appear in arg lists, and also inside Nest, as in:
if(< ... X ... Y ...>)
and constraints =
NoConstraint
- | NotIdCstrt of idconstraint
+ | NotIdCstrt of reconstraint
| NotExpCstrt of expression list
+ | SubExpCstrt of meta_name list
+
+(* Constraints on Meta-* Identifiers, Functions *)
+and idconstraint =
+ IdNoConstraint
+ | IdNegIdSet of string list * meta_name list
+ | IdRegExpConstraint of reconstraint
+
+and reconstraint =
+ | IdRegExp of string * Str.regexp
+ | IdNotRegExp of string * Str.regexp
and form = ANY | ID | LocalID | CONST (* form for MetaExp *)
and base_initialiser =
MetaInit of meta_name mcode * keep_binding * inherited
| InitExpr of expression
- | InitList of string mcode (*{*) * initialiser list * string mcode (*}*) *
+ | InitList of bool (* true if all are - *) *
+ string mcode (*{*) * initialiser list * string mcode (*}*) *
initialiser list (* whencode: elements that shouldn't appear in init *)
| InitGccExt of
designator list (* name *) * string mcode (*=*) *
statement (*decl*) dots * case_line list * rule_elem(*}*)
| Atomic of rule_elem
| Disj of statement dots list
- | Nest of statement dots *
+ | Nest of string mcode (* <.../<+... *) * statement dots *
+ string mcode (* ...>/...+> *) *
(statement dots,statement) whencode list * multi *
dots_whencode list * dots_whencode list
| FunDecl of rule_elem (* header *) * rule_elem (* { *) *
| GeneratedRulename of string option * dependency *
string list * string list * exists * bool
(* true if the whole thing is an expression *)
- | ScriptRulename of string * dependency
- | InitialScriptRulename of string
- | FinalScriptRulename of string
+ | ScriptRulename of string option (* name *) * string (* language *) *
+ dependency
+ | InitialScriptRulename of string option (* name *) * string (* language *) *
+ dependency
+ | FinalScriptRulename of string option (* name *) * string (* language *) *
+ dependency
and ruletype = Normal | Generated
CocciRule of string (* name *) *
(dependency * string list (* dropped isos *) * exists) *
top_level list * bool list (* true if generates an exp *) * ruletype
- | ScriptRule of string * dependency * (string * meta_name) list * string
- | InitialScriptRule of string * string
- | FinalScriptRule of string * string
+ | ScriptRule of string (* name *) *
+ string * dependency * (string * meta_name * metavar) list * string
+ | InitialScriptRule of string (* name *) *
+ string * dependency * string
+ | FinalScriptRule of string (* name *) *
+ string * dependency * string
and dependency =
Dep of string (* rule applies for the current binding *)
| CaseLineTag of case_line
| ConstVolTag of const_vol
| Token of string * info option
- | Pragma of string list
+ | Pragma of added_string list
| Code of top_level
| ExprDotsTag of expression dots
| ParamDotsTag of parameterTypeDef dots