Skip to content

Commit dfdc798

Browse files
committed
doc: Explain negated fields (! prefix) in query patterns
1 parent 5e3192a commit dfdc798

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/emacs-tree-sitter.org

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ Certain node types assign unique *field names* to specific child nodes. Within a
293293
arguments: (arguments) @function.args)
294294
#+end_src
295295

296+
A symbol prefixed with the character ~!~ denotes a *negated field*, which requires that the pattern matches only nodes that lack the specified field.
297+
#+begin_src scheme
298+
;; Match non-generic struct definitions.
299+
(struct_item
300+
name: (type_identifier) @struct_name
301+
!type_parameters)
302+
#+end_src
303+
296304
*** Groups and Predicates
297305
# Grouping Sibling Nodes ("group forms").
298306
A *group* form is a list form whose first element is a node form. It is used to denote a sequence of sibling nodes, and to group predicate forms with node forms.

0 commit comments

Comments
 (0)