2014-03-09 22:05:17 -07:00
|
|
|
#ifndef TREE_SITTER_RUNTIME_H_
|
|
|
|
|
#define TREE_SITTER_RUNTIME_H_
|
2014-02-15 17:00:33 -08:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2014-03-08 16:51:08 -08:00
|
|
|
|
2018-05-10 22:22:37 -07:00
|
|
|
#include <stdio.h>
|
2014-02-15 17:00:33 -08:00
|
|
|
#include <stdlib.h>
|
2016-11-14 12:15:24 -08:00
|
|
|
#include <stdint.h>
|
2014-10-03 16:06:08 -07:00
|
|
|
#include <stdbool.h>
|
2014-02-20 18:38:31 -08:00
|
|
|
|
2018-03-28 10:11:05 -07:00
|
|
|
#define TREE_SITTER_LANGUAGE_VERSION 8
|
2017-01-31 10:21:47 -08:00
|
|
|
|
2016-02-19 15:41:30 -08:00
|
|
|
typedef unsigned short TSSymbol;
|
|
|
|
|
typedef struct TSLanguage TSLanguage;
|
2018-05-10 22:22:37 -07:00
|
|
|
typedef struct TSParser TSParser;
|
|
|
|
|
typedef struct TSTree TSTree;
|
2018-05-09 16:38:56 -07:00
|
|
|
typedef struct TSTreeCursor TSTreeCursor;
|
2016-02-19 15:41:30 -08:00
|
|
|
|
2015-12-28 10:40:53 -08:00
|
|
|
typedef enum {
|
|
|
|
|
TSInputEncodingUTF8,
|
|
|
|
|
TSInputEncodingUTF16,
|
|
|
|
|
} TSInputEncoding;
|
|
|
|
|
|
2017-04-12 09:46:01 -04:00
|
|
|
typedef enum {
|
|
|
|
|
TSSymbolTypeRegular,
|
|
|
|
|
TSSymbolTypeAnonymous,
|
|
|
|
|
TSSymbolTypeAuxiliary,
|
|
|
|
|
} TSSymbolType;
|
|
|
|
|
|
2018-02-14 07:31:49 -08:00
|
|
|
typedef struct {
|
|
|
|
|
uint32_t row;
|
|
|
|
|
uint32_t column;
|
|
|
|
|
} TSPoint;
|
|
|
|
|
|
2014-03-01 22:43:25 -08:00
|
|
|
typedef struct {
|
2015-09-08 23:33:43 -07:00
|
|
|
void *payload;
|
2016-11-14 12:15:24 -08:00
|
|
|
const char *(*read)(void *payload, uint32_t *bytes_read);
|
2018-02-14 07:31:49 -08:00
|
|
|
int (*seek)(void *payload, uint32_t byte_index, TSPoint position);
|
2015-12-28 10:40:53 -08:00
|
|
|
TSInputEncoding encoding;
|
2014-06-28 18:56:04 -07:00
|
|
|
} TSInput;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-10-17 17:52:54 -07:00
|
|
|
typedef enum {
|
2016-09-06 17:27:50 -07:00
|
|
|
TSLogTypeParse,
|
|
|
|
|
TSLogTypeLex,
|
|
|
|
|
} TSLogType;
|
2014-10-17 17:52:54 -07:00
|
|
|
|
2014-10-13 01:02:12 -07:00
|
|
|
typedef struct {
|
2015-09-08 23:33:43 -07:00
|
|
|
void *payload;
|
2016-09-06 17:27:50 -07:00
|
|
|
void (*log)(void *payload, TSLogType, const char *);
|
|
|
|
|
} TSLogger;
|
2014-10-13 01:02:12 -07:00
|
|
|
|
2016-09-13 13:08:52 -07:00
|
|
|
typedef struct {
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t start_byte;
|
|
|
|
|
uint32_t bytes_removed;
|
|
|
|
|
uint32_t bytes_added;
|
2016-09-13 13:08:52 -07:00
|
|
|
TSPoint start_point;
|
|
|
|
|
TSPoint extent_removed;
|
|
|
|
|
TSPoint extent_added;
|
|
|
|
|
} TSInputEdit;
|
|
|
|
|
|
2016-09-07 17:49:16 -07:00
|
|
|
typedef struct {
|
|
|
|
|
TSPoint start;
|
|
|
|
|
TSPoint end;
|
|
|
|
|
} TSRange;
|
|
|
|
|
|
2015-07-31 15:47:48 -07:00
|
|
|
typedef struct {
|
2018-05-09 10:16:10 -07:00
|
|
|
const void *subtree;
|
2018-05-10 22:22:37 -07:00
|
|
|
const TSTree *tree;
|
2018-05-09 10:16:10 -07:00
|
|
|
TSPoint position;
|
|
|
|
|
uint32_t byte;
|
|
|
|
|
TSSymbol alias_symbol;
|
2015-07-31 15:47:48 -07:00
|
|
|
} TSNode;
|
|
|
|
|
|
2018-05-10 22:22:37 -07:00
|
|
|
TSParser *ts_parser_new();
|
|
|
|
|
void ts_parser_delete(TSParser *);
|
|
|
|
|
const TSLanguage *ts_parser_language(const TSParser *);
|
|
|
|
|
bool ts_parser_set_language(TSParser *, const TSLanguage *);
|
|
|
|
|
TSLogger ts_parser_logger(const TSParser *);
|
|
|
|
|
void ts_parser_set_logger(TSParser *, TSLogger);
|
|
|
|
|
void ts_parser_print_debugging_graphs(TSParser *, bool);
|
|
|
|
|
void ts_parser_halt_on_error(TSParser *, bool);
|
|
|
|
|
TSTree *ts_parser_parse(TSParser *, const TSTree *, TSInput);
|
|
|
|
|
TSTree *ts_parser_parse_string(TSParser *, const TSTree *, const char *, uint32_t);
|
|
|
|
|
|
|
|
|
|
TSTree *ts_tree_copy(const TSTree *);
|
|
|
|
|
void ts_tree_delete(const TSTree *);
|
|
|
|
|
TSNode ts_tree_root_node(const TSTree *);
|
|
|
|
|
void ts_tree_edit(TSTree *, const TSInputEdit *);
|
|
|
|
|
TSRange *ts_tree_get_changed_ranges(const TSTree *, const TSTree *, uint32_t *);
|
|
|
|
|
void ts_tree_print_dot_graph(const TSTree *, FILE *);
|
2018-05-09 16:38:56 -07:00
|
|
|
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t ts_node_start_byte(TSNode);
|
2015-11-25 11:57:39 -05:00
|
|
|
TSPoint ts_node_start_point(TSNode);
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t ts_node_end_byte(TSNode);
|
2015-11-25 11:57:39 -05:00
|
|
|
TSPoint ts_node_end_point(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSSymbol ts_node_symbol(TSNode);
|
2018-05-09 15:28:28 -07:00
|
|
|
const char *ts_node_type(TSNode);
|
|
|
|
|
char *ts_node_string(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
bool ts_node_eq(TSNode, TSNode);
|
|
|
|
|
bool ts_node_is_named(TSNode);
|
2017-12-28 15:48:35 -08:00
|
|
|
bool ts_node_is_missing(TSNode);
|
2015-09-18 23:20:06 -07:00
|
|
|
bool ts_node_has_changes(TSNode);
|
2017-06-21 17:26:52 -07:00
|
|
|
bool ts_node_has_error(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSNode ts_node_parent(TSNode);
|
2016-11-14 12:15:24 -08:00
|
|
|
TSNode ts_node_child(TSNode, uint32_t);
|
|
|
|
|
TSNode ts_node_named_child(TSNode, uint32_t);
|
|
|
|
|
uint32_t ts_node_child_count(TSNode);
|
|
|
|
|
uint32_t ts_node_named_child_count(TSNode);
|
2015-07-31 15:47:48 -07:00
|
|
|
TSNode ts_node_next_sibling(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSNode ts_node_next_named_sibling(TSNode);
|
2015-07-31 15:47:48 -07:00
|
|
|
TSNode ts_node_prev_sibling(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSNode ts_node_prev_named_sibling(TSNode);
|
2018-01-09 12:33:51 -08:00
|
|
|
TSNode ts_node_first_child_for_byte(TSNode, uint32_t);
|
|
|
|
|
TSNode ts_node_first_named_child_for_byte(TSNode, uint32_t);
|
2016-11-14 12:15:24 -08:00
|
|
|
TSNode ts_node_descendant_for_byte_range(TSNode, uint32_t, uint32_t);
|
|
|
|
|
TSNode ts_node_named_descendant_for_byte_range(TSNode, uint32_t, uint32_t);
|
2016-09-06 21:17:26 -07:00
|
|
|
TSNode ts_node_descendant_for_point_range(TSNode, TSPoint, TSPoint);
|
|
|
|
|
TSNode ts_node_named_descendant_for_point_range(TSNode, TSPoint, TSPoint);
|
2014-07-17 23:29:11 -07:00
|
|
|
|
2018-05-10 22:22:37 -07:00
|
|
|
TSTreeCursor *ts_tree_cursor_new(const TSTree *);
|
2018-05-09 16:38:56 -07:00
|
|
|
void ts_tree_cursor_delete(TSTreeCursor *);
|
|
|
|
|
bool ts_tree_cursor_goto_first_child(TSTreeCursor *);
|
|
|
|
|
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *);
|
|
|
|
|
bool ts_tree_cursor_goto_parent(TSTreeCursor *);
|
|
|
|
|
TSNode ts_tree_cursor_current_node(TSTreeCursor *);
|
|
|
|
|
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t ts_language_symbol_count(const TSLanguage *);
|
2016-02-19 15:41:30 -08:00
|
|
|
const char *ts_language_symbol_name(const TSLanguage *, TSSymbol);
|
2017-04-12 09:47:51 -04:00
|
|
|
TSSymbolType ts_language_symbol_type(const TSLanguage *, TSSymbol);
|
2017-01-31 10:21:47 -08:00
|
|
|
uint32_t ts_language_version(const TSLanguage *);
|
2015-10-29 12:40:01 -04:00
|
|
|
|
2014-02-15 17:00:33 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-03-09 22:05:17 -07:00
|
|
|
#endif // TREE_SITTER_RUNTIME_H_
|