tree-sitter/include/tree_sitter/runtime.h

82 lines
2.1 KiB
C
Raw Normal View History

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-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
typedef struct {
size_t bytes;
size_t chars;
} TSLength;
typedef struct {
2014-07-20 20:27:33 -07:00
void *data;
const char *(*read_fn)(void *data, size_t *bytes_read);
int (*seek_fn)(void *data, TSLength position);
void (*release_fn)(void *data);
2014-06-28 18:56:04 -07:00
} TSInput;
2014-02-15 17:00:33 -08:00
typedef enum {
TSDebugTypeParse,
TSDebugTypeLex
} TSDebugType;
typedef struct {
void *data;
void (*debug_fn)(void *data, TSDebugType, const char *);
void (*release_fn)(void *data);
} TSDebugger;
2014-03-19 22:59:07 -07:00
typedef struct {
2014-07-20 20:27:33 -07:00
size_t position;
size_t chars_inserted;
size_t chars_removed;
} TSInputEdit;
2014-03-15 15:15:59 -07:00
2014-07-17 23:29:11 -07:00
typedef unsigned short TSSymbol;
typedef struct TSLanguage TSLanguage;
2014-07-17 23:29:11 -07:00
typedef struct TSNode TSNode;
TSLength ts_node_pos(const TSNode *);
TSLength ts_node_size(const TSNode *);
2014-07-17 23:29:11 -07:00
TSSymbol ts_node_sym(const TSNode *);
TSNode *ts_node_child(TSNode *, size_t);
2014-07-20 17:57:20 -07:00
size_t ts_node_child_count(const TSNode *);
2014-08-25 09:31:27 -07:00
TSNode *ts_node_find_for_pos(TSNode *, size_t);
TSNode *ts_node_find_for_range(TSNode *, size_t, size_t);
TSNode *ts_node_parent(TSNode *node);
TSNode *ts_node_next_sibling(TSNode *node);
TSNode *ts_node_prev_sibling(TSNode *node);
const char *ts_node_name(const TSNode *);
const char *ts_node_string(const TSNode *);
2014-07-17 23:29:11 -07:00
void ts_node_retain(TSNode *node);
void ts_node_release(TSNode *node);
2014-10-03 16:06:08 -07:00
bool ts_node_eq(const TSNode *, const TSNode *);
2014-07-17 23:29:11 -07:00
typedef struct TSDocument TSDocument;
TSDocument *ts_document_make();
void ts_document_free(TSDocument *);
void ts_document_set_language(TSDocument *, const TSLanguage *);
void ts_document_set_input(TSDocument *, TSInput);
void ts_document_set_input_string(TSDocument *, const char *);
void ts_document_edit(TSDocument *, TSInputEdit);
TSDebugger ts_document_get_debugger(const TSDocument *);
void ts_document_set_debugger(TSDocument *, TSDebugger);
TSNode *ts_document_root_node(const TSDocument *);
2014-07-17 23:29:11 -07:00
#define ts_builtin_sym_error 0
#define ts_builtin_sym_end 1
#define ts_builtin_sym_document 2
#define ts_builtin_sym_ambiguity 3
#define ts_builtin_sym_start 4
2014-02-15 17:00:33 -08:00
#ifdef __cplusplus
}
#endif
2014-03-09 22:05:17 -07:00
#endif // TREE_SITTER_RUNTIME_H_