mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:36:22 -04:00
docs: specify valid children of supertype nodes
This commit is contained in:
parent
15da6ddf12
commit
cce7768b27
|
|
@ -108,6 +108,10 @@ In Tree-sitter grammars, there are usually certain rules that represent abstract
|
|||
"type", "declaration"). In the `grammar.js` file, these are often written as [hidden rules][hidden rules]
|
||||
whose definition is a simple [`choice`][grammar dsl] where each member is just a single symbol.
|
||||
|
||||
Each member of that `choice` must resolve to a single _visible_ node. A named rule always satisfies this, even when its
|
||||
own definition has several children. A [hidden rule][hidden rules] is inlined into its parent, so a hidden member whose
|
||||
definition can produce more than one node is not permitted in this position.
|
||||
|
||||
Normally, hidden rules are not mentioned in the node types file, since they don't appear in the syntax tree. But if you
|
||||
add a hidden rule to the grammar's [`supertypes` list][grammar dsl], then it _will_ show up in the node types file, with
|
||||
the following special entry:
|
||||
|
|
|
|||
Loading…
Reference in a new issue