commit 547d116

shrub  ·  2026-11-17 15:06:18 +0000 UTC
parent e05c83a
better error for unterminated string
1 files changed,  +2, -1
M lex.re
M lex.re
+2, -1
 1@@ -32,6 +32,7 @@ void lex(struct lexer *l, struct token *t) {
 2 	[a-zA-Z_] [a-zA-Z_0-9]*                      { settok(l, t, TIDENT); return; }
 3 	[0-9]+                                       { settok(l, t, TNUMBER); return; }
 4 	'"' ( [^"\n\x00\\] | "\\" [^\n\x00] )* '"'   { settok(l, t, TSTRING); return; }
 5+	'"' ( [^"\n\x00\\] | "\\" [^\n\x00] )*       { settok(l, t, TSTRING); errorat(&t->loc, "unterminated string"); }
 6 
 7 	*                          { settok(l, t, TNONE); errorat(&t->loc, "unexpected character"); }
 8 	*/
 9@@ -39,7 +40,7 @@ void lex(struct lexer *l, struct token *t) {
10 	/*!re2c
11 	"*/"                       { goto loop; }
12 	"\n"                       { l->line++; l->linestart = l->cur; goto comment; }
13-        "\x00"                     { errorat(&t->loc, "unertminated comment"); }
14+        "\x00"                     { errorat(&t->loc, "unterminated comment"); }
15 	*                          { goto comment; }
16 	*/
17 }