From 60b17004a48809b05160fa759e7aa751d18d5210 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Fri, 3 Dec 2021 00:31:46 +0100 Subject: [PATCH] Backtrack on finding ` with "next" --- src/compiler/lexer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/lexer.c b/src/compiler/lexer.c index 3df7e3fdf..b61529c4b 100644 --- a/src/compiler/lexer.c +++ b/src/compiler/lexer.c @@ -1144,13 +1144,14 @@ static inline bool scan_raw_string(Lexer *lexer) char c; while ((c = next(lexer)) != '`' || peek(lexer) == '`') { - if (c == '`') next(lexer); - if (reached_end(lexer)) + if (c == '\0') { + backtrack(lexer); return add_error_token_at(lexer, lexer->lexing_start , 1, "Reached the end of the file looking for " "the end of the raw string that starts " "here. Did you forget a '`' somewhere?"); } + if (c == '`') next(lexer); } const char *current = lexer->lexing_start + 1; const char *end = lexer->current - 1;