123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(* Yoann Padioleau
*
* Copyright (C) 2019 r2c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library 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 file
* license.txt for more details.
*)openCommon(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*****************************************************************************)(* Types *)(*****************************************************************************)(* mostly a copy-paste of metavars_fuzzy.ml and metavars_js.ml *)(* less: could want to remember the position in the pattern of the metavar
* for error reporting on pattern itself? so use a 'string Ast_generic.wrap'?
*)typemvar=stringtypemetavars_binding=(mvar,Ast_generic.any)Common.assoc(* ex: $X *)letmetavar_regexp_string="^\\(\\$[A-Z]\\)$"(* ex: $x *)letmetavar_variable_regexp_string="^\\(\\$[a-z]\\)$"(*
* Hacks abusing existing constructs to encode extra constructions.
* One day we will have a pattern_ast.ml that mimics mostly
* ast.ml and extends it with special sgrep constructs.
*)letis_metavar_names=s=~metavar_regexp_stringletis_metavar_variable_names=s=~metavar_variable_regexp_string