Skip to content

Commit

Permalink
doc: add named/unnnamed explanation
Browse files Browse the repository at this point in the history
fix #57
  • Loading branch information
HerringtonDarkholme committed Jun 6, 2023
1 parent e78c4d4 commit 2a57f4e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion website/guide/pattern-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ Note in the example above, even if two meta variables have the same name `$_FUNC

:::info Why use non-capturing match?
This is a useful trick to micro-optimize pattern matching speed, since we don't need to create a [HashMap](https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html) for bookkeeping.
:::
:::

## Capture unnamed node
A meta variable pattern `$META` will capture [named nodes](/advanced/core-concepts.html#named-vs-unnamed) by default.
To capture [unnamed nodes](/advanced/core-concepts.html#named-vs-unnamed), you can use double dollar sign `$$VAR`.

Namedness is an advanced topic in [Tree-sitter](https://tree-sitter.github.io/tree-sitter/using-parsers#named-vs-anonymous-nodes). You can read this [in-depth guide](/advanced/core-concepts.html) for more background.

0 comments on commit 2a57f4e

Please sign in to comment.