Pass edit information into parser function
This commit is contained in:
parent
464a0e8dad
commit
0d6435e24a
6 changed files with 35 additions and 24 deletions
|
|
@ -30,12 +30,11 @@ const char * ts_document_string(const ts_document *document) {
|
|||
|
||||
void ts_document_set_input(ts_document *document, ts_input input) {
|
||||
document->input = input;
|
||||
document->tree = ts_parser_parse(&document->parser, input);
|
||||
document->tree = ts_parser_parse(&document->parser, input, NULL);
|
||||
}
|
||||
|
||||
void ts_document_edit(ts_document *document, size_t position, size_t bytes_removed, size_t bytes_inserted) {
|
||||
document->input.seek_fn(document->input.data, 0);
|
||||
document->tree = ts_parser_parse(&document->parser, document->input);
|
||||
void ts_document_edit(ts_document *document, ts_input_edit edit) {
|
||||
document->tree = ts_parser_parse(&document->parser, document->input, &edit);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "tree_sitter/runtime.h"
|
||||
|
||||
const ts_tree * ts_parser_parse(ts_parser *parser, ts_input input) {
|
||||
return parser->parse_fn(parser->data, input);
|
||||
const ts_tree * ts_parser_parse(ts_parser *parser, ts_input input, ts_input_edit *edit) {
|
||||
return parser->parse_fn(parser->data, input, edit);
|
||||
}
|
||||
|
||||
void ts_parser_free(ts_parser *parser) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ typedef struct {
|
|||
} ts_stack;
|
||||
|
||||
static int INITIAL_STACK_SIZE = 100;
|
||||
static int INITIAL_STATE = 0;
|
||||
|
||||
ts_stack ts_stack_make() {
|
||||
ts_stack result = {
|
||||
|
|
@ -23,7 +24,7 @@ ts_stack ts_stack_make() {
|
|||
}
|
||||
|
||||
state_id ts_stack_top_state(const ts_stack *stack) {
|
||||
if (stack->size == 0) return 0;
|
||||
if (stack->size == 0) return INITIAL_STATE;
|
||||
return stack->entries[stack->size - 1].state;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue