Get another reference to the given language.
Free any dynamically-allocated resources for this language, if
this is the last reference.
Get the number of distinct field names in the language.
Get the numerical id for the given field name string.
Get the field name string for the given numerical id.
Check if the language came from a Wasm module. If so, then in order to use
this language with a Parser, that parser must have a Wasm store assigned.
Get the next parse state. Combine this with lookahead iterators to generate
completion suggestions or valid symbols in error nodes. Use
ts_node_grammar_symbol
for valid symbols.
Get the number of valid states in this language.
Get the number of distinct node types in the language.
Get the numerical id for the given node type string.
Get a node type string for the given numerical id.
Check whether the given node type id belongs to named nodes, anonymous nodes,
or a hidden nodes.
Get the ABI version number for this language. This version number is used
to ensure that languages were generated by a compatible version of
Tree-sitter.
Get the current symbol of the lookahead iterator;
Get the current symbol type of the lookahead iterator as a null terminated
string.
Delete a lookahead iterator freeing all the memory used.
Get the current language of the lookahead iterator.
Create a new lookahead iterator for the given language and parse state.
Advance the lookahead iterator to the next symbol.
Reset the lookahead iterator.
Reset the lookahead iterator to another state.
Get the node’s child at the given index, where zero represents the first
child.
Get the node’s child with the given numerical field id.
Get the node’s child with the given field name.
@deprecated use [ts_node_contains_descendant
] instead, this will be removed in 0.25
Get the node’s number of children.
Get the node that contains descendant
.
Get the node’s number of descendants, including one for the node itself.
Get the smallest node within this node that spans the given range of bytes
or (row, column) positions.
Edit the node to keep it in-sync with source code that has been edited.
Get the node’s end byte.
Get the node’s end position in terms of rows and columns.
Check if two nodes are identical.
Get the field name for node’s child at the given index, where zero represents
the first child. Returns NULL, if no field is found.
Get the field name for node’s named child at the given index, where zero
represents the first named child. Returns NULL, if no field is found.
Get the node’s first child that extends beyond the given byte offset.
Get the node’s first named child that extends beyond the given byte offset.
Get the node’s type as it appears in the grammar ignoring aliases as a
null-terminated string.
Check if a syntax node has been edited.
Check if the node is a syntax error or contains any syntax errors.
Check if the node is a syntax error.
Check if the node is extra. Extra nodes represent things like comments,
which are not required the grammar, but can appear anywhere.
Check if the node is missing. Missing nodes are inserted by the parser in
order to recover from certain kinds of syntax errors.
Check if the node is named. Named nodes correspond to named rules in the
grammar, whereas anonymous nodes correspond to string literals in the
grammar.
Get the node’s language.
Get the node’s named child at the given index.
Get the node’s number of named children.
Get the smallest named node within this node that spans the given range of
bytes or (row, column) positions.
Get the node’s next / previous named sibling.
Get the parse state after this node.
Get the node’s next / previous sibling.
Get this node’s parse state.
Get the node’s start byte.
Get the node’s start position in terms of rows and columns.
Get an S-expression representing the node as a string.
Get the node’s type as a numerical id.
Get the node’s type as a null-terminated string.
Get the parser’s current cancellation flag pointer.
Delete the parser, freeing all of the memory that it used.
Get the ranges of text that the parser will include when parsing.
Get the parser’s current language.
Get the parser’s current logger.
Create a new parser.
Use the parser to parse some source code and create a syntax tree.
Use the parser to parse some source code stored in one contiguous buffer.
The first two parameters are the same as in the
ts_parser_parse
function
above. The second two parameters indicate the location of the buffer and its
length in bytes.
Use the parser to parse some source code stored in one contiguous buffer with
a given encoding. The first four parameters work the same as in the
ts_parser_parse_string
method above. The final parameter indicates whether
the text is encoded as UTF8 or UTF16.
Set the file descriptor to which the parser should write debugging graphs
during parsing. The graphs are formatted in the DOT language. You may want
to pipe these graphs directly to a dot(1)
process in order to generate
SVG output. You can turn off this logging by passing a negative number.
Instruct the parser to start the next parse from the beginning.
Set the parser’s current cancellation flag pointer.
Set the ranges of text that the parser should include when parsing.
Set the language that the parser should use for parsing.
Set the logger that a parser should use during parsing.
Set the maximum duration in microseconds that parsing should be allowed to
take before halting.
Assign the given Wasm store to the parser. A parser must have a Wasm store
in order to use Wasm languages.
Remove the parser’s current Wasm store and return it. This returns NULL if
the parser doesn’t have a Wasm store.
Get the duration in microseconds that parsing is allowed to take.
Get the name and length of one of the query’s captures, or one of the
query’s string literals. Each capture and string is associated with a
numeric id based on the order that it appeared in the query’s source.
Get the quantifier of the query’s captures. Each capture is * associated
with a numeric id based on the order that it appeared in the query’s source.
Delete a query cursor, freeing all of the memory that it used.
Manage the maximum number of in-progress matches allowed by this query
cursor.
Start running a given query on a given node.
Create a new cursor for executing a given query.
Advance to the next capture of the currently running query.
Advance to the next match of the currently running query.
Set the range of bytes or (row, column) positions in which the query
will be executed.
Set the maximum start depth for a query cursor.
Set the maximum duration in microseconds that query execution should be allowed to
take before halting.
Get the duration in microseconds that query execution is allowed to take.
Delete a query, freeing all of the memory that it used.
Disable a certain capture within a query.
Disable a certain pattern within a query.
Get the byte offset where the given pattern ends in the query’s source.
Create a new query from a string containing one or more S-expression
patterns. The query is associated with a particular language, and can
only be run on syntax nodes parsed with that language.
Get the number of patterns, captures, or string literals in the query.
Get all of the predicates for the given pattern in the query.
Get the byte offset where the given pattern starts in the query’s source.
Set the allocation functions used by the library.
Create a shallow copy of the syntax tree. This is very fast.
Get the depth of the cursor’s current node relative to the original
node that the cursor was constructed with.
Get the index of the cursor’s current node out of all of the
descendants of the original node that the cursor was constructed with.
Get the field id of the tree cursor’s current node.
Get the field name of the tree cursor’s current node.
Get the tree cursor’s current node.
Delete a tree cursor, freeing all of the memory that it used.
Move the cursor to the node that is the nth descendant of
the original node that the cursor was constructed with, where
zero represents the original node itself.
Move the cursor to the first child of its current node.
Move the cursor to the first child of its current node that extends beyond
the given byte offset or point.
Move the cursor to the last child of its current node.
Move the cursor to the next sibling of its current node.
Move the cursor to the parent of its current node.
Move the cursor to the previous sibling of its current node.
Create a new tree cursor starting from the given node.
Re-initialize a tree cursor to start at the original node that the cursor was
constructed with.
Re-initialize a tree cursor to the same position as another cursor.
Delete the syntax tree, freeing all of the memory that it used.
Edit the syntax tree to keep it in sync with source code that has been
edited.
Compare an old edited syntax tree to a new syntax tree representing the same
document, returning an array of ranges whose syntactic structure has changed.
Get the array of included ranges that was used to parse the syntax tree.
Get the language that was used to parse the syntax tree.
Write a DOT graph describing the syntax tree to the given file.
Get the root node of the syntax tree.
Get the root node of the syntax tree, but with its position
shifted forward by the given offset.
Free the memory associated with the given Wasm store.
Get the number of languages instantiated in the given wasm store.
Create a language from a buffer of Wasm. The resulting language behaves
like any other Tree-sitter language, except that in order to use it with
a parser, that parser must have a Wasm store. Note that the language
can be used with any Wasm store, it doesn’t need to be the same store that
was used to originally load it.
Create a Wasm store.