changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > core / lisp/ffi/tree-sitter/alien.h

revision 696: 38e9c3be2392
     1.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2+++ b/lisp/ffi/tree-sitter/alien.h	Fri Oct 04 21:11:52 2024 -0400
     1.3@@ -0,0 +1,1282 @@
     1.4+#ifndef TREE_SITTER_API_H_
     1.5+#define TREE_SITTER_API_H_
     1.6+
     1.7+#ifndef TREE_SITTER_HIDE_SYMBOLS
     1.8+#if defined(__GNUC__) || defined(__clang__)
     1.9+#pragma GCC visibility push(default)
    1.10+#endif
    1.11+#endif
    1.12+
    1.13+#include <stdlib.h>
    1.14+#include <stdint.h>
    1.15+#include <stdbool.h>
    1.16+
    1.17+#ifdef __cplusplus
    1.18+extern "C" {
    1.19+#endif
    1.20+
    1.21+/****************************/
    1.22+/* Section - ABI Versioning */
    1.23+/****************************/
    1.24+
    1.25+/**
    1.26+ * The latest ABI version that is supported by the current version of the
    1.27+ * library. When Languages are generated by the Tree-sitter CLI, they are
    1.28+ * assigned an ABI version number that corresponds to the current CLI version.
    1.29+ * The Tree-sitter library is generally backwards-compatible with languages
    1.30+ * generated using older CLI versions, but is not forwards-compatible.
    1.31+ */
    1.32+#define TREE_SITTER_LANGUAGE_VERSION 14
    1.33+
    1.34+/**
    1.35+ * The earliest ABI version that is supported by the current version of the
    1.36+ * library.
    1.37+ */
    1.38+#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION 13
    1.39+
    1.40+/*******************/
    1.41+/* Section - Types */
    1.42+/*******************/
    1.43+
    1.44+typedef uint16_t TSStateId;
    1.45+typedef uint16_t TSSymbol;
    1.46+typedef uint16_t TSFieldId;
    1.47+typedef struct TSLanguage TSLanguage;
    1.48+typedef struct TSParser TSParser;
    1.49+typedef struct TSTree TSTree;
    1.50+typedef struct TSQuery TSQuery;
    1.51+typedef struct TSQueryCursor TSQueryCursor;
    1.52+typedef struct TSLookaheadIterator TSLookaheadIterator;
    1.53+
    1.54+typedef enum TSInputEncoding {
    1.55+  TSInputEncodingUTF8,
    1.56+  TSInputEncodingUTF16,
    1.57+} TSInputEncoding;
    1.58+
    1.59+typedef enum TSSymbolType {
    1.60+  TSSymbolTypeRegular,
    1.61+  TSSymbolTypeAnonymous,
    1.62+  TSSymbolTypeAuxiliary,
    1.63+} TSSymbolType;
    1.64+
    1.65+typedef struct TSPoint {
    1.66+  uint32_t row;
    1.67+  uint32_t column;
    1.68+} TSPoint;
    1.69+
    1.70+typedef struct TSRange {
    1.71+  TSPoint start_point;
    1.72+  TSPoint end_point;
    1.73+  uint32_t start_byte;
    1.74+  uint32_t end_byte;
    1.75+} TSRange;
    1.76+
    1.77+typedef struct TSInput {
    1.78+  void *payload;
    1.79+  const char *(*read)(void *payload, uint32_t byte_index, TSPoint position, uint32_t *bytes_read);
    1.80+  TSInputEncoding encoding;
    1.81+} TSInput;
    1.82+
    1.83+typedef enum TSLogType {
    1.84+  TSLogTypeParse,
    1.85+  TSLogTypeLex,
    1.86+} TSLogType;
    1.87+
    1.88+typedef struct TSLogger {
    1.89+  void *payload;
    1.90+  void (*log)(void *payload, TSLogType log_type, const char *buffer);
    1.91+} TSLogger;
    1.92+
    1.93+typedef struct TSInputEdit {
    1.94+  uint32_t start_byte;
    1.95+  uint32_t old_end_byte;
    1.96+  uint32_t new_end_byte;
    1.97+  TSPoint start_point;
    1.98+  TSPoint old_end_point;
    1.99+  TSPoint new_end_point;
   1.100+} TSInputEdit;
   1.101+
   1.102+typedef struct TSNode {
   1.103+  uint32_t context[4];
   1.104+  const void *id;
   1.105+  const TSTree *tree;
   1.106+} TSNode;
   1.107+
   1.108+typedef struct TSTreeCursor {
   1.109+  const void *tree;
   1.110+  const void *id;
   1.111+  uint32_t context[3];
   1.112+} TSTreeCursor;
   1.113+
   1.114+typedef struct TSQueryCapture {
   1.115+  TSNode node;
   1.116+  uint32_t index;
   1.117+} TSQueryCapture;
   1.118+
   1.119+typedef enum TSQuantifier {
   1.120+  TSQuantifierZero = 0, // must match the array initialization value
   1.121+  TSQuantifierZeroOrOne,
   1.122+  TSQuantifierZeroOrMore,
   1.123+  TSQuantifierOne,
   1.124+  TSQuantifierOneOrMore,
   1.125+} TSQuantifier;
   1.126+
   1.127+typedef struct TSQueryMatch {
   1.128+  uint32_t id;
   1.129+  uint16_t pattern_index;
   1.130+  uint16_t capture_count;
   1.131+  const TSQueryCapture *captures;
   1.132+} TSQueryMatch;
   1.133+
   1.134+typedef enum TSQueryPredicateStepType {
   1.135+  TSQueryPredicateStepTypeDone,
   1.136+  TSQueryPredicateStepTypeCapture,
   1.137+  TSQueryPredicateStepTypeString,
   1.138+} TSQueryPredicateStepType;
   1.139+
   1.140+typedef struct TSQueryPredicateStep {
   1.141+  TSQueryPredicateStepType type;
   1.142+  uint32_t value_id;
   1.143+} TSQueryPredicateStep;
   1.144+
   1.145+typedef enum TSQueryError {
   1.146+  TSQueryErrorNone = 0,
   1.147+  TSQueryErrorSyntax,
   1.148+  TSQueryErrorNodeType,
   1.149+  TSQueryErrorField,
   1.150+  TSQueryErrorCapture,
   1.151+  TSQueryErrorStructure,
   1.152+  TSQueryErrorLanguage,
   1.153+} TSQueryError;
   1.154+
   1.155+/********************/
   1.156+/* Section - Parser */
   1.157+/********************/
   1.158+
   1.159+/**
   1.160+ * Create a new parser.
   1.161+ */
   1.162+TSParser *ts_parser_new(void);
   1.163+
   1.164+/**
   1.165+ * Delete the parser, freeing all of the memory that it used.
   1.166+ */
   1.167+void ts_parser_delete(TSParser *self);
   1.168+
   1.169+/**
   1.170+ * Get the parser's current language.
   1.171+ */
   1.172+const TSLanguage *ts_parser_language(const TSParser *self);
   1.173+
   1.174+/**
   1.175+ * Set the language that the parser should use for parsing.
   1.176+ *
   1.177+ * Returns a boolean indicating whether or not the language was successfully
   1.178+ * assigned. True means assignment succeeded. False means there was a version
   1.179+ * mismatch: the language was generated with an incompatible version of the
   1.180+ * Tree-sitter CLI. Check the language's version using [`ts_language_version`]
   1.181+ * and compare it to this library's [`TREE_SITTER_LANGUAGE_VERSION`] and
   1.182+ * [`TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION`] constants.
   1.183+ */
   1.184+bool ts_parser_set_language(TSParser *self, const TSLanguage *language);
   1.185+
   1.186+/**
   1.187+ * Set the ranges of text that the parser should include when parsing.
   1.188+ *
   1.189+ * By default, the parser will always include entire documents. This function
   1.190+ * allows you to parse only a *portion* of a document but still return a syntax
   1.191+ * tree whose ranges match up with the document as a whole. You can also pass
   1.192+ * multiple disjoint ranges.
   1.193+ *
   1.194+ * The second and third parameters specify the location and length of an array
   1.195+ * of ranges. The parser does *not* take ownership of these ranges; it copies
   1.196+ * the data, so it doesn't matter how these ranges are allocated.
   1.197+ *
   1.198+ * If `count` is zero, then the entire document will be parsed. Otherwise,
   1.199+ * the given ranges must be ordered from earliest to latest in the document,
   1.200+ * and they must not overlap. That is, the following must hold for all:
   1.201+ *
   1.202+ * `i < count - 1`: `ranges[i].end_byte <= ranges[i + 1].start_byte`
   1.203+ *
   1.204+ * If this requirement is not satisfied, the operation will fail, the ranges
   1.205+ * will not be assigned, and this function will return `false`. On success,
   1.206+ * this function returns `true`
   1.207+ */
   1.208+bool ts_parser_set_included_ranges(
   1.209+  TSParser *self,
   1.210+  const TSRange *ranges,
   1.211+  uint32_t count
   1.212+);
   1.213+
   1.214+/**
   1.215+ * Get the ranges of text that the parser will include when parsing.
   1.216+ *
   1.217+ * The returned pointer is owned by the parser. The caller should not free it
   1.218+ * or write to it. The length of the array will be written to the given
   1.219+ * `count` pointer.
   1.220+ */
   1.221+const TSRange *ts_parser_included_ranges(
   1.222+  const TSParser *self,
   1.223+  uint32_t *count
   1.224+);
   1.225+
   1.226+/**
   1.227+ * Use the parser to parse some source code and create a syntax tree.
   1.228+ *
   1.229+ * If you are parsing this document for the first time, pass `NULL` for the
   1.230+ * `old_tree` parameter. Otherwise, if you have already parsed an earlier
   1.231+ * version of this document and the document has since been edited, pass the
   1.232+ * previous syntax tree so that the unchanged parts of it can be reused.
   1.233+ * This will save time and memory. For this to work correctly, you must have
   1.234+ * already edited the old syntax tree using the [`ts_tree_edit`] function in a
   1.235+ * way that exactly matches the source code changes.
   1.236+ *
   1.237+ * The [`TSInput`] parameter lets you specify how to read the text. It has the
   1.238+ * following three fields:
   1.239+ * 1. [`read`]: A function to retrieve a chunk of text at a given byte offset
   1.240+ *    and (row, column) position. The function should return a pointer to the
   1.241+ *    text and write its length to the [`bytes_read`] pointer. The parser does
   1.242+ *    not take ownership of this buffer; it just borrows it until it has
   1.243+ *    finished reading it. The function should write a zero value to the
   1.244+ *    [`bytes_read`] pointer to indicate the end of the document.
   1.245+ * 2. [`payload`]: An arbitrary pointer that will be passed to each invocation
   1.246+ *    of the [`read`] function.
   1.247+ * 3. [`encoding`]: An indication of how the text is encoded. Either
   1.248+ *    `TSInputEncodingUTF8` or `TSInputEncodingUTF16`.
   1.249+ *
   1.250+ * This function returns a syntax tree on success, and `NULL` on failure. There
   1.251+ * are three possible reasons for failure:
   1.252+ * 1. The parser does not have a language assigned. Check for this using the
   1.253+      [`ts_parser_language`] function.
   1.254+ * 2. Parsing was cancelled due to a timeout that was set by an earlier call to
   1.255+ *    the [`ts_parser_set_timeout_micros`] function. You can resume parsing from
   1.256+ *    where the parser left out by calling [`ts_parser_parse`] again with the
   1.257+ *    same arguments. Or you can start parsing from scratch by first calling
   1.258+ *    [`ts_parser_reset`].
   1.259+ * 3. Parsing was cancelled using a cancellation flag that was set by an
   1.260+ *    earlier call to [`ts_parser_set_cancellation_flag`]. You can resume parsing
   1.261+ *    from where the parser left out by calling [`ts_parser_parse`] again with
   1.262+ *    the same arguments.
   1.263+ *
   1.264+ * [`read`]: TSInput::read
   1.265+ * [`payload`]: TSInput::payload
   1.266+ * [`encoding`]: TSInput::encoding
   1.267+ * [`bytes_read`]: TSInput::read
   1.268+ */
   1.269+TSTree *ts_parser_parse(
   1.270+  TSParser *self,
   1.271+  const TSTree *old_tree,
   1.272+  TSInput input
   1.273+);
   1.274+
   1.275+/**
   1.276+ * Use the parser to parse some source code stored in one contiguous buffer.
   1.277+ * The first two parameters are the same as in the [`ts_parser_parse`] function
   1.278+ * above. The second two parameters indicate the location of the buffer and its
   1.279+ * length in bytes.
   1.280+ */
   1.281+TSTree *ts_parser_parse_string(
   1.282+  TSParser *self,
   1.283+  const TSTree *old_tree,
   1.284+  const char *string,
   1.285+  uint32_t length
   1.286+);
   1.287+
   1.288+/**
   1.289+ * Use the parser to parse some source code stored in one contiguous buffer with
   1.290+ * a given encoding. The first four parameters work the same as in the
   1.291+ * [`ts_parser_parse_string`] method above. The final parameter indicates whether
   1.292+ * the text is encoded as UTF8 or UTF16.
   1.293+ */
   1.294+TSTree *ts_parser_parse_string_encoding(
   1.295+  TSParser *self,
   1.296+  const TSTree *old_tree,
   1.297+  const char *string,
   1.298+  uint32_t length,
   1.299+  TSInputEncoding encoding
   1.300+);
   1.301+
   1.302+/**
   1.303+ * Instruct the parser to start the next parse from the beginning.
   1.304+ *
   1.305+ * If the parser previously failed because of a timeout or a cancellation, then
   1.306+ * by default, it will resume where it left off on the next call to
   1.307+ * [`ts_parser_parse`] or other parsing functions. If you don't want to resume,
   1.308+ * and instead intend to use this parser to parse some other document, you must
   1.309+ * call [`ts_parser_reset`] first.
   1.310+ */
   1.311+void ts_parser_reset(TSParser *self);
   1.312+
   1.313+/**
   1.314+ * Set the maximum duration in microseconds that parsing should be allowed to
   1.315+ * take before halting.
   1.316+ *
   1.317+ * If parsing takes longer than this, it will halt early, returning NULL.
   1.318+ * See [`ts_parser_parse`] for more information.
   1.319+ */
   1.320+void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros);
   1.321+
   1.322+/**
   1.323+ * Get the duration in microseconds that parsing is allowed to take.
   1.324+ */
   1.325+uint64_t ts_parser_timeout_micros(const TSParser *self);
   1.326+
   1.327+/**
   1.328+ * Set the parser's current cancellation flag pointer.
   1.329+ *
   1.330+ * If a non-null pointer is assigned, then the parser will periodically read
   1.331+ * from this pointer during parsing. If it reads a non-zero value, it will
   1.332+ * halt early, returning NULL. See [`ts_parser_parse`] for more information.
   1.333+ */
   1.334+void ts_parser_set_cancellation_flag(TSParser *self, const size_t *flag);
   1.335+
   1.336+/**
   1.337+ * Get the parser's current cancellation flag pointer.
   1.338+ */
   1.339+const size_t *ts_parser_cancellation_flag(const TSParser *self);
   1.340+
   1.341+/**
   1.342+ * Set the logger that a parser should use during parsing.
   1.343+ *
   1.344+ * The parser does not take ownership over the logger payload. If a logger was
   1.345+ * previously assigned, the caller is responsible for releasing any memory
   1.346+ * owned by the previous logger.
   1.347+ */
   1.348+void ts_parser_set_logger(TSParser *self, TSLogger logger);
   1.349+
   1.350+/**
   1.351+ * Get the parser's current logger.
   1.352+ */
   1.353+TSLogger ts_parser_logger(const TSParser *self);
   1.354+
   1.355+/**
   1.356+ * Set the file descriptor to which the parser should write debugging graphs
   1.357+ * during parsing. The graphs are formatted in the DOT language. You may want
   1.358+ * to pipe these graphs directly to a `dot(1)` process in order to generate
   1.359+ * SVG output. You can turn off this logging by passing a negative number.
   1.360+ */
   1.361+void ts_parser_print_dot_graphs(TSParser *self, int fd);
   1.362+
   1.363+/******************/
   1.364+/* Section - Tree */
   1.365+/******************/
   1.366+
   1.367+/**
   1.368+ * Create a shallow copy of the syntax tree. This is very fast.
   1.369+ *
   1.370+ * You need to copy a syntax tree in order to use it on more than one thread at
   1.371+ * a time, as syntax trees are not thread safe.
   1.372+ */
   1.373+TSTree *ts_tree_copy(const TSTree *self);
   1.374+
   1.375+/**
   1.376+ * Delete the syntax tree, freeing all of the memory that it used.
   1.377+ */
   1.378+void ts_tree_delete(TSTree *self);
   1.379+
   1.380+/**
   1.381+ * Get the root node of the syntax tree.
   1.382+ */
   1.383+TSNode ts_tree_root_node(const TSTree *self);
   1.384+
   1.385+/**
   1.386+ * Get the root node of the syntax tree, but with its position
   1.387+ * shifted forward by the given offset.
   1.388+ */
   1.389+TSNode ts_tree_root_node_with_offset(
   1.390+  const TSTree *self,
   1.391+  uint32_t offset_bytes,
   1.392+  TSPoint offset_extent
   1.393+);
   1.394+
   1.395+/**
   1.396+ * Get the language that was used to parse the syntax tree.
   1.397+ */
   1.398+const TSLanguage *ts_tree_language(const TSTree *self);
   1.399+
   1.400+/**
   1.401+ * Get the array of included ranges that was used to parse the syntax tree.
   1.402+ *
   1.403+ * The returned pointer must be freed by the caller.
   1.404+ */
   1.405+TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length);
   1.406+
   1.407+/**
   1.408+ * Edit the syntax tree to keep it in sync with source code that has been
   1.409+ * edited.
   1.410+ *
   1.411+ * You must describe the edit both in terms of byte offsets and in terms of
   1.412+ * (row, column) coordinates.
   1.413+ */
   1.414+void ts_tree_edit(TSTree *self, const TSInputEdit *edit);
   1.415+
   1.416+/**
   1.417+ * Compare an old edited syntax tree to a new syntax tree representing the same
   1.418+ * document, returning an array of ranges whose syntactic structure has changed.
   1.419+ *
   1.420+ * For this to work correctly, the old syntax tree must have been edited such
   1.421+ * that its ranges match up to the new tree. Generally, you'll want to call
   1.422+ * this function right after calling one of the [`ts_parser_parse`] functions.
   1.423+ * You need to pass the old tree that was passed to parse, as well as the new
   1.424+ * tree that was returned from that function.
   1.425+ *
   1.426+ * The returned array is allocated using `malloc` and the caller is responsible
   1.427+ * for freeing it using `free`. The length of the array will be written to the
   1.428+ * given `length` pointer.
   1.429+ */
   1.430+TSRange *ts_tree_get_changed_ranges(
   1.431+  const TSTree *old_tree,
   1.432+  const TSTree *new_tree,
   1.433+  uint32_t *length
   1.434+);
   1.435+
   1.436+/**
   1.437+ * Write a DOT graph describing the syntax tree to the given file.
   1.438+ */
   1.439+void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor);
   1.440+
   1.441+/******************/
   1.442+/* Section - Node */
   1.443+/******************/
   1.444+
   1.445+/**
   1.446+ * Get the node's type as a null-terminated string.
   1.447+ */
   1.448+const char *ts_node_type(TSNode self);
   1.449+
   1.450+/**
   1.451+ * Get the node's type as a numerical id.
   1.452+ */
   1.453+TSSymbol ts_node_symbol(TSNode self);
   1.454+
   1.455+/**
   1.456+ * Get the node's language.
   1.457+ */
   1.458+const TSLanguage *ts_node_language(TSNode self);
   1.459+
   1.460+/**
   1.461+ * Get the node's type as it appears in the grammar ignoring aliases as a
   1.462+ * null-terminated string.
   1.463+ */
   1.464+const char *ts_node_grammar_type(TSNode self);
   1.465+
   1.466+/**
   1.467+ * Get the node's type as a numerical id as it appears in the grammar ignoring
   1.468+ * aliases. This should be used in [`ts_language_next_state`] instead of
   1.469+ * [`ts_node_symbol`].
   1.470+ */
   1.471+TSSymbol ts_node_grammar_symbol(TSNode self);
   1.472+
   1.473+/**
   1.474+ * Get the node's start byte.
   1.475+ */
   1.476+uint32_t ts_node_start_byte(TSNode self);
   1.477+
   1.478+/**
   1.479+ * Get the node's start position in terms of rows and columns.
   1.480+ */
   1.481+TSPoint ts_node_start_point(TSNode self);
   1.482+
   1.483+/**
   1.484+ * Get the node's end byte.
   1.485+ */
   1.486+uint32_t ts_node_end_byte(TSNode self);
   1.487+
   1.488+/**
   1.489+ * Get the node's end position in terms of rows and columns.
   1.490+ */
   1.491+TSPoint ts_node_end_point(TSNode self);
   1.492+
   1.493+/**
   1.494+ * Get an S-expression representing the node as a string.
   1.495+ *
   1.496+ * This string is allocated with `malloc` and the caller is responsible for
   1.497+ * freeing it using `free`.
   1.498+ */
   1.499+char *ts_node_string(TSNode self);
   1.500+
   1.501+/**
   1.502+ * Check if the node is null. Functions like [`ts_node_child`] and
   1.503+ * [`ts_node_next_sibling`] will return a null node to indicate that no such node
   1.504+ * was found.
   1.505+ */
   1.506+bool ts_node_is_null(TSNode self);
   1.507+
   1.508+/**
   1.509+ * Check if the node is *named*. Named nodes correspond to named rules in the
   1.510+ * grammar, whereas *anonymous* nodes correspond to string literals in the
   1.511+ * grammar.
   1.512+ */
   1.513+bool ts_node_is_named(TSNode self);
   1.514+
   1.515+/**
   1.516+ * Check if the node is *missing*. Missing nodes are inserted by the parser in
   1.517+ * order to recover from certain kinds of syntax errors.
   1.518+ */
   1.519+bool ts_node_is_missing(TSNode self);
   1.520+
   1.521+/**
   1.522+ * Check if the node is *extra*. Extra nodes represent things like comments,
   1.523+ * which are not required the grammar, but can appear anywhere.
   1.524+ */
   1.525+bool ts_node_is_extra(TSNode self);
   1.526+
   1.527+/**
   1.528+ * Check if a syntax node has been edited.
   1.529+ */
   1.530+bool ts_node_has_changes(TSNode self);
   1.531+
   1.532+/**
   1.533+ * Check if the node is a syntax error or contains any syntax errors.
   1.534+ */
   1.535+bool ts_node_has_error(TSNode self);
   1.536+
   1.537+/**
   1.538+ * Check if the node is a syntax error.
   1.539+*/
   1.540+bool ts_node_is_error(TSNode self);
   1.541+
   1.542+/**
   1.543+ * Get this node's parse state.
   1.544+*/
   1.545+TSStateId ts_node_parse_state(TSNode self);
   1.546+
   1.547+/**
   1.548+ * Get the parse state after this node.
   1.549+*/
   1.550+TSStateId ts_node_next_parse_state(TSNode self);
   1.551+
   1.552+/**
   1.553+ * Get the node's immediate parent.
   1.554+ * Prefer [`ts_node_child_containing_descendant`] for
   1.555+ * iterating over the node's ancestors.
   1.556+ */
   1.557+TSNode ts_node_parent(TSNode self);
   1.558+
   1.559+/**
   1.560+ * Get the node's child that contains `descendant`.
   1.561+ */
   1.562+TSNode ts_node_child_containing_descendant(TSNode self, TSNode descendant);
   1.563+
   1.564+/**
   1.565+ * Get the node's child at the given index, where zero represents the first
   1.566+ * child.
   1.567+ */
   1.568+TSNode ts_node_child(TSNode self, uint32_t child_index);
   1.569+
   1.570+/**
   1.571+ * Get the field name for node's child at the given index, where zero represents
   1.572+ * the first child. Returns NULL, if no field is found.
   1.573+ */
   1.574+const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index);
   1.575+
   1.576+/**
   1.577+ * Get the node's number of children.
   1.578+ */
   1.579+uint32_t ts_node_child_count(TSNode self);
   1.580+
   1.581+/**
   1.582+ * Get the node's *named* child at the given index.
   1.583+ *
   1.584+ * See also [`ts_node_is_named`].
   1.585+ */
   1.586+TSNode ts_node_named_child(TSNode self, uint32_t child_index);
   1.587+
   1.588+/**
   1.589+ * Get the node's number of *named* children.
   1.590+ *
   1.591+ * See also [`ts_node_is_named`].
   1.592+ */
   1.593+uint32_t ts_node_named_child_count(TSNode self);
   1.594+
   1.595+/**
   1.596+ * Get the node's child with the given field name.
   1.597+ */
   1.598+TSNode ts_node_child_by_field_name(
   1.599+  TSNode self,
   1.600+  const char *name,
   1.601+  uint32_t name_length
   1.602+);
   1.603+
   1.604+/**
   1.605+ * Get the node's child with the given numerical field id.
   1.606+ *
   1.607+ * You can convert a field name to an id using the
   1.608+ * [`ts_language_field_id_for_name`] function.
   1.609+ */
   1.610+TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id);
   1.611+
   1.612+/**
   1.613+ * Get the node's next / previous sibling.
   1.614+ */
   1.615+TSNode ts_node_next_sibling(TSNode self);
   1.616+TSNode ts_node_prev_sibling(TSNode self);
   1.617+
   1.618+/**
   1.619+ * Get the node's next / previous *named* sibling.
   1.620+ */
   1.621+TSNode ts_node_next_named_sibling(TSNode self);
   1.622+TSNode ts_node_prev_named_sibling(TSNode self);
   1.623+
   1.624+/**
   1.625+ * Get the node's first child that extends beyond the given byte offset.
   1.626+ */
   1.627+TSNode ts_node_first_child_for_byte(TSNode self, uint32_t byte);
   1.628+
   1.629+/**
   1.630+ * Get the node's first named child that extends beyond the given byte offset.
   1.631+ */
   1.632+TSNode ts_node_first_named_child_for_byte(TSNode self, uint32_t byte);
   1.633+
   1.634+/**
   1.635+ * Get the node's number of descendants, including one for the node itself.
   1.636+ */
   1.637+uint32_t ts_node_descendant_count(TSNode self);
   1.638+
   1.639+/**
   1.640+ * Get the smallest node within this node that spans the given range of bytes
   1.641+ * or (row, column) positions.
   1.642+ */
   1.643+TSNode ts_node_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
   1.644+TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
   1.645+
   1.646+/**
   1.647+ * Get the smallest named node within this node that spans the given range of
   1.648+ * bytes or (row, column) positions.
   1.649+ */
   1.650+TSNode ts_node_named_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
   1.651+TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
   1.652+
   1.653+/**
   1.654+ * Edit the node to keep it in-sync with source code that has been edited.
   1.655+ *
   1.656+ * This function is only rarely needed. When you edit a syntax tree with the
   1.657+ * [`ts_tree_edit`] function, all of the nodes that you retrieve from the tree
   1.658+ * afterward will already reflect the edit. You only need to use [`ts_node_edit`]
   1.659+ * when you have a [`TSNode`] instance that you want to keep and continue to use
   1.660+ * after an edit.
   1.661+ */
   1.662+void ts_node_edit(TSNode *self, const TSInputEdit *edit);
   1.663+
   1.664+/**
   1.665+ * Check if two nodes are identical.
   1.666+ */
   1.667+bool ts_node_eq(TSNode self, TSNode other);
   1.668+
   1.669+/************************/
   1.670+/* Section - TreeCursor */
   1.671+/************************/
   1.672+
   1.673+/**
   1.674+ * Create a new tree cursor starting from the given node.
   1.675+ *
   1.676+ * A tree cursor allows you to walk a syntax tree more efficiently than is
   1.677+ * possible using the [`TSNode`] functions. It is a mutable object that is always
   1.678+ * on a certain syntax node, and can be moved imperatively to different nodes.
   1.679+ */
   1.680+TSTreeCursor ts_tree_cursor_new(TSNode node);
   1.681+
   1.682+/**
   1.683+ * Delete a tree cursor, freeing all of the memory that it used.
   1.684+ */
   1.685+void ts_tree_cursor_delete(TSTreeCursor *self);
   1.686+
   1.687+/**
   1.688+ * Re-initialize a tree cursor to start at the original node that the cursor was
   1.689+ * constructed with.
   1.690+ */
   1.691+void ts_tree_cursor_reset(TSTreeCursor *self, TSNode node);
   1.692+
   1.693+/**
   1.694+ * Re-initialize a tree cursor to the same position as another cursor.
   1.695+ *
   1.696+ * Unlike [`ts_tree_cursor_reset`], this will not lose parent information and
   1.697+ * allows reusing already created cursors.
   1.698+*/
   1.699+void ts_tree_cursor_reset_to(TSTreeCursor *dst, const TSTreeCursor *src);
   1.700+
   1.701+/**
   1.702+ * Get the tree cursor's current node.
   1.703+ */
   1.704+TSNode ts_tree_cursor_current_node(const TSTreeCursor *self);
   1.705+
   1.706+/**
   1.707+ * Get the field name of the tree cursor's current node.
   1.708+ *
   1.709+ * This returns `NULL` if the current node doesn't have a field.
   1.710+ * See also [`ts_node_child_by_field_name`].
   1.711+ */
   1.712+const char *ts_tree_cursor_current_field_name(const TSTreeCursor *self);
   1.713+
   1.714+/**
   1.715+ * Get the field id of the tree cursor's current node.
   1.716+ *
   1.717+ * This returns zero if the current node doesn't have a field.
   1.718+ * See also [`ts_node_child_by_field_id`], [`ts_language_field_id_for_name`].
   1.719+ */
   1.720+TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *self);
   1.721+
   1.722+/**
   1.723+ * Move the cursor to the parent of its current node.
   1.724+ *
   1.725+ * This returns `true` if the cursor successfully moved, and returns `false`
   1.726+ * if there was no parent node (the cursor was already on the root node).
   1.727+ */
   1.728+bool ts_tree_cursor_goto_parent(TSTreeCursor *self);
   1.729+
   1.730+/**
   1.731+ * Move the cursor to the next sibling of its current node.
   1.732+ *
   1.733+ * This returns `true` if the cursor successfully moved, and returns `false`
   1.734+ * if there was no next sibling node.
   1.735+ */
   1.736+bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *self);
   1.737+
   1.738+/**
   1.739+ * Move the cursor to the previous sibling of its current node.
   1.740+ *
   1.741+ * This returns `true` if the cursor successfully moved, and returns `false` if
   1.742+ * there was no previous sibling node.
   1.743+ *
   1.744+ * Note, that this function may be slower than
   1.745+ * [`ts_tree_cursor_goto_next_sibling`] due to how node positions are stored. In
   1.746+ * the worst case, this will need to iterate through all the children upto the
   1.747+ * previous sibling node to recalculate its position.
   1.748+ */
   1.749+bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor *self);
   1.750+
   1.751+/**
   1.752+ * Move the cursor to the first child of its current node.
   1.753+ *
   1.754+ * This returns `true` if the cursor successfully moved, and returns `false`
   1.755+ * if there were no children.
   1.756+ */
   1.757+bool ts_tree_cursor_goto_first_child(TSTreeCursor *self);
   1.758+
   1.759+/**
   1.760+ * Move the cursor to the last child of its current node.
   1.761+ *
   1.762+ * This returns `true` if the cursor successfully moved, and returns `false` if
   1.763+ * there were no children.
   1.764+ *
   1.765+ * Note that this function may be slower than [`ts_tree_cursor_goto_first_child`]
   1.766+ * because it needs to iterate through all the children to compute the child's
   1.767+ * position.
   1.768+ */
   1.769+bool ts_tree_cursor_goto_last_child(TSTreeCursor *self);
   1.770+
   1.771+/**
   1.772+ * Move the cursor to the node that is the nth descendant of
   1.773+ * the original node that the cursor was constructed with, where
   1.774+ * zero represents the original node itself.
   1.775+ */
   1.776+void ts_tree_cursor_goto_descendant(TSTreeCursor *self, uint32_t goal_descendant_index);
   1.777+
   1.778+/**
   1.779+ * Get the index of the cursor's current node out of all of the
   1.780+ * descendants of the original node that the cursor was constructed with.
   1.781+ */
   1.782+uint32_t ts_tree_cursor_current_descendant_index(const TSTreeCursor *self);
   1.783+
   1.784+/**
   1.785+ * Get the depth of the cursor's current node relative to the original
   1.786+ * node that the cursor was constructed with.
   1.787+ */
   1.788+uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *self);
   1.789+
   1.790+/**
   1.791+ * Move the cursor to the first child of its current node that extends beyond
   1.792+ * the given byte offset or point.
   1.793+ *
   1.794+ * This returns the index of the child node if one was found, and returns -1
   1.795+ * if no such child was found.
   1.796+ */
   1.797+int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte);
   1.798+int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point);
   1.799+
   1.800+TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *cursor);
   1.801+
   1.802+/*******************/
   1.803+/* Section - Query */
   1.804+/*******************/
   1.805+
   1.806+/**
   1.807+ * Create a new query from a string containing one or more S-expression
   1.808+ * patterns. The query is associated with a particular language, and can
   1.809+ * only be run on syntax nodes parsed with that language.
   1.810+ *
   1.811+ * If all of the given patterns are valid, this returns a [`TSQuery`].
   1.812+ * If a pattern is invalid, this returns `NULL`, and provides two pieces
   1.813+ * of information about the problem:
   1.814+ * 1. The byte offset of the error is written to the `error_offset` parameter.
   1.815+ * 2. The type of error is written to the `error_type` parameter.
   1.816+ */
   1.817+TSQuery *ts_query_new(
   1.818+  const TSLanguage *language,
   1.819+  const char *source,
   1.820+  uint32_t source_len,
   1.821+  uint32_t *error_offset,
   1.822+  TSQueryError *error_type
   1.823+);
   1.824+
   1.825+/**
   1.826+ * Delete a query, freeing all of the memory that it used.
   1.827+ */
   1.828+void ts_query_delete(TSQuery *self);
   1.829+
   1.830+/**
   1.831+ * Get the number of patterns, captures, or string literals in the query.
   1.832+ */
   1.833+uint32_t ts_query_pattern_count(const TSQuery *self);
   1.834+uint32_t ts_query_capture_count(const TSQuery *self);
   1.835+uint32_t ts_query_string_count(const TSQuery *self);
   1.836+
   1.837+/**
   1.838+ * Get the byte offset where the given pattern starts in the query's source.
   1.839+ *
   1.840+ * This can be useful when combining queries by concatenating their source
   1.841+ * code strings.
   1.842+ */
   1.843+uint32_t ts_query_start_byte_for_pattern(const TSQuery *self, uint32_t pattern_index);
   1.844+
   1.845+/**
   1.846+ * Get the byte offset where the given pattern ends in the query's source.
   1.847+ *
   1.848+ * This can be useful when combining queries by concatenating their source
   1.849+ * code strings.
   1.850+ */
   1.851+uint32_t ts_query_end_byte_for_pattern(const TSQuery *self, uint32_t pattern_index);
   1.852+
   1.853+/**
   1.854+ * Get all of the predicates for the given pattern in the query.
   1.855+ *
   1.856+ * The predicates are represented as a single array of steps. There are three
   1.857+ * types of steps in this array, which correspond to the three legal values for
   1.858+ * the `type` field:
   1.859+ * - `TSQueryPredicateStepTypeCapture` - Steps with this type represent names
   1.860+ *    of captures. Their `value_id` can be used with the
   1.861+ *   [`ts_query_capture_name_for_id`] function to obtain the name of the capture.
   1.862+ * - `TSQueryPredicateStepTypeString` - Steps with this type represent literal
   1.863+ *    strings. Their `value_id` can be used with the
   1.864+ *    [`ts_query_string_value_for_id`] function to obtain their string value.
   1.865+ * - `TSQueryPredicateStepTypeDone` - Steps with this type are *sentinels*
   1.866+ *    that represent the end of an individual predicate. If a pattern has two
   1.867+ *    predicates, then there will be two steps with this `type` in the array.
   1.868+ */
   1.869+const TSQueryPredicateStep *ts_query_predicates_for_pattern(
   1.870+  const TSQuery *self,
   1.871+  uint32_t pattern_index,
   1.872+  uint32_t *step_count
   1.873+);
   1.874+
   1.875+/*
   1.876+ * Check if the given pattern in the query has a single root node.
   1.877+ */
   1.878+bool ts_query_is_pattern_rooted(const TSQuery *self, uint32_t pattern_index);
   1.879+
   1.880+/*
   1.881+ * Check if the given pattern in the query is 'non local'.
   1.882+ *
   1.883+ * A non-local pattern has multiple root nodes and can match within a
   1.884+ * repeating sequence of nodes, as specified by the grammar. Non-local
   1.885+ * patterns disable certain optimizations that would otherwise be possible
   1.886+ * when executing a query on a specific range of a syntax tree.
   1.887+ */
   1.888+bool ts_query_is_pattern_non_local(const TSQuery *self, uint32_t pattern_index);
   1.889+
   1.890+/*
   1.891+ * Check if a given pattern is guaranteed to match once a given step is reached.
   1.892+ * The step is specified by its byte offset in the query's source code.
   1.893+ */
   1.894+bool ts_query_is_pattern_guaranteed_at_step(const TSQuery *self, uint32_t byte_offset);
   1.895+
   1.896+/**
   1.897+ * Get the name and length of one of the query's captures, or one of the
   1.898+ * query's string literals. Each capture and string is associated with a
   1.899+ * numeric id based on the order that it appeared in the query's source.
   1.900+ */
   1.901+const char *ts_query_capture_name_for_id(
   1.902+  const TSQuery *self,
   1.903+  uint32_t index,
   1.904+  uint32_t *length
   1.905+);
   1.906+
   1.907+/**
   1.908+ * Get the quantifier of the query's captures. Each capture is * associated
   1.909+ * with a numeric id based on the order that it appeared in the query's source.
   1.910+ */
   1.911+TSQuantifier ts_query_capture_quantifier_for_id(
   1.912+  const TSQuery *self,
   1.913+  uint32_t pattern_index,
   1.914+  uint32_t capture_index
   1.915+);
   1.916+
   1.917+const char *ts_query_string_value_for_id(
   1.918+  const TSQuery *self,
   1.919+  uint32_t index,
   1.920+  uint32_t *length
   1.921+);
   1.922+
   1.923+/**
   1.924+ * Disable a certain capture within a query.
   1.925+ *
   1.926+ * This prevents the capture from being returned in matches, and also avoids
   1.927+ * any resource usage associated with recording the capture. Currently, there
   1.928+ * is no way to undo this.
   1.929+ */
   1.930+void ts_query_disable_capture(TSQuery *self, const char *name, uint32_t length);
   1.931+
   1.932+/**
   1.933+ * Disable a certain pattern within a query.
   1.934+ *
   1.935+ * This prevents the pattern from matching and removes most of the overhead
   1.936+ * associated with the pattern. Currently, there is no way to undo this.
   1.937+ */
   1.938+void ts_query_disable_pattern(TSQuery *self, uint32_t pattern_index);
   1.939+
   1.940+/**
   1.941+ * Create a new cursor for executing a given query.
   1.942+ *
   1.943+ * The cursor stores the state that is needed to iteratively search
   1.944+ * for matches. To use the query cursor, first call [`ts_query_cursor_exec`]
   1.945+ * to start running a given query on a given syntax node. Then, there are
   1.946+ * two options for consuming the results of the query:
   1.947+ * 1. Repeatedly call [`ts_query_cursor_next_match`] to iterate over all of the
   1.948+ *    *matches* in the order that they were found. Each match contains the
   1.949+ *    index of the pattern that matched, and an array of captures. Because
   1.950+ *    multiple patterns can match the same set of nodes, one match may contain
   1.951+ *    captures that appear *before* some of the captures from a previous match.
   1.952+ * 2. Repeatedly call [`ts_query_cursor_next_capture`] to iterate over all of the
   1.953+ *    individual *captures* in the order that they appear. This is useful if
   1.954+ *    don't care about which pattern matched, and just want a single ordered
   1.955+ *    sequence of captures.
   1.956+ *
   1.957+ * If you don't care about consuming all of the results, you can stop calling
   1.958+ * [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] at any point.
   1.959+ *  You can then start executing another query on another node by calling
   1.960+ *  [`ts_query_cursor_exec`] again.
   1.961+ */
   1.962+TSQueryCursor *ts_query_cursor_new(void);
   1.963+
   1.964+/**
   1.965+ * Delete a query cursor, freeing all of the memory that it used.
   1.966+ */
   1.967+void ts_query_cursor_delete(TSQueryCursor *self);
   1.968+
   1.969+/**
   1.970+ * Start running a given query on a given node.
   1.971+ */
   1.972+void ts_query_cursor_exec(TSQueryCursor *self, const TSQuery *query, TSNode node);
   1.973+
   1.974+/**
   1.975+ * Manage the maximum number of in-progress matches allowed by this query
   1.976+ * cursor.
   1.977+ *
   1.978+ * Query cursors have an optional maximum capacity for storing lists of
   1.979+ * in-progress captures. If this capacity is exceeded, then the
   1.980+ * earliest-starting match will silently be dropped to make room for further
   1.981+ * matches. This maximum capacity is optional — by default, query cursors allow
   1.982+ * any number of pending matches, dynamically allocating new space for them as
   1.983+ * needed as the query is executed.
   1.984+ */
   1.985+bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *self);
   1.986+uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self);
   1.987+void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit);
   1.988+
   1.989+/**
   1.990+ * Set the range of bytes or (row, column) positions in which the query
   1.991+ * will be executed.
   1.992+ */
   1.993+void ts_query_cursor_set_byte_range(TSQueryCursor *self, uint32_t start_byte, uint32_t end_byte);
   1.994+void ts_query_cursor_set_point_range(TSQueryCursor *self, TSPoint start_point, TSPoint end_point);
   1.995+
   1.996+/**
   1.997+ * Advance to the next match of the currently running query.
   1.998+ *
   1.999+ * If there is a match, write it to `*match` and return `true`.
  1.1000+ * Otherwise, return `false`.
  1.1001+ */
  1.1002+bool ts_query_cursor_next_match(TSQueryCursor *self, TSQueryMatch *match);
  1.1003+void ts_query_cursor_remove_match(TSQueryCursor *self, uint32_t match_id);
  1.1004+
  1.1005+/**
  1.1006+ * Advance to the next capture of the currently running query.
  1.1007+ *
  1.1008+ * If there is a capture, write its match to `*match` and its index within
  1.1009+ * the matche's capture list to `*capture_index`. Otherwise, return `false`.
  1.1010+ */
  1.1011+bool ts_query_cursor_next_capture(
  1.1012+  TSQueryCursor *self,
  1.1013+  TSQueryMatch *match,
  1.1014+  uint32_t *capture_index
  1.1015+);
  1.1016+
  1.1017+/**
  1.1018+ * Set the maximum start depth for a query cursor.
  1.1019+ *
  1.1020+ * This prevents cursors from exploring children nodes at a certain depth.
  1.1021+ * Note if a pattern includes many children, then they will still be checked.
  1.1022+ *
  1.1023+ * The zero max start depth value can be used as a special behavior and
  1.1024+ * it helps to destructure a subtree by staying on a node and using captures
  1.1025+ * for interested parts. Note that the zero max start depth only limit a search
  1.1026+ * depth for a pattern's root node but other nodes that are parts of the pattern
  1.1027+ * may be searched at any depth what defined by the pattern structure.
  1.1028+ *
  1.1029+ * Set to `UINT32_MAX` to remove the maximum start depth.
  1.1030+ */
  1.1031+void ts_query_cursor_set_max_start_depth(TSQueryCursor *self, uint32_t max_start_depth);
  1.1032+
  1.1033+/**********************/
  1.1034+/* Section - Language */
  1.1035+/**********************/
  1.1036+
  1.1037+/**
  1.1038+ * Get another reference to the given language.
  1.1039+ */
  1.1040+const TSLanguage *ts_language_copy(const TSLanguage *self);
  1.1041+
  1.1042+/**
  1.1043+ * Free any dynamically-allocated resources for this language, if
  1.1044+ * this is the last reference.
  1.1045+ */
  1.1046+void ts_language_delete(const TSLanguage *self);
  1.1047+
  1.1048+/**
  1.1049+ * Get the number of distinct node types in the language.
  1.1050+ */
  1.1051+uint32_t ts_language_symbol_count(const TSLanguage *self);
  1.1052+
  1.1053+/**
  1.1054+ * Get the number of valid states in this language.
  1.1055+*/
  1.1056+uint32_t ts_language_state_count(const TSLanguage *self);
  1.1057+
  1.1058+/**
  1.1059+ * Get a node type string for the given numerical id.
  1.1060+ */
  1.1061+const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
  1.1062+
  1.1063+/**
  1.1064+ * Get the numerical id for the given node type string.
  1.1065+ */
  1.1066+TSSymbol ts_language_symbol_for_name(
  1.1067+  const TSLanguage *self,
  1.1068+  const char *string,
  1.1069+  uint32_t length,
  1.1070+  bool is_named
  1.1071+);
  1.1072+
  1.1073+/**
  1.1074+ * Get the number of distinct field names in the language.
  1.1075+ */
  1.1076+uint32_t ts_language_field_count(const TSLanguage *self);
  1.1077+
  1.1078+/**
  1.1079+ * Get the field name string for the given numerical id.
  1.1080+ */
  1.1081+const char *ts_language_field_name_for_id(const TSLanguage *self, TSFieldId id);
  1.1082+
  1.1083+/**
  1.1084+ * Get the numerical id for the given field name string.
  1.1085+ */
  1.1086+TSFieldId ts_language_field_id_for_name(const TSLanguage *self, const char *name, uint32_t name_length);
  1.1087+
  1.1088+/**
  1.1089+ * Check whether the given node type id belongs to named nodes, anonymous nodes,
  1.1090+ * or a hidden nodes.
  1.1091+ *
  1.1092+ * See also [`ts_node_is_named`]. Hidden nodes are never returned from the API.
  1.1093+ */
  1.1094+TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
  1.1095+
  1.1096+/**
  1.1097+ * Get the ABI version number for this language. This version number is used
  1.1098+ * to ensure that languages were generated by a compatible version of
  1.1099+ * Tree-sitter.
  1.1100+ *
  1.1101+ * See also [`ts_parser_set_language`].
  1.1102+ */
  1.1103+uint32_t ts_language_version(const TSLanguage *self);
  1.1104+
  1.1105+/**
  1.1106+ * Get the next parse state. Combine this with lookahead iterators to generate
  1.1107+ * completion suggestions or valid symbols in error nodes. Use
  1.1108+ * [`ts_node_grammar_symbol`] for valid symbols.
  1.1109+*/
  1.1110+TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
  1.1111+
  1.1112+/********************************/
  1.1113+/* Section - Lookahead Iterator */
  1.1114+/********************************/
  1.1115+
  1.1116+/**
  1.1117+ * Create a new lookahead iterator for the given language and parse state.
  1.1118+ *
  1.1119+ * This returns `NULL` if state is invalid for the language.
  1.1120+ *
  1.1121+ * Repeatedly using [`ts_lookahead_iterator_next`] and
  1.1122+ * [`ts_lookahead_iterator_current_symbol`] will generate valid symbols in the
  1.1123+ * given parse state. Newly created lookahead iterators will contain the `ERROR`
  1.1124+ * symbol.
  1.1125+ *
  1.1126+ * Lookahead iterators can be useful to generate suggestions and improve syntax
  1.1127+ * error diagnostics. To get symbols valid in an ERROR node, use the lookahead
  1.1128+ * iterator on its first leaf node state. For `MISSING` nodes, a lookahead
  1.1129+ * iterator created on the previous non-extra leaf node may be appropriate.
  1.1130+*/
  1.1131+TSLookaheadIterator *ts_lookahead_iterator_new(const TSLanguage *self, TSStateId state);
  1.1132+
  1.1133+/**
  1.1134+ * Delete a lookahead iterator freeing all the memory used.
  1.1135+*/
  1.1136+void ts_lookahead_iterator_delete(TSLookaheadIterator *self);
  1.1137+
  1.1138+/**
  1.1139+ * Reset the lookahead iterator to another state.
  1.1140+ *
  1.1141+ * This returns `true` if the iterator was reset to the given state and `false`
  1.1142+ * otherwise.
  1.1143+*/
  1.1144+bool ts_lookahead_iterator_reset_state(TSLookaheadIterator *self, TSStateId state);
  1.1145+
  1.1146+/**
  1.1147+ * Reset the lookahead iterator.
  1.1148+ *
  1.1149+ * This returns `true` if the language was set successfully and `false`
  1.1150+ * otherwise.
  1.1151+*/
  1.1152+bool ts_lookahead_iterator_reset(TSLookaheadIterator *self, const TSLanguage *language, TSStateId state);
  1.1153+
  1.1154+/**
  1.1155+ * Get the current language of the lookahead iterator.
  1.1156+*/
  1.1157+const TSLanguage *ts_lookahead_iterator_language(const TSLookaheadIterator *self);
  1.1158+
  1.1159+/**
  1.1160+ * Advance the lookahead iterator to the next symbol.
  1.1161+ *
  1.1162+ * This returns `true` if there is a new symbol and `false` otherwise.
  1.1163+*/
  1.1164+bool ts_lookahead_iterator_next(TSLookaheadIterator *self);
  1.1165+
  1.1166+/**
  1.1167+ * Get the current symbol of the lookahead iterator;
  1.1168+*/
  1.1169+TSSymbol ts_lookahead_iterator_current_symbol(const TSLookaheadIterator *self);
  1.1170+
  1.1171+/**
  1.1172+ * Get the current symbol type of the lookahead iterator as a null terminated
  1.1173+ * string.
  1.1174+*/
  1.1175+const char *ts_lookahead_iterator_current_symbol_name(const TSLookaheadIterator *self);
  1.1176+
  1.1177+/*************************************/
  1.1178+/* Section - WebAssembly Integration */
  1.1179+/************************************/
  1.1180+
  1.1181+typedef struct wasm_engine_t TSWasmEngine;
  1.1182+typedef struct TSWasmStore TSWasmStore;
  1.1183+
  1.1184+typedef enum {
  1.1185+  TSWasmErrorKindNone = 0,
  1.1186+  TSWasmErrorKindParse,
  1.1187+  TSWasmErrorKindCompile,
  1.1188+  TSWasmErrorKindInstantiate,
  1.1189+  TSWasmErrorKindAllocate,
  1.1190+} TSWasmErrorKind;
  1.1191+
  1.1192+typedef struct {
  1.1193+  TSWasmErrorKind kind;
  1.1194+  char *message;
  1.1195+} TSWasmError;
  1.1196+
  1.1197+/**
  1.1198+ * Create a Wasm store.
  1.1199+ */
  1.1200+TSWasmStore *ts_wasm_store_new(
  1.1201+  TSWasmEngine *engine,
  1.1202+  TSWasmError *error
  1.1203+);
  1.1204+
  1.1205+/**
  1.1206+ * Free the memory associated with the given Wasm store.
  1.1207+ */
  1.1208+void ts_wasm_store_delete(TSWasmStore *);
  1.1209+
  1.1210+/**
  1.1211+ * Create a language from a buffer of Wasm. The resulting language behaves
  1.1212+ * like any other Tree-sitter language, except that in order to use it with
  1.1213+ * a parser, that parser must have a Wasm store. Note that the language
  1.1214+ * can be used with any Wasm store, it doesn't need to be the same store that
  1.1215+ * was used to originally load it.
  1.1216+ */
  1.1217+const TSLanguage *ts_wasm_store_load_language(
  1.1218+  TSWasmStore *,
  1.1219+  const char *name,
  1.1220+  const char *wasm,
  1.1221+  uint32_t wasm_len,
  1.1222+  TSWasmError *error
  1.1223+);
  1.1224+
  1.1225+/**
  1.1226+ * Get the number of languages instantiated in the given wasm store.
  1.1227+ */
  1.1228+size_t ts_wasm_store_language_count(const TSWasmStore *);
  1.1229+
  1.1230+/**
  1.1231+ * Check if the language came from a Wasm module. If so, then in order to use
  1.1232+ * this language with a Parser, that parser must have a Wasm store assigned.
  1.1233+ */
  1.1234+bool ts_language_is_wasm(const TSLanguage *);
  1.1235+
  1.1236+/**
  1.1237+ * Assign the given Wasm store to the parser. A parser must have a Wasm store
  1.1238+ * in order to use Wasm languages.
  1.1239+ */
  1.1240+void ts_parser_set_wasm_store(TSParser *, TSWasmStore *);
  1.1241+
  1.1242+/**
  1.1243+ * Remove the parser's current Wasm store and return it. This returns NULL if
  1.1244+ * the parser doesn't have a Wasm store.
  1.1245+ */
  1.1246+TSWasmStore *ts_parser_take_wasm_store(TSParser *);
  1.1247+
  1.1248+/**********************************/
  1.1249+/* Section - Global Configuration */
  1.1250+/**********************************/
  1.1251+
  1.1252+/**
  1.1253+ * Set the allocation functions used by the library.
  1.1254+ *
  1.1255+ * By default, Tree-sitter uses the standard libc allocation functions,
  1.1256+ * but aborts the process when an allocation fails. This function lets
  1.1257+ * you supply alternative allocation functions at runtime.
  1.1258+ *
  1.1259+ * If you pass `NULL` for any parameter, Tree-sitter will switch back to
  1.1260+ * its default implementation of that function.
  1.1261+ *
  1.1262+ * If you call this function after the library has already been used, then
  1.1263+ * you must ensure that either:
  1.1264+ *  1. All the existing objects have been freed.
  1.1265+ *  2. The new allocator shares its state with the old one, so it is capable
  1.1266+ *     of freeing memory that was allocated by the old allocator.
  1.1267+ */
  1.1268+void ts_set_allocator(
  1.1269+  void *(*new_malloc)(size_t),
  1.1270+        void *(*new_calloc)(size_t, size_t),
  1.1271+        void *(*new_realloc)(void *, size_t),
  1.1272+        void (*new_free)(void *)
  1.1273+);
  1.1274+
  1.1275+#ifdef __cplusplus
  1.1276+}
  1.1277+#endif
  1.1278+
  1.1279+#ifndef TREE_SITTER_HIDE_SYMBOLS
  1.1280+#if defined(__GNUC__) || defined(__clang__)
  1.1281+#pragma GCC visibility pop
  1.1282+#endif
  1.1283+#endif
  1.1284+
  1.1285+#endif  // TREE_SITTER_API_H_