Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#ifndef TREE_SITTER_API_H_
#define TREE_SITTER_API_H_
#ifndef TREE_SITTER_HIDE_SYMBOLS
#if defined(GNUC) || defined(clang)
#pragma GCC visibility push(default)
#endif
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
//
/ Section - ABI Versioning /
//
/**
*/
#define TREE_SITTER_LANGUAGE_VERSION 15
/**
*/
#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION 13
//
/ Section - Types /
//
typedef uint16_t TSStateId;
typedef uint16_t TSSymbol;
typedef uint16_t TSFieldId;
typedef struct TSLanguage TSLanguage;
typedef struct TSParser TSParser;
typedef struct TSTree TSTree;
typedef struct TSQuery TSQuery;
typedef struct TSQueryCursor TSQueryCursor;
typedef struct TSLookaheadIterator TSLookaheadIterator;
// This function signature reads one code point from the given string,
// returning the number of bytes consumed. It should write the code point
// to the
code_pointpointer, or write -1 if the input is invalid.typedef uint32_t (*TSDecodeFunction)(
const uint8_t *string,
uint32_t length,
int32_t *code_point
);
// Deprecated alias to be removed in ABI 16
typedef TSDecodeFunction DecodeFunction;
typedef enum TSInputEncoding {
TSInputEncodingUTF8,
TSInputEncodingUTF16LE,
TSInputEncodingUTF16BE,
TSInputEncodingCustom
} TSInputEncoding;
typedef enum TSSymbolType {
TSSymbolTypeRegular,
TSSymbolTypeAnonymous,
TSSymbolTypeSupertype,
TSSymbolTypeAuxiliary,
} TSSymbolType;
typedef struct TSPoint {
uint32_t row;
uint32_t column;
} TSPoint;
typedef struct TSRange {
TSPoint start_point;
TSPoint end_point;
uint32_t start_byte;
uint32_t end_byte;
} TSRange;
typedef struct TSInput {
void *payload;
const char *(*read)(void *payload, uint32_t byte_index, TSPoint position, uint32_t *bytes_read);
TSInputEncoding encoding;
TSDecodeFunction decode;
} TSInput;
typedef struct TSParseState {
void *payload;
uint32_t current_byte_offset;
bool has_error;
} TSParseState;
typedef struct TSParseOptions {
void *payload;
bool (*progress_callback)(TSParseState *state);
} TSParseOptions;
typedef enum TSLogType {
TSLogTypeParse,
TSLogTypeLex,
} TSLogType;
typedef struct TSLogger {
void *payload;
void (*log)(void *payload, TSLogType log_type, const char *buffer);
} TSLogger;
/**
start_byteandstart_pointvalues must be less than or equal to theold_end_byteandold_end_pointvalues, respectively. Passing an edit*/
typedef struct TSInputEdit {
uint32_t start_byte;
uint32_t old_end_byte;
uint32_t new_end_byte;
TSPoint start_point;
TSPoint old_end_point;
TSPoint new_end_point;
} TSInputEdit;
typedef struct TSNode {
uint32_t context[4];
const void *id;
const TSTree *tree;
} TSNode;
typedef struct TSTreeCursor {
const void *tree;
const void *id;
uint32_t context[3];
} TSTreeCursor;
typedef struct TSQueryCapture {
TSNode node;
uint32_t index;
} TSQueryCapture;
typedef enum TSQuantifier {
TSQuantifierZero = 0, // must match the array initialization value
TSQuantifierZeroOrOne,
TSQuantifierZeroOrMore,
TSQuantifierOne,
TSQuantifierOneOrMore,
} TSQuantifier;
typedef struct TSQueryMatch {
uint32_t id;
uint16_t pattern_index;
uint16_t capture_count;
const TSQueryCapture *captures;
} TSQueryMatch;
typedef enum TSQueryPredicateStepType {
TSQueryPredicateStepTypeDone,
TSQueryPredicateStepTypeCapture,
TSQueryPredicateStepTypeString,
} TSQueryPredicateStepType;
typedef struct TSQueryPredicateStep {
TSQueryPredicateStepType type;
uint32_t value_id;
} TSQueryPredicateStep;
typedef enum TSQueryError {
TSQueryErrorNone = 0,
TSQueryErrorSyntax,
TSQueryErrorNodeType,
TSQueryErrorField,
TSQueryErrorCapture,
TSQueryErrorStructure,
TSQueryErrorLanguage,
} TSQueryError;
typedef struct TSQueryCursorState {
void *payload;
uint32_t current_byte_offset;
} TSQueryCursorState;
typedef struct TSQueryCursorOptions {
void *payload;
bool (*progress_callback)(TSQueryCursorState *state);
} TSQueryCursorOptions;
/**
*/
typedef struct TSLanguageMetadata {
uint8_t major_version;
uint8_t minor_version;
uint8_t patch_version;
} TSLanguageMetadata;
//
/* Section - Parser */
//
/**
*/
TSParser *ts_parser_new(void);
/**
*/
void ts_parser_delete(TSParser *self);
/**
*/
const TSLanguage *ts_parser_language(const TSParser *self);
/**
ts_language_is_parseable]. Check the language's ABI version usingts_language_abi_version] and compare it to this library'sTREE_SITTER_LANGUAGE_VERSION] andTREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION] constants.*/
bool ts_parser_set_language(TSParser *self, const TSLanguage *language);
/**
countis zero, then the entire document will be parsed. Otherwise,i < count - 1:ranges[i].end_byte <= ranges[i + 1].start_bytefalse. On success,true*/
bool ts_parser_set_included_ranges(
TSParser *self,
const TSRange *ranges,
uint32_t count
);
/**
countpointer.*/
const TSRange *ts_parser_included_ranges(
const TSParser *self,
uint32_t *count
);
/**
NULLfor theold_treeparameter. Otherwise, if you have already parsed an earlierts_tree_edit] function in aTSInput] parameter lets you specify how to read the text. It has theread: A function to retrieve a chunk of text at a given byte offsetbytes_readpointer. The parser doesbytes_readpointer to indicate the end of the document.payload: An arbitrary pointer that will be passed to each invocationreadfunction.encoding: An indication of how the text is encoded. EitherTSInputEncodingUTF8,TSInputEncodingUTF16LE,TSInputEncoding16BE,TSInputEncodingCustom.decode: A function to read one code point from the given input. Thiscode_pointpointer, or write -1 if the input is invalid.NULLon failure. Therets_parser_language] function.ts_parser_parse_with_options] inside the [TSParseOptions] struct.TSTree *ts_parser_parse(
TSParser *self,
const TSTree *old_tree,
TSInput input
);
/**
ts_parser_parse] for more details.TSParseOptions] for more details on the options./
TSTree ts_parser_parse_with_options(
TSParser *self,
const TSTree *old_tree,
TSInput input,
TSParseOptions parse_options
);
/**
ts_parser_parse] function*/
TSTree *ts_parser_parse_string(
TSParser *self,
const TSTree *old_tree,
const char *string,
uint32_t length
);
/**
ts_parser_parse_string] method above. The final parameter indicates whether*/
TSTree *ts_parser_parse_string_encoding(
TSParser *self,
const TSTree *old_tree,
const char *string,
uint32_t length,
TSInputEncoding encoding
);
/**
ts_parser_parse] or other parsing functions. If you don't want to resume,ts_parser_reset] first.*/
void ts_parser_reset(TSParser *self);
/**
*/
void ts_parser_set_logger(TSParser *self, TSLogger logger);
/**
*/
TSLogger ts_parser_logger(const TSParser *self);
/**
dot(1)process in order to generate*/
void ts_parser_print_dot_graphs(TSParser *self, int fd);
//
/ Section - Tree /
//
/**
*/
TSTree *ts_tree_copy(const TSTree *self);
/**
*/
void ts_tree_delete(TSTree *self);
/**
*/
TSNode ts_tree_root_node(const TSTree *self);
/**
*/
TSNode ts_tree_root_node_with_offset(
const TSTree *self,
uint32_t offset_bytes,
TSPoint offset_extent
);
/**
*/
const TSLanguage *ts_tree_language(const TSTree *self);
/**
*/
TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length);
/**
start_bytemust be less than or equal to itsold_end_byte,start_pointmust be less than or equal to itsold_end_point.*/
void ts_tree_edit(TSTree *self, const TSInputEdit *edit);
/**
ts_parser_parse] functions.mallocand the caller is responsiblefree. The length of the array will be written to thelengthpointer.*/
TSRange *ts_tree_get_changed_ranges(
const TSTree *old_tree,
const TSTree *new_tree,
uint32_t *length
);
/**
*/
void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor);
//
/ Section - Node /
//
/**
*/
const char *ts_node_type(TSNode self);
/**
*/
TSSymbol ts_node_symbol(TSNode self);
/**
*/
const TSLanguage *ts_node_language(TSNode self);
/**
*/
const char *ts_node_grammar_type(TSNode self);
/**
ts_language_next_state] instead ofts_node_symbol].*/
TSSymbol ts_node_grammar_symbol(TSNode self);
/**
*/
uint32_t ts_node_start_byte(TSNode self);
/**
*/
TSPoint ts_node_start_point(TSNode self);
/**
*/
uint32_t ts_node_end_byte(TSNode self);
/**
*/
TSPoint ts_node_end_point(TSNode self);
/**
mallocand the caller is responsible forfree.*/
char *ts_node_string(TSNode self);
/**
ts_node_child] andts_node_next_sibling] will return a null node to indicate that no such node*/
bool ts_node_is_null(TSNode self);
/**
*/
bool ts_node_is_named(TSNode self);
/**
*/
bool ts_node_is_missing(TSNode self);
/**
*/
bool ts_node_is_extra(TSNode self);
/**
*/
bool ts_node_has_changes(TSNode self);
/**
*/
bool ts_node_has_error(TSNode self);
/**
*/
bool ts_node_is_error(TSNode self);
/**
ts_lookahead_iterator_new] to*/
TSStateId ts_node_parse_state(TSNode self);
/**
*/
TSStateId ts_node_next_parse_state(TSNode self);
/**
ts_node_child_with_descendant] for*/
TSNode ts_node_parent(TSNode self);
/**
descendant.descendantitself.*/
TSNode ts_node_child_with_descendant(TSNode self, TSNode descendant);
/**
*/
TSNode ts_node_child(TSNode self, uint32_t child_index);
/**
*/
const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index);
/**
*/
const char *ts_node_field_name_for_named_child(TSNode self, uint32_t named_child_index);
/**
*/
uint32_t ts_node_child_count(TSNode self);
/**
ts_node_is_named].*/
TSNode ts_node_named_child(TSNode self, uint32_t child_index);
/**
ts_node_is_named].*/
uint32_t ts_node_named_child_count(TSNode self);
/**
*/
TSNode ts_node_child_by_field_name(
TSNode self,
const char *name,
uint32_t name_length
);
/**
ts_language_field_id_for_name] function.*/
TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id);
/**
*/
TSNode ts_node_next_sibling(TSNode self);
TSNode ts_node_prev_sibling(TSNode self);
/**
*/
TSNode ts_node_next_named_sibling(TSNode self);
TSNode ts_node_prev_named_sibling(TSNode self);
/**
*/
TSNode ts_node_first_child_for_byte(TSNode self, uint32_t byte);
/**
*/
TSNode ts_node_first_named_child_for_byte(TSNode self, uint32_t byte);
/**
*/
uint32_t ts_node_descendant_count(TSNode self);
/**
*/
TSNode ts_node_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
/**
*/
TSNode ts_node_named_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
/**
ts_tree_edit] function, all of the nodes that you retrieve from the treets_node_edit]TSNode] instance that you want to keep and continue to usestart_bytemust be less than or equal to itsold_end_byte,start_pointmust be less than or equal to itsold_end_point.*/
void ts_node_edit(TSNode *self, const TSInputEdit *edit);
/**
*/
bool ts_node_eq(TSNode self, TSNode other);
/**
start_bytemust be less than or equal to itsold_end_byte,start_pointmust be less than or equal to itsold_end_point.*/
void ts_point_edit(TSPoint *point, uint32_t *point_byte, const TSInputEdit *edit);
/**
start_bytemust be less than or equal to itsold_end_byte,start_pointmust be less than or equal to itsold_end_point.*/
void ts_range_edit(TSRange *range, const TSInputEdit *edit);
//
/ Section - TreeCursor /
//
/**
TSNode] functions. It is a mutable object that is always*/
TSTreeCursor ts_tree_cursor_new(TSNode node);
/**
*/
void ts_tree_cursor_delete(TSTreeCursor *self);
/**
*/
void ts_tree_cursor_reset(TSTreeCursor *self, TSNode node);
/**
ts_tree_cursor_reset], this will not lose parent information and*/
void ts_tree_cursor_reset_to(TSTreeCursor *dst, const TSTreeCursor *src);
/**
*/
TSNode ts_tree_cursor_current_node(const TSTreeCursor *self);
/**
NULLif the current node doesn't have a field.ts_node_child_by_field_name].*/
const char *ts_tree_cursor_current_field_name(const TSTreeCursor *self);
/**
ts_node_child_by_field_id], [ts_language_field_id_for_name].*/
TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *self);
/**
trueif the cursor successfully moved, and returnsfalse*/
bool ts_tree_cursor_goto_parent(TSTreeCursor *self);
/**
trueif the cursor successfully moved, and returnsfalse*/
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *self);
/**
trueif the cursor successfully moved, and returnsfalseifts_tree_cursor_goto_next_sibling] due to how node positions are stored. In*/
bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor *self);
/**
trueif the cursor successfully moved, and returnsfalse*/
bool ts_tree_cursor_goto_first_child(TSTreeCursor *self);
/**
trueif the cursor successfully moved, and returnsfalseifts_tree_cursor_goto_first_child]*/
bool ts_tree_cursor_goto_last_child(TSTreeCursor *self);
/**
*/
void ts_tree_cursor_goto_descendant(TSTreeCursor *self, uint32_t goal_descendant_index);
/**
*/
uint32_t ts_tree_cursor_current_descendant_index(const TSTreeCursor *self);
/**
*/
uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *self);
/**
*/
int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte);
int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point);
TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *cursor);
//
/ Section - Query /
//
/**
TSQuery].NULL, and provides two pieceserror_offsetparameter.error_typeparameter.*/
TSQuery *ts_query_new(
const TSLanguage *language,
const char *source,
uint32_t source_len,
uint32_t *error_offset,
TSQueryError *error_type
);
/**
*/
void ts_query_delete(TSQuery *self);
/**
*/
TSQuery *ts_query_copy(const TSQuery *self);
/**
*/
uint32_t ts_query_pattern_count(const TSQuery *self);
uint32_t ts_query_capture_count(const TSQuery *self);
uint32_t ts_query_string_count(const TSQuery *self);
/**
*/
uint32_t ts_query_start_byte_for_pattern(const TSQuery *self, uint32_t pattern_index);
/**
*/
uint32_t ts_query_end_byte_for_pattern(const TSQuery *self, uint32_t pattern_index);
/**
typefield:TSQueryPredicateStepTypeCapture- Steps with this type represent namesvalue_idcan be used with thets_query_capture_name_for_id] function to obtain the name of the capture.TSQueryPredicateStepTypeString- Steps with this type represent literalvalue_idcan be used with thets_query_string_value_for_id] function to obtain their string value.TSQueryPredicateStepTypeDone- Steps with this type are sentinelstypein the array.*/
const TSQueryPredicateStep *ts_query_predicates_for_pattern(
const TSQuery *self,
uint32_t pattern_index,
uint32_t *step_count
);
/*
*/
bool ts_query_is_pattern_rooted(const TSQuery *self, uint32_t pattern_index);
/*
*/
bool ts_query_is_pattern_non_local(const TSQuery *self, uint32_t pattern_index);
/*
*/
bool ts_query_is_pattern_guaranteed_at_step(const TSQuery *self, uint32_t byte_offset);
/**
*/
const char *ts_query_capture_name_for_id(
const TSQuery *self,
uint32_t index,
uint32_t *length
);
/**
*/
TSQuantifier ts_query_capture_quantifier_for_id(
const TSQuery *self,
uint32_t pattern_index,
uint32_t capture_index
);
const char *ts_query_string_value_for_id(
const TSQuery *self,
uint32_t index,
uint32_t *length
);
/**
*/
void ts_query_disable_capture(TSQuery *self, const char *name, uint32_t length);
/**
*/
void ts_query_disable_pattern(TSQuery *self, uint32_t pattern_index);
/**
ts_query_cursor_exec]ts_query_cursor_next_match] to iterate over all of thets_query_cursor_next_capture] to iterate over all of thets_query_cursor_next_match] or [ts_query_cursor_next_capture] at any point.ts_query_cursor_exec] again.*/
TSQueryCursor *ts_query_cursor_new(void);
/**
*/
void ts_query_cursor_delete(TSQueryCursor *self);
/**
*/
void ts_query_cursor_exec(TSQueryCursor *self, const TSQuery *query, TSNode node);
/**
true, query execution halts. Matches that were still ints_query_cursor_exec] or [ts_query_cursor_exec_with_options].*/
void ts_query_cursor_exec_with_options(
TSQueryCursor *self,
const TSQuery *query,
TSNode node,
const TSQueryCursorOptions *query_options
);
/**
*/
bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *self);
uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self);
void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit);
/**
end_byteof zero is interpreted asUINT32_MAX, making the rangefalseif the start byte is greater than the end byte, otherwisetrue.*/
bool ts_query_cursor_set_byte_range(TSQueryCursor *self, uint32_t start_byte, uint32_t end_byte);
/**
end_pointof(0, 0)is interpreted asPOINT_MAX, making thefalseif the start point is greater than the end point, otherwisetrue.*/
bool ts_query_cursor_set_point_range(TSQueryCursor *self, TSPoint start_point, TSPoint end_point);
/**
ts_query_cursor_set_byte_range, this will restrict the query cursor to only returnend_byteof zero is interpreted asUINT32_MAX, making the range*/
bool ts_query_cursor_set_containing_byte_range(TSQueryCursor *self, uint32_t start_byte, uint32_t end_byte);
/**
ts_query_cursor_set_point_range, this will restrict the query cursor to only returnend_pointof(0, 0)is interpreted asPOINT_MAX, making the*/
bool ts_query_cursor_set_containing_point_range(TSQueryCursor *self, TSPoint start_point, TSPoint end_point);
/**
*matchand returntrue.false.*/
bool ts_query_cursor_next_match(TSQueryCursor *self, TSQueryMatch *match);
void ts_query_cursor_remove_match(TSQueryCursor *self, uint32_t match_id);
/**
*matchand its index within*capture_index. Otherwise, returnfalse.*/
bool ts_query_cursor_next_capture(
TSQueryCursor *self,
TSQueryMatch *match,
uint32_t *capture_index
);
/**
UINT32_MAXto remove the maximum start depth.*/
void ts_query_cursor_set_max_start_depth(TSQueryCursor *self, uint32_t max_start_depth);
//
/ Section - Language /
//
/**
*/
const TSLanguage *ts_language_copy(const TSLanguage *self);
/**
*/
void ts_language_delete(const TSLanguage *self);
/**
*/
bool ts_language_is_parseable(const TSLanguage *self);
/**
*/
uint32_t ts_language_symbol_count(const TSLanguage *self);
/**
*/
uint32_t ts_language_state_count(const TSLanguage *self);
/**
*/
TSSymbol ts_language_symbol_for_name(
const TSLanguage *self,
const char *string,
uint32_t length,
bool is_named
);
/**
*/
uint32_t ts_language_field_count(const TSLanguage *self);
/**
*/
const char *ts_language_field_name_for_id(const TSLanguage *self, TSFieldId id);
/**
*/
TSFieldId ts_language_field_id_for_name(const TSLanguage *self, const char *name, uint32_t name_length);
/**
*/
const TSSymbol *ts_language_supertypes(const TSLanguage *self, uint32_t *length);
/**
ts_language_supertypes] for fetching all supertype symbols.*/
const TSSymbol *ts_language_subtypes(
const TSLanguage *self,
TSSymbol supertype,
uint32_t *length
);
/**
*/
const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
/**
ts_node_is_named]. Hidden nodes are never returned from the API.*/
TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
/**
ts_parser_set_language].*/
uint32_t ts_language_abi_version(const TSLanguage *self);
/**
tree-sitter.jsonfile.TSMetadata].*/
const TSLanguageMetadata *ts_language_metadata(const TSLanguage *self);
/**
ts_node_grammar_symbol] for valid symbols.*/
TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
/**
NULLin older parsers.*/
const char *ts_language_name(const TSLanguage *self);
//
/* Section - Lookahead Iterator */
//
/**
NULLif state is invalid for the language.ts_lookahead_iterator_next] andts_lookahead_iterator_current_symbol] will generate valid symbols in thets_lookahead_iterator_next] is called.MISSINGnodes, a lookahead*/
TSLookaheadIterator *ts_lookahead_iterator_new(const TSLanguage *self, TSStateId state);
/**
*/
void ts_lookahead_iterator_delete(TSLookaheadIterator *self);
/**
trueif the iterator was reset to the given state andfalse*/
bool ts_lookahead_iterator_reset_state(TSLookaheadIterator *self, TSStateId state);
/**
trueif the language was set successfully andfalse*/
bool ts_lookahead_iterator_reset(TSLookaheadIterator *self, const TSLanguage *language, TSStateId state);
/**
*/
const TSLanguage *ts_lookahead_iterator_language(const TSLookaheadIterator *self);
/**
trueif there is a new symbol andfalseotherwise.*/
bool ts_lookahead_iterator_next(TSLookaheadIterator *self);
/**
ts_lookahead_iterator_next] onselfreturnedtrue.*/
TSSymbol ts_lookahead_iterator_current_symbol(const TSLookaheadIterator *self);
/**
NULLunless the most recent call tots_lookahead_iterator_next] onselfreturnedtrue.*/
const char *ts_lookahead_iterator_current_symbol_name(const TSLookaheadIterator *self);
/*/
/ Section - WebAssembly Integration /
//
typedef struct wasm_engine_t TSWasmEngine;
typedef struct TSWasmStore TSWasmStore;
typedef enum {
TSWasmErrorKindNone = 0,
TSWasmErrorKindParse,
TSWasmErrorKindCompile,
TSWasmErrorKindInstantiate,
TSWasmErrorKindAllocate,
} TSWasmErrorKind;
typedef struct {
TSWasmErrorKind kind;
char *message;
} TSWasmError;
/**
*/
TSWasmStore *ts_wasm_store_new(
TSWasmEngine *engine,
TSWasmError *error
);
/**
*/
void ts_wasm_store_delete(TSWasmStore *);
/**
*/
const TSLanguage *ts_wasm_store_load_language(
TSWasmStore *,
const char *name,
const char *wasm,
uint32_t wasm_len,
TSWasmError *error
);
/**
*/
size_t ts_wasm_store_language_count(const TSWasmStore *);
/**
*/
bool ts_language_is_wasm(const TSLanguage *);
/**
*/
void ts_parser_set_wasm_store(TSParser *, TSWasmStore *);
/**
*/
TSWasmStore *ts_parser_take_wasm_store(TSParser *);
//
/ Section - Global Configuration /
//
/**
NULLfor any parameter, Tree-sitter will switch back to*/
void ts_set_allocator(
void *(*new_malloc)(size_t),
void *(*new_calloc)(size_t, size_t),
void *(*new_realloc)(void *, size_t),
void (*new_free)(void *)
);
#ifdef __cplusplus
}
#endif
#ifndef TREE_SITTER_HIDE_SYMBOLS
#if defined(GNUC) || defined(clang)
#pragma GCC visibility pop
#endif
#endif
#endif // TREE_SITTER_API_H_