Fix code paths that still conflated null characters with EOF

This commit is contained in:
Max Brunsfeld 2019-12-06 15:26:57 -08:00
parent 47a926067d
commit 0cb2ef1082
4 changed files with 15 additions and 4 deletions

View file

@ -439,7 +439,7 @@ static Subtree ts_parser__lex(
}
if (self->lexer.current_position.bytes == error_end_position.bytes) {
if (self->lexer.data.lookahead == 0) {
if (self->lexer.data.eof(&self->lexer.data)) {
self->lexer.data.result_symbol = ts_builtin_sym_error;
break;
}

View file

@ -766,10 +766,10 @@ Subtree ts_subtree_last_external_token(Subtree tree) {
}
static size_t ts_subtree__write_char_to_string(char *s, size_t n, int32_t c) {
if (c == 0)
return snprintf(s, n, "EOF");
if (c == -1)
return snprintf(s, n, "INVALID");
else if (c == '\0')
return snprintf(s, n, "'\\0'");
else if (c == '\n')
return snprintf(s, n, "'\\n'");
else if (c == '\t')