Update parse-tree-patterns.md (#665)

* Update parse-tree-patterns.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update docs/contributing/parse-tree-patterns.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
This commit is contained in:
AndrewDant 2022-05-31 09:59:03 -04:00 committed by GitHub
parent ca0c11f421
commit 358cf953cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,15 +6,16 @@ We have a small domain-specific language that we use to define patterns to look
`GRAND_PARENT_TYPE.*.CHILD_TYPE[FIELD]!?`
| Syntax | Description |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| TYPE | Match node type<br/>`node.type` |
| Dot operator(`.`) | Type hierarchy between parent and child |
| Wildcard op(`*`) | Match any type |
| Negation op(`~`) | Match any type other than what is specified after `~` |
| Important op(`!`) | Use this node as result instead of parent.<br/>By default the leftmost/top node is used |
| Optional op(`?`) | Node is optional. Will match if available. |
| Field op(`[field]`) | Get child field node for resulting node.<br/>Only evaluated on the resulting node at the end.<br/>`node.childForFieldName(field)` |
| Syntax | Description |
| ------------------- | --------------------------------------------------------------------------------------- |
| TYPE | Match node type<br/>`node.type` |
| Dot operator(`.`) | Type hierarchy between parent and child |
| Wildcard op(`*`) | Match any type |
| Negation op(`~`) | Match any type other than what is specified after `~` |
| Important op(`!`) | Use this node as result instead of parent.<br/>By default the leftmost/top node is used |
| Optional op(`?`) | Node is optional. Will match if available. |
| Field op(`[field]`) | Return child node at given field.<br/>`node.childForFieldName(field)` |
| Index op(`[n]`) | Return nth named child node. |
## Multiple patterns