Store subtree's lookahead byte count relative to its end offset

This improves test coverage for incremental parsing by generalizing
the randomized tests in `real_grammars.cc` to make *multiple* edits
before incrementally re-parsing.
This commit is contained in:
Max Brunsfeld 2018-11-02 15:20:43 -07:00
parent 67a9cb3336
commit 2169c45da9
13 changed files with 132 additions and 140 deletions

View file

@ -398,8 +398,6 @@ static Subtree ts_parser__lex(TSParser *self, StackVersion version, TSStateId pa
last_byte_scanned = self->lexer.current_position.bytes;
}
uint32_t bytes_scanned = last_byte_scanned - start_position.bytes + 1;
Subtree result;
if (skipped_error) {
Length padding = length_sub(error_start_position, start_position);
@ -409,7 +407,7 @@ static Subtree ts_parser__lex(TSParser *self, StackVersion version, TSStateId pa
first_error_character,
padding,
size,
bytes_scanned,
last_byte_scanned + 1 - error_end_position.bytes,
parse_state,
self->language
);
@ -444,7 +442,7 @@ static Subtree ts_parser__lex(TSParser *self, StackVersion version, TSStateId pa
symbol,
padding,
size,
bytes_scanned,
last_byte_scanned + 1 - self->lexer.token_end_position.bytes,
parse_state,
found_external_token,
is_keyword,