2014-02-15 17:00:33 -08:00
|
|
|
#ifndef tree_sitter_runtime_h
|
|
|
|
|
#define tree_sitter_runtime_h
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2014-02-20 18:38:31 -08:00
|
|
|
|
2014-02-15 17:00:33 -08:00
|
|
|
typedef struct {
|
|
|
|
|
size_t position;
|
2014-02-20 18:38:31 -08:00
|
|
|
char lookahead_char;
|
|
|
|
|
size_t expected_input_count;
|
|
|
|
|
const char **expected_inputs;
|
2014-02-20 13:30:43 -08:00
|
|
|
} ts_error;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 18:38:31 -08:00
|
|
|
const char * ts_error_string(const ts_error *error);
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
typedef size_t ts_symbol;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
typedef struct ts_tree {
|
|
|
|
|
ts_symbol value;
|
|
|
|
|
struct ts_tree **children;
|
2014-02-15 17:00:33 -08:00
|
|
|
size_t child_count;
|
|
|
|
|
size_t ref_count;
|
2014-02-20 13:30:43 -08:00
|
|
|
} ts_tree;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
ts_tree * ts_tree_make(ts_symbol value, size_t child_count, ts_tree **children);
|
|
|
|
|
void ts_tree_retain(ts_tree *tree);
|
|
|
|
|
void ts_tree_release(ts_tree *tree);
|
|
|
|
|
int ts_tree_equals(const ts_tree *tree1, const ts_tree *tree2);
|
|
|
|
|
char * ts_tree_string(const ts_tree *tree, const char **names);
|
2014-02-15 17:00:33 -08:00
|
|
|
|
|
|
|
|
typedef struct {
|
2014-02-20 13:30:43 -08:00
|
|
|
ts_error error;
|
|
|
|
|
ts_tree *tree;
|
|
|
|
|
} ts_parse_result;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
typedef ts_parse_result ts_parse_fn(const char *);
|
2014-02-15 17:00:33 -08:00
|
|
|
|
|
|
|
|
typedef struct {
|
2014-02-20 13:30:43 -08:00
|
|
|
ts_parse_fn *parse_fn;
|
2014-02-15 17:00:33 -08:00
|
|
|
const char **symbol_names;
|
2014-02-20 13:30:43 -08:00
|
|
|
} ts_parse_config;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
typedef struct ts_document ts_document;
|
2014-02-15 17:00:33 -08:00
|
|
|
|
2014-02-20 13:30:43 -08:00
|
|
|
ts_document * ts_document_make();
|
2014-02-20 18:38:31 -08:00
|
|
|
void ts_document_free(ts_document *);
|
2014-02-20 13:30:43 -08:00
|
|
|
void ts_document_set_parser(ts_document *document, ts_parse_config config);
|
|
|
|
|
void ts_document_set_text(ts_document *document, const char *text);
|
|
|
|
|
ts_tree * ts_document_tree(const ts_document *document);
|
|
|
|
|
const char * ts_document_string(const ts_document *document);
|
2014-02-15 17:00:33 -08:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|