Skip to content

Commit

Permalink
fix: rename lenient to relaxed
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Jun 25, 2024
1 parent 9daf58e commit a6458a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions website/advanced/match-algorithm.md
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.
2 changes: 1 addition & 1 deletion website/guide/rule-config/atomic-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ const foo = () => {
The first step to compose a rule is to find the target. In this case, we can first use kind: `arrow_function` to find function node. Then we can use other rules to filter candidate nodes that does have return type.

Another trick to write cleaner rule is to use sub-rules as fields.
Please refer to [composite rule](/guide/rule-config/composite-rule.html#combine-different-rules-as-fields) for more details.
Please refer to [composite rule](/guide/rule-config/composite-rule.html#combine-different-rules-as-fields) for more details.

0 comments on commit a6458a4

Please sign in to comment.