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
|
|
|
|
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
|
|
|
|
2016-02-19 15:41:30 -08:00
|
|
|
typedef unsigned short TSSymbol;
|
|
|
|
|
typedef struct TSLanguage TSLanguage;
|
|
|
|
|
typedef struct TSDocument TSDocument;
|
|
|
|
|
|
2015-12-28 10:40:53 -08:00
|
|
|
typedef enum {
|
|
|
|
|
TSInputEncodingUTF8,
|
|
|
|
|
TSInputEncodingUTF16,
|
|
|
|
|
} TSInputEncoding;
|
|
|
|
|
|
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);
|
|
|
|
|
int (*seek)(void *payload, uint32_t character_index, uint32_t byte_index);
|
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
|
|
|
|
2015-11-12 12:24:05 -05:00
|
|
|
typedef struct {
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t row;
|
|
|
|
|
uint32_t column;
|
2015-11-18 16:34:50 -08:00
|
|
|
} TSPoint;
|
2015-11-12 12:24:05 -05: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 {
|
|
|
|
|
const void *data;
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t offset[3];
|
2015-07-31 15:47:48 -07:00
|
|
|
} TSNode;
|
|
|
|
|
|
2016-02-19 15:41:30 -08:00
|
|
|
typedef struct {
|
|
|
|
|
TSSymbol value;
|
|
|
|
|
bool done;
|
|
|
|
|
void *data;
|
|
|
|
|
} TSSymbolIterator;
|
2014-03-15 16:55:25 -07:00
|
|
|
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t ts_node_start_char(TSNode);
|
|
|
|
|
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_char(TSNode);
|
|
|
|
|
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);
|
2016-02-19 15:41:30 -08:00
|
|
|
TSSymbolIterator ts_node_symbols(TSNode);
|
|
|
|
|
void ts_symbol_iterator_next(TSSymbolIterator *);
|
2016-09-06 21:43:59 -07:00
|
|
|
const char *ts_node_type(TSNode, const TSDocument *);
|
2016-01-18 10:27:23 -08:00
|
|
|
char *ts_node_string(TSNode, const TSDocument *);
|
2015-09-08 23:16:24 -07:00
|
|
|
bool ts_node_eq(TSNode, TSNode);
|
|
|
|
|
bool ts_node_is_named(TSNode);
|
2015-09-18 23:20:06 -07:00
|
|
|
bool ts_node_has_changes(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);
|
2016-11-14 12:15:24 -08:00
|
|
|
TSNode ts_node_descendant_for_char_range(TSNode, uint32_t, uint32_t);
|
|
|
|
|
TSNode ts_node_named_descendant_for_char_range(TSNode, uint32_t, uint32_t);
|
|
|
|
|
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
|
|
|
|
2016-09-06 17:26:18 -07:00
|
|
|
TSDocument *ts_document_new();
|
2014-07-30 23:40:02 -07:00
|
|
|
void ts_document_free(TSDocument *);
|
2015-09-13 19:41:11 -07:00
|
|
|
const TSLanguage *ts_document_language(TSDocument *);
|
2014-07-30 23:40:02 -07:00
|
|
|
void ts_document_set_language(TSDocument *, const TSLanguage *);
|
2015-09-08 23:33:43 -07:00
|
|
|
TSInput ts_document_input(TSDocument *);
|
2014-07-30 23:40:02 -07:00
|
|
|
void ts_document_set_input(TSDocument *, TSInput);
|
|
|
|
|
void ts_document_set_input_string(TSDocument *, const char *);
|
2016-09-06 17:27:50 -07:00
|
|
|
TSLogger ts_document_logger(const TSDocument *);
|
|
|
|
|
void ts_document_set_logger(TSDocument *, TSLogger);
|
2016-02-23 11:16:50 -08:00
|
|
|
void ts_document_print_debugging_graphs(TSDocument *, bool);
|
2015-09-18 23:20:06 -07:00
|
|
|
void ts_document_edit(TSDocument *, TSInputEdit);
|
2016-11-04 09:18:38 -07:00
|
|
|
void ts_document_parse(TSDocument *);
|
2016-11-14 12:15:24 -08:00
|
|
|
void ts_document_parse_and_get_changed_ranges(TSDocument *, TSRange **, uint32_t *);
|
2015-10-18 13:05:40 -07:00
|
|
|
void ts_document_invalidate(TSDocument *);
|
2015-07-31 15:47:48 -07:00
|
|
|
TSNode ts_document_root_node(const TSDocument *);
|
2016-11-14 12:15:24 -08:00
|
|
|
uint32_t ts_document_parse_count(const TSDocument *);
|
2014-07-17 23:29:11 -07:00
|
|
|
|
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);
|
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_
|