-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9daf58e
commit a6458a4
Showing
2 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
# Deep Dive into ast-grep's Match Algorithm | ||
|
||
In descending order of strict-ness | ||
|
||
* CST: all nodes are matched | ||
* Smart: all nodes except source trivial nodes are matched. | ||
* Significant: only significant nodes are matched | ||
* AST: only ast nodes are matched | ||
* Lenient: ast-nodes excluding comments are matched | ||
By default, ast-grep uses a smart strategy to match pattern against the AST node. All nodes in the pattern must be matched, but it will skip unnamed nodes in target code. | ||
|
||
Currently ast-grep only supports Smart. | ||
For the definition of __*named*__ and __*unnamed*__ nodes, please refer to the [core concepts](/advanced/core-concepts.html) doc. | ||
|
||
* `cst`: All nodes in the pattern and target code must be matched. No node is skipped. | ||
* `smart`: All nodes in the pattern must be matched, but it will skip unnamed nodes in target code. This is the default behavior. | ||
* `ast`: Only named AST nodes in both pattern and target code are matched. All unnamed nodes are skipped. | ||
* `relaxed`: Named AST nodes in both pattern and target code are matched. Comments and unnamed nodes are ignored. | ||
* `signature`: Only named AST nodes' kinds are matched. Comments, unnamed nodes and text are ignored. | ||
|
||
Currently ast-grep only supports Smart. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters