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>
|
2014-10-03 16:06:08 -07:00
|
|
|
#include <stdbool.h>
|
2014-02-20 18:38:31 -08:00
|
|
|
|
2014-09-26 16:15:07 -07:00
|
|
|
typedef struct {
|
|
|
|
|
size_t bytes;
|
|
|
|
|
size_t chars;
|
|
|
|
|
} TSLength;
|
|
|
|
|
|
2014-03-01 22:43:25 -08:00
|
|
|
typedef struct {
|
2015-09-08 23:33:43 -07:00
|
|
|
void *payload;
|
|
|
|
|
const char *(*read_fn)(void *payload, size_t *bytes_read);
|
|
|
|
|
int (*seek_fn)(void *payload, TSLength position);
|
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 {
|
|
|
|
|
TSDebugTypeParse,
|
2015-07-27 18:29:48 -07:00
|
|
|
TSDebugTypeLex,
|
2014-10-17 17:52:54 -07:00
|
|
|
} TSDebugType;
|
|
|
|
|
|
2014-10-13 01:02:12 -07:00
|
|
|
typedef struct {
|
2015-09-08 23:33:43 -07:00
|
|
|
void *payload;
|
|
|
|
|
void (*debug_fn)(void *payload, TSDebugType, const char *);
|
2014-10-13 01:02:12 -07:00
|
|
|
} TSDebugger;
|
|
|
|
|
|
2014-03-19 22:59:07 -07:00
|
|
|
typedef struct {
|
2014-07-20 20:27:33 -07:00
|
|
|
size_t position;
|
2014-09-28 18:47:29 -07:00
|
|
|
size_t chars_inserted;
|
|
|
|
|
size_t chars_removed;
|
2014-06-28 18:56:47 -07:00
|
|
|
} TSInputEdit;
|
2014-03-15 15:15:59 -07:00
|
|
|
|
2015-07-31 15:47:48 -07:00
|
|
|
typedef struct {
|
|
|
|
|
const void *data;
|
2015-08-16 10:51:34 -07:00
|
|
|
TSLength offset;
|
2015-07-31 15:47:48 -07:00
|
|
|
} TSNode;
|
|
|
|
|
|
2014-07-17 23:29:11 -07:00
|
|
|
typedef unsigned short TSSymbol;
|
2014-07-30 23:40:02 -07:00
|
|
|
typedef struct TSLanguage TSLanguage;
|
2015-07-31 15:47:48 -07:00
|
|
|
typedef struct TSDocument TSDocument;
|
2014-03-15 16:55:25 -07:00
|
|
|
|
2015-07-31 15:47:48 -07:00
|
|
|
TSLength ts_node_pos(TSNode);
|
|
|
|
|
TSLength ts_node_size(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSSymbol ts_node_symbol(TSNode);
|
|
|
|
|
const char *ts_node_name(TSNode, const TSDocument *);
|
|
|
|
|
const char *ts_node_string(TSNode, const TSDocument *);
|
|
|
|
|
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);
|
2015-07-31 15:47:48 -07:00
|
|
|
TSNode ts_node_child(TSNode, size_t);
|
2015-09-08 23:16:24 -07:00
|
|
|
TSNode ts_node_named_child(TSNode, size_t);
|
2015-07-31 15:47:48 -07:00
|
|
|
size_t ts_node_child_count(TSNode);
|
2015-09-08 23:16:24 -07:00
|
|
|
size_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);
|
|
|
|
|
TSNode ts_node_descendent_for_range(TSNode, size_t, size_t);
|
|
|
|
|
TSNode ts_node_named_descendent_for_range(TSNode, size_t, size_t);
|
2014-07-17 23:29:11 -07:00
|
|
|
|
2014-07-20 21:43:27 -07:00
|
|
|
TSDocument *ts_document_make();
|
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 *);
|
2015-10-28 17:12:43 -04:00
|
|
|
const char *ts_document_symbol_name(TSDocument *, TSSymbol);
|
2015-09-08 23:33:43 -07:00
|
|
|
TSDebugger ts_document_debugger(const TSDocument *);
|
2014-10-17 17:52:54 -07:00
|
|
|
void ts_document_set_debugger(TSDocument *, TSDebugger);
|
2015-09-18 23:20:06 -07:00
|
|
|
void ts_document_edit(TSDocument *, TSInputEdit);
|
2015-10-18 13:05:40 -07:00
|
|
|
void ts_document_parse(TSDocument *);
|
|
|
|
|
void ts_document_invalidate(TSDocument *);
|
2015-07-31 15:47:48 -07:00
|
|
|
TSNode ts_document_root_node(const TSDocument *);
|
2015-09-10 14:23:42 -07:00
|
|
|
size_t ts_document_parse_count(const TSDocument *);
|
2014-07-17 23:29:11 -07:00
|
|
|
|
|
|
|
|
#define ts_builtin_sym_error 0
|
|
|
|
|
#define ts_builtin_sym_end 1
|
2015-08-22 10:48:34 -07:00
|
|
|
#define ts_builtin_sym_start 2
|
2014-03-08 16:51:08 -08: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_
|