diff --git a/include/tree_sitter/parser.h b/include/tree_sitter/parser.h index 27a3eb1d..c34396f1 100644 --- a/include/tree_sitter/parser.h +++ b/include/tree_sitter/parser.h @@ -72,7 +72,7 @@ ts_lexer_start_token(lexer); SYMBOL_NAMES; -static const TSTree * ts_parse(void *data, ts_input input, ts_input_edit *edit) { +static const TSTree * ts_parse(void *data, TSInput input, ts_input_edit *edit) { ts_lr_parser *parser = (ts_lr_parser *)data; ts_lr_parser_initialize(parser, input, edit); for (;;) { diff --git a/include/tree_sitter/parser/lexer.h b/include/tree_sitter/parser/lexer.h index aef0906e..2f731db0 100644 --- a/include/tree_sitter/parser/lexer.h +++ b/include/tree_sitter/parser/lexer.h @@ -6,7 +6,7 @@ #define ts_lex_state_error 0 typedef struct { - ts_input input; + TSInput input; const char *chunk; size_t chunk_start; size_t chunk_size; diff --git a/include/tree_sitter/parser/lr_parser.h b/include/tree_sitter/parser/lr_parser.h index 4df40bac..be98c27e 100644 --- a/include/tree_sitter/parser/lr_parser.h +++ b/include/tree_sitter/parser/lr_parser.h @@ -59,7 +59,7 @@ ts_lr_parser * ts_lr_parser_make(size_t symbol_count, TSTree * (* lex_fn)(ts_lexer *, TSStateId), const int *hidden_symbol_flags); void ts_lr_parser_free(void *data); -void ts_lr_parser_initialize(ts_lr_parser *parser, ts_input input, ts_input_edit *edit); +void ts_lr_parser_initialize(ts_lr_parser *parser, TSInput input, ts_input_edit *edit); TSTree * ts_lr_parser_parse(ts_lr_parser *parser, const char **symbol_names); #ifdef __cplusplus diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index 85973a96..563e3f22 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -33,7 +33,7 @@ typedef struct { const char * (* read_fn)(void *data, size_t *bytes_read); int (* seek_fn)(void *data, size_t position); void (* release_fn)(void *data); -} ts_input; +} TSInput; typedef struct { size_t position; @@ -42,20 +42,20 @@ typedef struct { } ts_input_edit; typedef struct { - const TSTree * (* parse_fn)(void *data, ts_input input, ts_input_edit *edit); + const TSTree * (* parse_fn)(void *data, TSInput input, ts_input_edit *edit); void (* free_fn)(void *data); const char **symbol_names; void *data; } ts_parser; -const TSTree * ts_parser_parse(ts_parser *, ts_input, ts_input_edit *edit); +const TSTree * ts_parser_parse(ts_parser *, TSInput, ts_input_edit *edit); void ts_parser_free(ts_parser *); typedef struct TSDocument TSDocument; TSDocument * ts_document_make(); void ts_document_free(TSDocument *doc); void ts_document_set_parser(TSDocument *doc, ts_parser parser); -void ts_document_set_input(TSDocument *doc, ts_input input); +void ts_document_set_input(TSDocument *doc, TSInput input); void ts_document_set_input_string(TSDocument *doc, const char *text); void ts_document_edit(TSDocument *doc, ts_input_edit edit); const TSTree * ts_document_tree(const TSDocument *doc); diff --git a/spec/runtime/helpers/spy_reader.h b/spec/runtime/helpers/spy_reader.h index 1ad90d39..fd19cbce 100644 --- a/spec/runtime/helpers/spy_reader.h +++ b/spec/runtime/helpers/spy_reader.h @@ -12,7 +12,7 @@ public: std::string content; size_t position; size_t chunk_size; - ts_input input; + TSInput input; std::vector strings_read; }; diff --git a/src/runtime/document.c b/src/runtime/document.c index c391dd99..fc6eb0e8 100644 --- a/src/runtime/document.c +++ b/src/runtime/document.c @@ -4,7 +4,7 @@ struct TSDocument { ts_parser parser; const TSTree *tree; - ts_input input; + TSInput input; size_t error_count; }; @@ -32,7 +32,7 @@ const char * ts_document_string(const TSDocument *document) { return ts_tree_string(document->tree, document->parser.symbol_names); } -void ts_document_set_input(TSDocument *document, ts_input input) { +void ts_document_set_input(TSDocument *document, TSInput input) { document->input = input; document->tree = document->parser.parse_fn(document->parser.data, input, NULL); } @@ -69,12 +69,12 @@ int ts_string_input_seek(void *d, size_t position) { return (position < data->length); } -ts_input ts_string_input_make(const char *string) { +TSInput ts_string_input_make(const char *string) { ts_string_input_data *data = malloc(sizeof(ts_string_input_data)); data->string = string; data->position = 0; data->length = strlen(string); - ts_input input = { + TSInput input = { .data = (void *)data, .read_fn = ts_string_input_read, .seek_fn = ts_string_input_seek, diff --git a/src/runtime/lr_parser.c b/src/runtime/lr_parser.c index 27b3248b..52c6416c 100644 --- a/src/runtime/lr_parser.c +++ b/src/runtime/lr_parser.c @@ -186,7 +186,7 @@ void ts_lr_parser_free(void *data) { free(parser); } -void ts_lr_parser_initialize(ts_lr_parser *parser, ts_input input, ts_input_edit *edit) { +void ts_lr_parser_initialize(ts_lr_parser *parser, TSInput input, ts_input_edit *edit) { if (!edit) ts_stack_shrink(&parser->stack, 0); parser->lookahead = NULL; parser->next_lookahead = NULL;