Improve some error messages

This commit is contained in:
Rangi42
2025-07-24 11:19:04 -04:00
parent ded4ef4072
commit c6d0e8de63
8 changed files with 16 additions and 9 deletions

View File

@@ -982,8 +982,11 @@ static void discardLineContinuation() {
break; break;
} else if (c == ';') { } else if (c == ';') {
discardComment(); discardComment();
} else if (c == EOF) {
error("Invalid line continuation at end of file");
break;
} else { } else {
error("Begun line continuation, but encountered character %s", printChar(c)); error("Invalid character after line continuation %s", printChar(c));
break; break;
} }
} }

View File

@@ -459,7 +459,7 @@ yy::parser::symbol_type yylex() {
scriptError(context, "Unknown keyword \"%s\"", ident.c_str()); scriptError(context, "Unknown keyword \"%s\"", ident.c_str());
return yylex(); return yylex();
} else { } else {
scriptError(context, "Unexpected character '%s'", printChar(c)); scriptError(context, "Unexpected character %s", printChar(c));
// Keep reading characters until the EOL, to avoid reporting too many errors. // Keep reading characters until the EOL, to avoid reporting too many errors.
for (c = context.file.sgetc(); !isNewline(c); c = context.file.sgetc()) { for (c = context.file.sgetc(); !isNewline(c); c = context.file.sgetc()) {
if (c == EOF) { if (c == EOF) {

View File

@@ -0,0 +1 @@
assert 1 + 1 == 2 \

View File

@@ -0,0 +1,3 @@
error: line-continuation-at-eof.asm(1):
Invalid line continuation at end of file
Assembly aborted with 1 error!

View File

@@ -1,5 +1,5 @@
error: line-continuation.asm(3): error: line-continuation.asm(3):
Begun line continuation, but encountered character 's' Invalid character after line continuation 's'
warning: line-continuation.asm(6) -> line-continuation.asm::spam(4): [-Wuser] warning: line-continuation.asm(6) -> line-continuation.asm::spam(4): [-Wuser]
spam spam
error: line-continuation.asm(14): error: line-continuation.asm(14):

View File

@@ -1,5 +1,5 @@
error: macro-arg-0.asm(5) -> macro-arg-0.asm::m(2): error: macro-arg-0.asm(5) -> macro-arg-0.asm::m(2):
Begun line continuation, but encountered character '0' Invalid character after line continuation '0'
error: macro-arg-0.asm(5) -> macro-arg-0.asm::m(3): error: macro-arg-0.asm(5) -> macro-arg-0.asm::m(3):
Invalid bracketed macro argument '\<0>' Invalid bracketed macro argument '\<0>'
Assembly aborted with 2 errors! Assembly aborted with 2 errors!

View File

@@ -1,3 +1,3 @@
error: macro-arg-recursion.asm(6) -> macro-arg-recursion.asm::m(2): error: macro-arg-recursion.asm(6) -> macro-arg-recursion.asm::m(2):
Begun line continuation, but encountered character '2' Invalid character after line continuation '2'
Assembly aborted with 1 error! Assembly aborted with 1 error!

View File

@@ -1,17 +1,17 @@
error: null-outside-string.asm(3): error: null-outside-string.asm(3):
Begun line continuation, but encountered character '0' Invalid character after line continuation '0'
error: null-outside-string.asm(3): error: null-outside-string.asm(3):
syntax error, unexpected number syntax error, unexpected number
error: null-outside-string.asm(4): error: null-outside-string.asm(4):
Begun line continuation, but encountered character '0' Invalid character after line continuation '0'
error: null-outside-string.asm(4): error: null-outside-string.asm(4):
syntax error, unexpected number syntax error, unexpected number
error: null-outside-string.asm(6): error: null-outside-string.asm(6):
Begun line continuation, but encountered character 'X' Invalid character after line continuation 'X'
error: null-outside-string.asm(6): error: null-outside-string.asm(6):
syntax error, unexpected symbol syntax error, unexpected symbol
error: null-outside-string.asm(7): error: null-outside-string.asm(7):
Begun line continuation, but encountered character 'X' Invalid character after line continuation 'X'
error: null-outside-string.asm(7): error: null-outside-string.asm(7):
syntax error, unexpected symbol syntax error, unexpected symbol
Assembly aborted with 8 errors! Assembly aborted with 8 errors!