In lexer, stop reading input as soon as empty string is returned
This commit is contained in:
parent
03a5a97992
commit
4720672cfb
1 changed files with 3 additions and 3 deletions
|
|
@ -6,12 +6,12 @@ static int advance(TSLexer *lexer) {
|
|||
if (lexer->position_in_chunk + 1 < lexer->chunk_size) {
|
||||
lexer->position_in_chunk++;
|
||||
} else {
|
||||
if (lexer->reached_end)
|
||||
return 0;
|
||||
|
||||
lexer->chunk_start += lexer->chunk_size;
|
||||
lexer->chunk = lexer->input.read_fn(lexer->input.data, &lexer->chunk_size);
|
||||
lexer->position_in_chunk = 0;
|
||||
if (lexer->reached_end) {
|
||||
return 0;
|
||||
}
|
||||
if (lexer->chunk_size == 0) {
|
||||
lexer->reached_end = 1;
|
||||
lexer->chunk = empty_chunk;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue