| 1 | (* |
| 2 | * Copyright 2012, INRIA |
| 3 | * Julia Lawall, Gilles Muller |
| 4 | * Copyright 2010-2011, INRIA, University of Copenhagen |
| 5 | * Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix |
| 6 | * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen |
| 7 | * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix |
| 8 | * This file is part of Coccinelle. |
| 9 | * |
| 10 | * Coccinelle is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, according to version 2 of the License. |
| 13 | * |
| 14 | * Coccinelle is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | * The authors reserve the right to distribute this or future versions of |
| 23 | * Coccinelle under other licenses. |
| 24 | *) |
| 25 | |
| 26 | |
| 27 | # 0 "./ast_cocci.mli" |
| 28 | (* --------------------------------------------------------------------- *) |
| 29 | (* Modified code *) |
| 30 | |
| 31 | type added_string = Noindent of string | Indent of string | Space of string |
| 32 | |
| 33 | type info = { line : int; column : int; |
| 34 | strbef : (added_string * int (* line *) * int (* col *)) list; |
| 35 | straft : (added_string * int (* line *) * int (* col *)) list } |
| 36 | type line = int |
| 37 | type meta_name = string * string |
| 38 | type 'a wrap = |
| 39 | {node : 'a; |
| 40 | node_line : line; |
| 41 | free_vars : meta_name list; (*free vars*) |
| 42 | minus_free_vars : meta_name list; (*minus free vars*) |
| 43 | fresh_vars : (meta_name * seed) list; (*fresh vars*) |
| 44 | inherited : meta_name list; (*inherited vars*) |
| 45 | saved_witness : meta_name list; (*witness vars*) |
| 46 | bef_aft : dots_bef_aft; |
| 47 | pos_info : meta_name mcode option; (* pos info, try not to duplicate *) |
| 48 | true_if_test_exp : bool;(* true if "test_exp from iso", only for exprs *) |
| 49 | (* the following is only for declarations *) |
| 50 | safe_for_multi_decls : bool; |
| 51 | (* isos relevant to the term; ultimately only used for rule_elems *) |
| 52 | iso_info : (string*anything) list } |
| 53 | |
| 54 | and 'a befaft = |
| 55 | BEFORE of 'a list list * count |
| 56 | | AFTER of 'a list list * count |
| 57 | | BEFOREAFTER of 'a list list * 'a list list * count |
| 58 | | NOTHING |
| 59 | |
| 60 | and 'a replacement = REPLACEMENT of 'a list list * count | NOREPLACEMENT |
| 61 | |
| 62 | and 'a mcode = 'a * info * mcodekind * meta_pos list (* pos variables *) |
| 63 | (* pos is an offset indicating where in the C code the mcodekind has an |
| 64 | effect *) |
| 65 | and adjacency = ALLMINUS | ADJ of int |
| 66 | and mcodekind = |
| 67 | MINUS of pos * int list * adjacency * anything replacement |
| 68 | | CONTEXT of pos * anything befaft |
| 69 | | PLUS of count |
| 70 | and count = ONE (* + *) | MANY (* ++ *) |
| 71 | and fixpos = |
| 72 | Real of int (* charpos *) | Virt of int * int (* charpos + offset *) |
| 73 | and pos = NoPos | DontCarePos | FixPos of (fixpos * fixpos) |
| 74 | |
| 75 | and dots_bef_aft = |
| 76 | NoDots |
| 77 | | AddingBetweenDots of statement * int (*index of let var*) |
| 78 | | DroppingBetweenDots of statement * int (*index of let var*) |
| 79 | |
| 80 | and inherited = Type_cocci.inherited |
| 81 | and keep_binding = Type_cocci.keep_binding |
| 82 | and multi = bool (*true if a nest is one or more, false if it is zero or more*) |
| 83 | |
| 84 | and end_info = |
| 85 | meta_name list (*free vars*) * (meta_name * seed) list (*fresh*) * |
| 86 | meta_name list (*inherited vars*) * mcodekind |
| 87 | |
| 88 | (* --------------------------------------------------------------------- *) |
| 89 | (* Metavariables *) |
| 90 | |
| 91 | and arity = UNIQUE | OPT | MULTI | NONE |
| 92 | |
| 93 | and metavar = |
| 94 | MetaMetaDecl of arity * meta_name (* name *) |
| 95 | | MetaIdDecl of arity * meta_name (* name *) |
| 96 | | MetaFreshIdDecl of meta_name (* name *) * seed (* seed *) |
| 97 | | MetaTypeDecl of arity * meta_name (* name *) |
| 98 | | MetaInitDecl of arity * meta_name (* name *) |
| 99 | | MetaInitListDecl of arity * meta_name (* name *) * list_len (*len*) |
| 100 | | MetaListlenDecl of meta_name (* name *) |
| 101 | | MetaParamDecl of arity * meta_name (* name *) |
| 102 | | MetaParamListDecl of arity * meta_name (*name*) * list_len (*len*) |
| 103 | | MetaConstDecl of |
| 104 | arity * meta_name (* name *) * Type_cocci.typeC list option |
| 105 | | MetaErrDecl of arity * meta_name (* name *) |
| 106 | | MetaExpDecl of |
| 107 | arity * meta_name (* name *) * Type_cocci.typeC list option |
| 108 | | MetaIdExpDecl of |
| 109 | arity * meta_name (* name *) * Type_cocci.typeC list option |
| 110 | | MetaLocalIdExpDecl of |
| 111 | arity * meta_name (* name *) * Type_cocci.typeC list option |
| 112 | | MetaExpListDecl of arity * meta_name (*name*) * list_len (*len*) |
| 113 | | MetaDeclDecl of arity * meta_name (* name *) |
| 114 | | MetaFieldDecl of arity * meta_name (* name *) |
| 115 | | MetaFieldListDecl of arity * meta_name (* name *) * list_len (*len*) |
| 116 | | MetaStmDecl of arity * meta_name (* name *) |
| 117 | | MetaStmListDecl of arity * meta_name (* name *) |
| 118 | | MetaFuncDecl of arity * meta_name (* name *) |
| 119 | | MetaLocalFuncDecl of arity * meta_name (* name *) |
| 120 | | MetaPosDecl of arity * meta_name (* name *) |
| 121 | | MetaDeclarerDecl of arity * meta_name (* name *) |
| 122 | | MetaIteratorDecl of arity * meta_name (* name *) |
| 123 | |
| 124 | and list_len = AnyLen | MetaLen of meta_name | CstLen of int |
| 125 | |
| 126 | and seed = NoVal | StringSeed of string | ListSeed of seed_elem list |
| 127 | and seed_elem = SeedString of string | SeedId of meta_name |
| 128 | |
| 129 | (* --------------------------------------------------------------------- *) |
| 130 | (* --------------------------------------------------------------------- *) |
| 131 | (* Dots *) |
| 132 | |
| 133 | and 'a base_dots = |
| 134 | DOTS of 'a list |
| 135 | | CIRCLES of 'a list |
| 136 | | STARS of 'a list |
| 137 | |
| 138 | and 'a dots = 'a base_dots wrap |
| 139 | |
| 140 | (* --------------------------------------------------------------------- *) |
| 141 | (* Identifier *) |
| 142 | |
| 143 | and base_ident = |
| 144 | Id of string mcode |
| 145 | | MetaId of meta_name mcode * idconstraint * keep_binding * inherited |
| 146 | | MetaFunc of meta_name mcode * idconstraint * keep_binding * inherited |
| 147 | | MetaLocalFunc of meta_name mcode * idconstraint * keep_binding * inherited |
| 148 | | AsIdent of ident * ident (* as ident, always metavar *) |
| 149 | |
| 150 | | DisjId of ident list |
| 151 | | OptIdent of ident |
| 152 | | UniqueIdent of ident |
| 153 | |
| 154 | and ident = base_ident wrap |
| 155 | |
| 156 | (* --------------------------------------------------------------------- *) |
| 157 | (* Expression *) |
| 158 | |
| 159 | and base_expression = |
| 160 | Ident of ident |
| 161 | | Constant of constant mcode |
| 162 | | FunCall of expression * string mcode (* ( *) * |
| 163 | expression dots * string mcode (* ) *) |
| 164 | | Assignment of expression * assignOp mcode * expression * bool |
| 165 | | Sequence of expression * string mcode (* , *) * expression |
| 166 | | CondExpr of expression * string mcode (* ? *) * expression option * |
| 167 | string mcode (* : *) * expression |
| 168 | | Postfix of expression * fixOp mcode |
| 169 | | Infix of expression * fixOp mcode |
| 170 | | Unary of expression * unaryOp mcode |
| 171 | | Binary of expression * binaryOp mcode * expression |
| 172 | | Nested of expression * binaryOp mcode * expression |
| 173 | | ArrayAccess of expression * string mcode (* [ *) * expression * |
| 174 | string mcode (* ] *) |
| 175 | | RecordAccess of expression * string mcode (* . *) * ident |
| 176 | | RecordPtAccess of expression * string mcode (* -> *) * ident |
| 177 | | Cast of string mcode (* ( *) * fullType * string mcode (* ) *) * |
| 178 | expression |
| 179 | |
| 180 | | SizeOfExpr of string mcode (* sizeof *) * expression |
| 181 | | SizeOfType of string mcode (* sizeof *) * string mcode (* ( *) * |
| 182 | fullType * string mcode (* ) *) |
| 183 | | TypeExp of fullType |
| 184 | |
| 185 | | Paren of string mcode (* ( *) * expression * |
| 186 | string mcode (* ) *) |
| 187 | |
| 188 | | Constructor of string mcode (* ( *) * fullType * string mcode (* ) *) * |
| 189 | initialiser |
| 190 | | MetaErr of meta_name mcode * constraints * keep_binding * |
| 191 | inherited |
| 192 | | MetaExpr of meta_name mcode * constraints * keep_binding * |
| 193 | Type_cocci.typeC list option * form * inherited |
| 194 | | MetaExprList of meta_name mcode * listlen * |
| 195 | keep_binding * inherited (* only in arg lists *) |
| 196 | | AsExpr of expression * expression (* as expr, always metavar *) |
| 197 | |
| 198 | | EComma of string mcode (* only in arg lists *) |
| 199 | |
| 200 | | DisjExpr of expression list |
| 201 | | NestExpr of string mcode (* <.../<+... *) * |
| 202 | expression dots * |
| 203 | string mcode (* ...>/...+> *) * |
| 204 | expression option * multi |
| 205 | |
| 206 | (* can appear in arg lists, and also inside Nest, as in: |
| 207 | if(< ... X ... Y ...>) |
| 208 | In the following, the expression option is the WHEN *) |
| 209 | | Edots of string mcode (* ... *) * expression option |
| 210 | | Ecircles of string mcode (* ooo *) * expression option |
| 211 | | Estars of string mcode (* *** *) * expression option |
| 212 | |
| 213 | | OptExp of expression |
| 214 | | UniqueExp of expression |
| 215 | |
| 216 | and constraints = |
| 217 | NoConstraint |
| 218 | | NotIdCstrt of reconstraint |
| 219 | | NotExpCstrt of expression list |
| 220 | | SubExpCstrt of meta_name list |
| 221 | |
| 222 | (* Constraints on Meta-* Identifiers, Functions *) |
| 223 | and idconstraint = |
| 224 | IdNoConstraint |
| 225 | | IdNegIdSet of string list * meta_name list |
| 226 | | IdRegExpConstraint of reconstraint |
| 227 | |
| 228 | and reconstraint = |
| 229 | | IdRegExp of string * Regexp.regexp |
| 230 | | IdNotRegExp of string * Regexp.regexp |
| 231 | |
| 232 | and form = ANY | ID | LocalID | CONST (* form for MetaExp *) |
| 233 | |
| 234 | and expression = base_expression wrap |
| 235 | |
| 236 | and listlen = |
| 237 | MetaListLen of meta_name mcode * keep_binding * inherited |
| 238 | | CstListLen of int |
| 239 | | AnyListLen |
| 240 | |
| 241 | and unaryOp = GetRef | GetRefLabel | DeRef | UnPlus | UnMinus | Tilde | Not |
| 242 | and assignOp = SimpleAssign | OpAssign of arithOp |
| 243 | and fixOp = Dec | Inc |
| 244 | |
| 245 | and binaryOp = Arith of arithOp | Logical of logicalOp |
| 246 | and arithOp = |
| 247 | Plus | Minus | Mul | Div | Mod | DecLeft | DecRight | And | Or | Xor |
| 248 | and logicalOp = Inf | Sup | InfEq | SupEq | Eq | NotEq | AndLog | OrLog |
| 249 | |
| 250 | and constant = |
| 251 | String of string |
| 252 | | Char of string |
| 253 | | Int of string |
| 254 | | Float of string |
| 255 | |
| 256 | (* --------------------------------------------------------------------- *) |
| 257 | (* Types *) |
| 258 | |
| 259 | and base_fullType = |
| 260 | Type of bool (* true if all minus *) * |
| 261 | const_vol mcode option * typeC |
| 262 | | AsType of fullType * fullType (* as type, always metavar *) |
| 263 | | DisjType of fullType list (* only after iso *) |
| 264 | | OptType of fullType |
| 265 | | UniqueType of fullType |
| 266 | |
| 267 | and base_typeC = |
| 268 | BaseType of baseType * string mcode list (* Yoann style *) |
| 269 | | SignedT of sign mcode * typeC option |
| 270 | | Pointer of fullType * string mcode (* * *) |
| 271 | | FunctionPointer of fullType * |
| 272 | string mcode(* ( *)*string mcode(* * *)*string mcode(* ) *)* |
| 273 | string mcode (* ( *)*parameter_list*string mcode(* ) *) |
| 274 | | FunctionType of bool (* true if all minus for dropping return type *) * |
| 275 | fullType option * |
| 276 | string mcode (* ( *) * parameter_list * |
| 277 | string mcode (* ) *) |
| 278 | | Array of fullType * string mcode (* [ *) * |
| 279 | expression option * string mcode (* ] *) |
| 280 | | EnumName of string mcode (*enum*) * ident option (* name *) |
| 281 | | EnumDef of fullType (* either EnumName or metavar *) * |
| 282 | string mcode (* { *) * expression dots * string mcode (* } *) |
| 283 | | StructUnionName of structUnion mcode * ident option (* name *) |
| 284 | | StructUnionDef of fullType (* either StructUnionName or metavar *) * |
| 285 | string mcode (* { *) * declaration dots * string mcode (* } *) |
| 286 | | TypeName of string mcode |
| 287 | |
| 288 | | MetaType of meta_name mcode * keep_binding * inherited |
| 289 | |
| 290 | and fullType = base_fullType wrap |
| 291 | and typeC = base_typeC wrap |
| 292 | |
| 293 | and baseType = VoidType | CharType | ShortType | ShortIntType | IntType |
| 294 | | DoubleType | LongDoubleType | FloatType |
| 295 | | LongType | LongIntType | LongLongType | LongLongIntType |
| 296 | | SizeType | SSizeType | PtrDiffType |
| 297 | |
| 298 | and structUnion = Struct | Union |
| 299 | |
| 300 | and sign = Signed | Unsigned |
| 301 | |
| 302 | and const_vol = Const | Volatile |
| 303 | |
| 304 | (* --------------------------------------------------------------------- *) |
| 305 | (* Variable declaration *) |
| 306 | (* Even if the Cocci program specifies a list of declarations, they are |
| 307 | split out into multiple declarations of a single variable each. *) |
| 308 | |
| 309 | and base_declaration = |
| 310 | Init of storage mcode option * fullType * ident * string mcode (*=*) * |
| 311 | initialiser * string mcode (*;*) |
| 312 | | UnInit of storage mcode option * fullType * ident * string mcode (* ; *) |
| 313 | | TyDecl of fullType * string mcode (* ; *) |
| 314 | | MacroDecl of ident (* name *) * string mcode (* ( *) * |
| 315 | expression dots * string mcode (* ) *) * string mcode (* ; *) |
| 316 | | MacroDeclInit of ident (* name *) * string mcode (* ( *) * |
| 317 | expression dots * string mcode (* ) *) * string mcode (*=*) * |
| 318 | initialiser * string mcode (* ; *) |
| 319 | | Typedef of string mcode (*typedef*) * fullType * typeC * string mcode (*;*) |
| 320 | | DisjDecl of declaration list |
| 321 | | Ddots of string mcode (* ... *) * declaration option (* whencode *) |
| 322 | |
| 323 | | MetaDecl of meta_name mcode * keep_binding * inherited |
| 324 | | MetaField of meta_name mcode * keep_binding * inherited |
| 325 | | MetaFieldList of meta_name mcode * listlen * keep_binding * inherited |
| 326 | | AsDecl of declaration * declaration |
| 327 | |
| 328 | | OptDecl of declaration |
| 329 | | UniqueDecl of declaration |
| 330 | |
| 331 | and declaration = base_declaration wrap |
| 332 | |
| 333 | (* --------------------------------------------------------------------- *) |
| 334 | (* Initializers *) |
| 335 | |
| 336 | and base_initialiser = |
| 337 | MetaInit of meta_name mcode * keep_binding * inherited |
| 338 | | MetaInitList of meta_name mcode * listlen * keep_binding * inherited |
| 339 | | AsInit of initialiser * initialiser (* as init, always metavar *) |
| 340 | | InitExpr of expression |
| 341 | | ArInitList of string mcode (*{*) * initialiser dots * string mcode (*}*) |
| 342 | | StrInitList of bool (* true if all are - *) * |
| 343 | string mcode (*{*) * initialiser list * string mcode (*}*) * |
| 344 | initialiser list (* whencode: elements that shouldn't appear in init *) |
| 345 | | InitGccExt of |
| 346 | designator list (* name *) * string mcode (*=*) * |
| 347 | initialiser (* gccext: *) |
| 348 | | InitGccName of ident (* name *) * string mcode (*:*) * |
| 349 | initialiser |
| 350 | | IComma of string mcode (* , *) |
| 351 | | Idots of string mcode (* ... *) * initialiser option (* whencode *) |
| 352 | | OptIni of initialiser |
| 353 | | UniqueIni of initialiser |
| 354 | |
| 355 | and designator = |
| 356 | DesignatorField of string mcode (* . *) * ident |
| 357 | | DesignatorIndex of string mcode (* [ *) * expression * string mcode (* ] *) |
| 358 | | DesignatorRange of |
| 359 | string mcode (* [ *) * expression * string mcode (* ... *) * |
| 360 | expression * string mcode (* ] *) |
| 361 | |
| 362 | and initialiser = base_initialiser wrap |
| 363 | |
| 364 | (* --------------------------------------------------------------------- *) |
| 365 | (* Parameter *) |
| 366 | |
| 367 | and base_parameterTypeDef = |
| 368 | VoidParam of fullType |
| 369 | | Param of fullType * ident option |
| 370 | |
| 371 | | MetaParam of meta_name mcode * keep_binding * inherited |
| 372 | | MetaParamList of meta_name mcode * listlen * keep_binding * inherited |
| 373 | |
| 374 | | PComma of string mcode |
| 375 | |
| 376 | | Pdots of string mcode (* ... *) |
| 377 | | Pcircles of string mcode (* ooo *) |
| 378 | |
| 379 | | OptParam of parameterTypeDef |
| 380 | | UniqueParam of parameterTypeDef |
| 381 | |
| 382 | and parameterTypeDef = base_parameterTypeDef wrap |
| 383 | |
| 384 | and parameter_list = parameterTypeDef dots |
| 385 | |
| 386 | (* --------------------------------------------------------------------- *) |
| 387 | (* #define Parameters *) |
| 388 | |
| 389 | and base_define_param = |
| 390 | DParam of ident |
| 391 | | DPComma of string mcode |
| 392 | | DPdots of string mcode (* ... *) |
| 393 | | DPcircles of string mcode (* ooo *) |
| 394 | | OptDParam of define_param |
| 395 | | UniqueDParam of define_param |
| 396 | |
| 397 | and define_param = base_define_param wrap |
| 398 | |
| 399 | and base_define_parameters = |
| 400 | NoParams |
| 401 | | DParams of string mcode(*( *) * define_param dots * string mcode(* )*) |
| 402 | |
| 403 | and define_parameters = base_define_parameters wrap |
| 404 | |
| 405 | (* --------------------------------------------------------------------- *) |
| 406 | (* positions *) |
| 407 | |
| 408 | (* PER = keep bindings separate, ANY = collect them *) |
| 409 | and meta_collect = PER | ALL |
| 410 | |
| 411 | and meta_pos = |
| 412 | MetaPos of meta_name mcode * meta_name list * |
| 413 | meta_collect * keep_binding * inherited |
| 414 | |
| 415 | (* --------------------------------------------------------------------- *) |
| 416 | (* Function declaration *) |
| 417 | |
| 418 | and storage = Static | Auto | Register | Extern |
| 419 | |
| 420 | (* --------------------------------------------------------------------- *) |
| 421 | (* Top-level code *) |
| 422 | |
| 423 | and base_rule_elem = |
| 424 | FunHeader of mcodekind (* before the function header *) * |
| 425 | bool (* true if all minus, for dropping static, etc *) * |
| 426 | fninfo list * ident (* name *) * |
| 427 | string mcode (* ( *) * parameter_list * |
| 428 | string mcode (* ) *) |
| 429 | | Decl of mcodekind (* before the decl *) * |
| 430 | bool (* true if all minus *) * declaration |
| 431 | |
| 432 | | SeqStart of string mcode (* { *) |
| 433 | | SeqEnd of string mcode (* } *) |
| 434 | |
| 435 | | ExprStatement of expression option * string mcode (*;*) |
| 436 | | IfHeader of string mcode (* if *) * string mcode (* ( *) * |
| 437 | expression * string mcode (* ) *) |
| 438 | | Else of string mcode (* else *) |
| 439 | | WhileHeader of string mcode (* while *) * string mcode (* ( *) * |
| 440 | expression * string mcode (* ) *) |
| 441 | | DoHeader of string mcode (* do *) |
| 442 | | WhileTail of string mcode (* while *) * string mcode (* ( *) * |
| 443 | expression * string mcode (* ) *) * |
| 444 | string mcode (* ; *) |
| 445 | | ForHeader of string mcode (* for *) * string mcode (* ( *) * |
| 446 | forinfo * |
| 447 | expression option * string mcode (*;*) * |
| 448 | expression option * string mcode (* ) *) |
| 449 | | IteratorHeader of ident (* name *) * string mcode (* ( *) * |
| 450 | expression dots * string mcode (* ) *) |
| 451 | | SwitchHeader of string mcode (* switch *) * string mcode (* ( *) * |
| 452 | expression * string mcode (* ) *) |
| 453 | | Break of string mcode (* break *) * string mcode (* ; *) |
| 454 | | Continue of string mcode (* continue *) * string mcode (* ; *) |
| 455 | | Label of ident * string mcode (* : *) |
| 456 | | Goto of string mcode (* goto *) * ident * string mcode (* ; *) |
| 457 | | Return of string mcode (* return *) * string mcode (* ; *) |
| 458 | | ReturnExpr of string mcode (* return *) * expression * |
| 459 | string mcode (* ; *) |
| 460 | |
| 461 | | MetaRuleElem of meta_name mcode * keep_binding * inherited |
| 462 | | MetaStmt of meta_name mcode * keep_binding * metaStmtInfo * |
| 463 | inherited |
| 464 | | MetaStmtList of meta_name mcode * keep_binding * inherited |
| 465 | |
| 466 | | Exp of expression |
| 467 | | TopExp of expression (* for macros body *) |
| 468 | | Ty of fullType (* only at top level *) |
| 469 | | TopInit of initialiser (* only at top level *) |
| 470 | | Include of string mcode (*#include*) * inc_file mcode (*file *) |
| 471 | | Undef of string mcode (* #define *) * ident (* name *) |
| 472 | | DefineHeader of string mcode (* #define *) * ident (* name *) * |
| 473 | define_parameters (*params*) |
| 474 | | Case of string mcode (* case *) * expression * string mcode (*:*) |
| 475 | | Default of string mcode (* default *) * string mcode (*:*) |
| 476 | | DisjRuleElem of rule_elem list |
| 477 | |
| 478 | and forinfo = |
| 479 | ForExp of expression option * string mcode (*;*) |
| 480 | | ForDecl of mcodekind (* before the decl *) * |
| 481 | bool (* true if all minus *) * declaration |
| 482 | |
| 483 | and fninfo = |
| 484 | FStorage of storage mcode |
| 485 | | FType of fullType |
| 486 | | FInline of string mcode |
| 487 | | FAttr of string mcode |
| 488 | |
| 489 | and metaStmtInfo = |
| 490 | NotSequencible | SequencibleAfterDots of dots_whencode list | Sequencible |
| 491 | |
| 492 | and rule_elem = base_rule_elem wrap |
| 493 | |
| 494 | and base_statement = |
| 495 | Seq of rule_elem (* { *) * |
| 496 | statement dots * rule_elem (* } *) |
| 497 | | IfThen of rule_elem (* header *) * statement * end_info |
| 498 | | IfThenElse of rule_elem (* header *) * statement * |
| 499 | rule_elem (* else *) * statement * end_info |
| 500 | | While of rule_elem (* header *) * statement * end_info |
| 501 | | Do of rule_elem (* do *) * statement * rule_elem (* tail *) |
| 502 | | For of rule_elem (* header *) * statement * end_info |
| 503 | | Iterator of rule_elem (* header *) * statement * end_info (*enditer*) |
| 504 | | Switch of rule_elem (* header *) * rule_elem (* { *) * |
| 505 | statement (*decl*) dots * case_line list * rule_elem(*}*) |
| 506 | | Atomic of rule_elem |
| 507 | | Disj of statement dots list |
| 508 | | Nest of string mcode (* <.../<+... *) * statement dots * |
| 509 | string mcode (* ...>/...+> *) * |
| 510 | (statement dots,statement) whencode list * multi * |
| 511 | dots_whencode list * dots_whencode list |
| 512 | | FunDecl of rule_elem (* header *) * rule_elem (* { *) * |
| 513 | statement dots * rule_elem (* } *) |
| 514 | | Define of rule_elem (* header *) * statement dots |
| 515 | | AsStmt of statement * statement (* as statement, always metavar *) |
| 516 | | Dots of string mcode (* ... *) * |
| 517 | (statement dots,statement) whencode list * |
| 518 | dots_whencode list * dots_whencode list |
| 519 | | Circles of string mcode (* ooo *) * |
| 520 | (statement dots,statement) whencode list * |
| 521 | dots_whencode list * dots_whencode list |
| 522 | | Stars of string mcode (* *** *) * |
| 523 | (statement dots,statement) whencode list * |
| 524 | dots_whencode list * dots_whencode list |
| 525 | | OptStm of statement |
| 526 | | UniqueStm of statement |
| 527 | |
| 528 | and ('a,'b) whencode = |
| 529 | WhenNot of 'a |
| 530 | | WhenAlways of 'b |
| 531 | | WhenModifier of when_modifier |
| 532 | | WhenNotTrue of rule_elem |
| 533 | | WhenNotFalse of rule_elem |
| 534 | |
| 535 | and when_modifier = |
| 536 | WhenAny |
| 537 | | WhenStrict |
| 538 | | WhenForall |
| 539 | | WhenExists |
| 540 | |
| 541 | and dots_whencode = |
| 542 | WParen of rule_elem * meta_name (*pren_var*) |
| 543 | | Other of statement |
| 544 | | Other_dots of statement dots |
| 545 | |
| 546 | and statement = base_statement wrap |
| 547 | |
| 548 | and base_case_line = |
| 549 | CaseLine of rule_elem (* case/default header *) * statement dots |
| 550 | | OptCase of case_line |
| 551 | |
| 552 | and case_line = base_case_line wrap |
| 553 | |
| 554 | and inc_file = |
| 555 | Local of inc_elem list |
| 556 | | NonLocal of inc_elem list |
| 557 | |
| 558 | and inc_elem = |
| 559 | IncPath of string |
| 560 | | IncDots |
| 561 | |
| 562 | and base_top_level = |
| 563 | NONDECL of statement (* cannot match all of a top-level declaration *) |
| 564 | | CODE of statement dots |
| 565 | | FILEINFO of string mcode (* old file *) * string mcode (* new file *) |
| 566 | | ERRORWORDS of expression list |
| 567 | |
| 568 | and top_level = base_top_level wrap |
| 569 | |
| 570 | and rulename = |
| 571 | CocciRulename of string option * dependency * string list * string list * |
| 572 | exists * bool |
| 573 | (* true if the whole thing is an expression *) |
| 574 | | GeneratedRulename of string option * dependency * |
| 575 | string list * string list * exists * bool |
| 576 | (* true if the whole thing is an expression *) |
| 577 | | ScriptRulename of string option (* name *) * string (* language *) * |
| 578 | dependency |
| 579 | | InitialScriptRulename of string option (* name *) * string (* language *) * |
| 580 | dependency |
| 581 | | FinalScriptRulename of string option (* name *) * string (* language *) * |
| 582 | dependency |
| 583 | |
| 584 | and ruletype = Normal | Generated |
| 585 | |
| 586 | and rule = |
| 587 | CocciRule of string (* name *) * |
| 588 | (dependency * string list (* dropped isos *) * exists) * |
| 589 | top_level list * bool list (* true if generates an exp *) * ruletype |
| 590 | | ScriptRule of string (* name *) * |
| 591 | string * dependency * |
| 592 | (script_meta_name * meta_name * metavar) list * |
| 593 | meta_name list (*script vars*) * string |
| 594 | | InitialScriptRule of string (* name *) * |
| 595 | string * dependency * string |
| 596 | | FinalScriptRule of string (* name *) * |
| 597 | string * dependency * string |
| 598 | |
| 599 | and script_meta_name = string option (*string*) * string option (*ast*) |
| 600 | |
| 601 | and dependency = |
| 602 | Dep of string (* rule applies for the current binding *) |
| 603 | | AntiDep of string (* rule doesn't apply for the current binding *) |
| 604 | | EverDep of string (* rule applies for some binding *) |
| 605 | | NeverDep of string (* rule never applies for any binding *) |
| 606 | | AndDep of dependency * dependency |
| 607 | | OrDep of dependency * dependency |
| 608 | | NoDep | FailDep |
| 609 | |
| 610 | and rule_with_metavars = metavar list * rule |
| 611 | |
| 612 | and anything = |
| 613 | FullTypeTag of fullType |
| 614 | | BaseTypeTag of baseType |
| 615 | | StructUnionTag of structUnion |
| 616 | | SignTag of sign |
| 617 | | IdentTag of ident |
| 618 | | ExpressionTag of expression |
| 619 | | ConstantTag of constant |
| 620 | | UnaryOpTag of unaryOp |
| 621 | | AssignOpTag of assignOp |
| 622 | | FixOpTag of fixOp |
| 623 | | BinaryOpTag of binaryOp |
| 624 | | ArithOpTag of arithOp |
| 625 | | LogicalOpTag of logicalOp |
| 626 | | DeclarationTag of declaration |
| 627 | | InitTag of initialiser |
| 628 | | StorageTag of storage |
| 629 | | IncFileTag of inc_file |
| 630 | | Rule_elemTag of rule_elem |
| 631 | | StatementTag of statement |
| 632 | | ForInfoTag of forinfo |
| 633 | | CaseLineTag of case_line |
| 634 | | ConstVolTag of const_vol |
| 635 | | Token of string * info option |
| 636 | | Pragma of added_string list |
| 637 | | Code of top_level |
| 638 | | ExprDotsTag of expression dots |
| 639 | | ParamDotsTag of parameterTypeDef dots |
| 640 | | StmtDotsTag of statement dots |
| 641 | | DeclDotsTag of declaration dots |
| 642 | | TypeCTag of typeC |
| 643 | | ParamTag of parameterTypeDef |
| 644 | | SgrepStartTag of string |
| 645 | | SgrepEndTag of string |
| 646 | |
| 647 | (* --------------------------------------------------------------------- *) |
| 648 | |
| 649 | and exists = Exists | Forall | Undetermined |
| 650 | |
| 651 | (* --------------------------------------------------------------------- *) |
| 652 | |
| 653 | val mkToken : string -> anything |
| 654 | |
| 655 | val undots : 'a dots -> 'a list |
| 656 | |
| 657 | val lub_count : count -> count -> count |
| 658 | |
| 659 | (* --------------------------------------------------------------------- *) |
| 660 | |
| 661 | val rewrap : 'a wrap -> 'b -> 'b wrap |
| 662 | val rewrap_mcode : 'a mcode -> 'a -> 'a mcode |
| 663 | val unwrap : 'a wrap -> 'a |
| 664 | val unwrap_mcode : 'a mcode -> 'a |
| 665 | val get_mcodekind : 'a mcode -> mcodekind |
| 666 | val get_line : 'a wrap -> line |
| 667 | val get_mcode_line : 'a mcode -> line |
| 668 | val get_mcode_col : 'a mcode -> int |
| 669 | val get_fvs : 'a wrap -> meta_name list |
| 670 | val get_wcfvs : ('a wrap,'b wrap) whencode list -> meta_name list |
| 671 | val set_fvs : meta_name list -> 'a wrap -> 'a wrap |
| 672 | val get_mfvs : 'a wrap -> meta_name list |
| 673 | val set_mfvs : meta_name list -> 'a wrap -> 'a wrap |
| 674 | val get_fresh : 'a wrap -> (meta_name * seed) list |
| 675 | val get_inherited : 'a wrap -> meta_name list |
| 676 | val get_saved : 'a wrap -> meta_name list |
| 677 | val get_dots_bef_aft : statement -> dots_bef_aft |
| 678 | val set_dots_bef_aft : dots_bef_aft -> statement -> statement |
| 679 | val get_pos : 'a wrap -> meta_name mcode option |
| 680 | val set_pos : 'a wrap -> meta_name mcode option -> 'a wrap |
| 681 | val get_test_exp : 'a wrap -> bool |
| 682 | val set_test_exp : expression -> expression |
| 683 | val get_safe_decl : 'a wrap -> bool |
| 684 | val get_isos : 'a wrap -> (string*anything) list |
| 685 | val set_isos : 'a wrap -> (string*anything) list -> 'a wrap |
| 686 | val get_pos_var : 'a mcode -> meta_pos list |
| 687 | val set_pos_var : meta_pos list -> 'a mcode -> 'a mcode |
| 688 | val drop_pos : 'a mcode -> 'a mcode |
| 689 | |
| 690 | val get_meta_name : metavar -> meta_name |
| 691 | |
| 692 | val tag2c : anything -> string |
| 693 | |
| 694 | val no_info : info |
| 695 | |
| 696 | val make_meta_rule_elem : |
| 697 | string -> mcodekind -> |
| 698 | (meta_name list * (meta_name * seed) list * meta_name list) -> |
| 699 | rule_elem |
| 700 | |
| 701 | val make_meta_decl : |
| 702 | string -> mcodekind -> |
| 703 | (meta_name list * (meta_name * seed) list * meta_name list) -> |
| 704 | declaration |
| 705 | |
| 706 | val make_term : 'a -> 'a wrap |
| 707 | val make_inherited_term : 'a -> meta_name list (* inherited vars *) -> 'a wrap |
| 708 | val make_mcode : 'a -> 'a mcode |
| 709 | |
| 710 | val equal_pos : fixpos -> fixpos -> bool |