Module ffi

Source

Structs§

TSInput
TSInputEdit
TSLanguage
TSLogger
TSLookaheadIterator
TSNode
TSParser
TSPoint
TSQuery
TSQueryCapture
TSQueryCursor
TSQueryMatch
TSQueryPredicateStep
TSRange
TSTree
TSTreeCursor

Constants§

TREE_SITTER_LANGUAGE_VERSION
TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION
TSInputEncodingUTF8
TSInputEncodingUTF16
TSLogTypeLex
TSLogTypeParse
TSQuantifierOne
TSQuantifierOneOrMore
TSQuantifierZero
TSQuantifierZeroOrMore
TSQuantifierZeroOrOne
TSQueryErrorCapture
TSQueryErrorField
TSQueryErrorLanguage
TSQueryErrorNodeType
TSQueryErrorNone
TSQueryErrorStructure
TSQueryErrorSyntax
TSQueryPredicateStepTypeCapture
TSQueryPredicateStepTypeDone
TSQueryPredicateStepTypeString
TSSymbolTypeAnonymous
TSSymbolTypeAuxiliary
TSSymbolTypeRegular

Functions§

ts_language_field_count
Get the number of distinct field names in the language.
ts_language_field_id_for_name
Get the numerical id for the given field name string.
ts_language_field_name_for_id
Get the field name string for the given numerical id.
ts_language_next_state
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.
ts_language_state_count
Get the number of valid states in this language.
ts_language_symbol_count
Get the number of distinct node types in the language.
ts_language_symbol_for_name
Get the numerical id for the given node type string.
ts_language_symbol_name
Get a node type string for the given numerical id.
ts_language_symbol_type
Check whether the given node type id belongs to named nodes, anonymous nodes, or a hidden nodes.
ts_language_version
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.
ts_lookahead_iterator_current_symbol
Get the current symbol of the lookahead iterator;
ts_lookahead_iterator_current_symbol_name
Get the current symbol type of the lookahead iterator as a null terminated string.
ts_lookahead_iterator_delete
Delete a lookahead iterator freeing all the memory used.
ts_lookahead_iterator_language
Get the current language of the lookahead iterator.
ts_lookahead_iterator_new
Create a new lookahead iterator for the given language and parse state.
ts_lookahead_iterator_next
Advance the lookahead iterator to the next symbol.
ts_lookahead_iterator_reset
Reset the lookahead iterator.
ts_lookahead_iterator_reset_state
Reset the lookahead iterator to another state.
ts_node_child
Get the node’s child at the given index, where zero represents the first child.
ts_node_child_by_field_id
Get the node’s child with the given numerical field id.
ts_node_child_by_field_name
Get the node’s child with the given field name.
ts_node_child_count
Get the node’s number of children.
ts_node_descendant_count
Get the node’s number of descendants, including one for the node itself.
ts_node_descendant_for_byte_range
Get the smallest node within this node that spans the given range of bytes or (row, column) positions.
ts_node_descendant_for_point_range
ts_node_edit
Edit the node to keep it in-sync with source code that has been edited.
ts_node_end_byte
Get the node’s end byte.
ts_node_end_point
Get the node’s end position in terms of rows and columns.
ts_node_eq
Check if two nodes are identical.
ts_node_field_name_for_child
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.
ts_node_first_child_for_byte
Get the node’s first child that extends beyond the given byte offset.
ts_node_first_named_child_for_byte
Get the node’s first named child that extends beyond the given byte offset.
ts_node_grammar_symbol
Get the node’s type as a numerical id as it appears in the grammar ignoring aliases. This should be used in ts_language_next_state instead of ts_node_symbol.
ts_node_grammar_type
Get the node’s type as it appears in the grammar ignoring aliases as a null-terminated string.
ts_node_has_changes
Check if a syntax node has been edited.
ts_node_has_error
Check if the node is a syntax error or contains any syntax errors.
ts_node_is_error
Check if the node is a syntax error.
ts_node_is_extra
Check if the node is extra. Extra nodes represent things like comments, which are not required the grammar, but can appear anywhere.
ts_node_is_missing
Check if the node is missing. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
ts_node_is_named
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.
ts_node_is_null
Check if the node is null. Functions like ts_node_child and ts_node_next_sibling will return a null node to indicate that no such node was found.
ts_node_language
Get the node’s language.
ts_node_named_child
Get the node’s named child at the given index.
ts_node_named_child_count
Get the node’s number of named children.
ts_node_named_descendant_for_byte_range
Get the smallest named node within this node that spans the given range of bytes or (row, column) positions.
ts_node_named_descendant_for_point_range
ts_node_next_named_sibling
Get the node’s next / previous named sibling.
ts_node_next_parse_state
Get the parse state after this node.
ts_node_next_sibling
Get the node’s next / previous sibling.
ts_node_parent
Get the node’s immediate parent.
ts_node_parse_state
Get this node’s parse state.
ts_node_prev_named_sibling
ts_node_prev_sibling
ts_node_start_byte
Get the node’s start byte.
ts_node_start_point
Get the node’s start position in terms of rows and columns.
ts_node_string
Get an S-expression representing the node as a string.
ts_node_symbol
Get the node’s type as a numerical id.
ts_node_type
Get the node’s type as a null-terminated string.
ts_parser_cancellation_flag
Get the parser’s current cancellation flag pointer.
ts_parser_delete
Delete the parser, freeing all of the memory that it used.
ts_parser_included_ranges
Get the ranges of text that the parser will include when parsing.
ts_parser_language
Get the parser’s current language.
ts_parser_logger
Get the parser’s current logger.
ts_parser_new
Create a new parser.
ts_parser_parse
Use the parser to parse some source code and create a syntax tree.
ts_parser_parse_string
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.
ts_parser_parse_string_encoding
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.
ts_parser_print_dot_graphs
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.
ts_parser_reset
Instruct the parser to start the next parse from the beginning.
ts_parser_set_cancellation_flag
Set the parser’s current cancellation flag pointer.
ts_parser_set_included_ranges
Set the ranges of text that the parser should include when parsing.
ts_parser_set_language
Set the language that the parser should use for parsing.
ts_parser_set_logger
Set the logger that a parser should use during parsing.
ts_parser_set_timeout_micros
Set the maximum duration in microseconds that parsing should be allowed to take before halting.
ts_parser_timeout_micros
Get the duration in microseconds that parsing is allowed to take.
ts_query_capture_count
ts_query_capture_name_for_id
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.
ts_query_capture_quantifier_for_id
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.
ts_query_cursor_delete
Delete a query cursor, freeing all of the memory that it used.
ts_query_cursor_did_exceed_match_limit
Manage the maximum number of in-progress matches allowed by this query cursor.
ts_query_cursor_exec
Start running a given query on a given node.
ts_query_cursor_match_limit
ts_query_cursor_new
Create a new cursor for executing a given query.
ts_query_cursor_next_capture
Advance to the next capture of the currently running query.
ts_query_cursor_next_match
Advance to the next match of the currently running query.
ts_query_cursor_remove_match
ts_query_cursor_set_byte_range
Set the range of bytes or (row, column) positions in which the query will be executed.
ts_query_cursor_set_match_limit
ts_query_cursor_set_max_start_depth
Set the maximum start depth for a query cursor.
ts_query_cursor_set_point_range
ts_query_delete
Delete a query, freeing all of the memory that it used.
ts_query_deserialize
Deserialize a query.
ts_query_disable_capture
Disable a certain capture within a query.
ts_query_disable_pattern
Disable a certain pattern within a query.
ts_query_is_pattern_guaranteed_at_step
ts_query_is_pattern_non_local
ts_query_is_pattern_rooted
ts_query_new
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.
ts_query_pattern_count
Get the number of patterns, captures, or string literals in the query.
ts_query_predicates_for_pattern
Get all of the predicates for the given pattern in the query.
ts_query_serialize
Serialize a query.
ts_query_start_byte_for_pattern
Get the byte offset where the given pattern starts in the query’s source.
ts_query_string_count
ts_query_string_value_for_id
ts_set_allocator
Set the allocation functions used by the library.
ts_tree_copy
Create a shallow copy of the syntax tree. This is very fast.
ts_tree_cursor_copy
ts_tree_cursor_current_depth
Get the depth of the cursor’s current node relative to the original node that the cursor was constructed with.
ts_tree_cursor_current_descendant_index
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.
ts_tree_cursor_current_field_id
Get the field id of the tree cursor’s current node.
ts_tree_cursor_current_field_name
Get the field name of the tree cursor’s current node.
ts_tree_cursor_current_node
Get the tree cursor’s current node.
ts_tree_cursor_delete
Delete a tree cursor, freeing all of the memory that it used.
ts_tree_cursor_goto_descendant
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.
ts_tree_cursor_goto_first_child
Move the cursor to the first child of its current node.
ts_tree_cursor_goto_first_child_for_byte
Move the cursor to the first child of its current node that extends beyond the given byte offset or point.
ts_tree_cursor_goto_first_child_for_point
ts_tree_cursor_goto_last_child
Move the cursor to the last child of its current node.
ts_tree_cursor_goto_next_sibling
Move the cursor to the next sibling of its current node.
ts_tree_cursor_goto_parent
Move the cursor to the parent of its current node.
ts_tree_cursor_goto_previous_sibling
Move the cursor to the previous sibling of its current node.
ts_tree_cursor_new
Create a new tree cursor starting from the given node.
ts_tree_cursor_reset
Re-initialize a tree cursor to start at a different node.
ts_tree_cursor_reset_to
Re-initialize a tree cursor to the same position as another cursor.
ts_tree_delete
Delete the syntax tree, freeing all of the memory that it used.
ts_tree_edit
Edit the syntax tree to keep it in sync with source code that has been edited.
ts_tree_get_changed_ranges
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.
ts_tree_included_ranges
Get the array of included ranges that was used to parse the syntax tree.
ts_tree_language
Get the language that was used to parse the syntax tree.
ts_tree_print_dot_graph
Write a DOT graph describing the syntax tree to the given file.
ts_tree_root_node
Get the root node of the syntax tree.
ts_tree_root_node_with_offset
Get the root node of the syntax tree, but with its position shifted forward by the given offset.

Type Aliases§

TSFieldId
TSInputEncoding
TSLogType
TSQuantifier
TSQueryError
TSQueryPredicateStepType
TSStateId
TSSymbol
TSSymbolType