Playground | ast-grep (original) (raw)
SG playground: Write Code to Match Code. Manual 🔗
ast-grepis a AST-based tool to search code by pattern code. Think it as your old-friendgrepbut it matches AST node instead of text.- Write pattern as if write ordinary code. It will match all code that has the same syntactical structure.
- You can use
$sign + upper case letters as wildcard, e.g.$MATCH, to match any single AST node. Think it as REGEX dot., except it is not textual. - You can use
$$$to match multiple AST nodes.