lang: lex: only read linefeeds up to the end of the current line buffer

This commit is contained in:
2024-11-18 15:19:26 +00:00
parent 96172eac84
commit 5a5b0d01d8

View File

@@ -482,6 +482,11 @@ static int advance(struct ivy_lexer *lex)
return c; return c;
} }
static bool input_available(struct ivy_lexer* lex)
{
return lex->lex_linebuf_ptr < lex->lex_linebuf_len;
}
static bool char_can_begin_symbol(char c) static bool char_can_begin_symbol(char c)
{ {
for (size_t i = 0; i < nr_symbols; i++) { for (size_t i = 0; i < nr_symbols; i++) {
@@ -999,6 +1004,11 @@ static enum ivy_status pump_tokens(struct ivy_lexer *lex)
if (c == '\n') { if (c == '\n') {
while (c == '\n') { while (c == '\n') {
advance(lex); advance(lex);
if (!input_available(lex)) {
break;
}
c = peek(lex); c = peek(lex);
} }