mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 03:52:08 +00:00
Error messages refer to "undefined" symbols and sections
This commit is contained in:
@@ -594,9 +594,9 @@ std::string act_SectionName(std::string const &symName) {
|
||||
Symbol *sym = sym_FindScopedValidSymbol(symName);
|
||||
if (!sym) {
|
||||
if (sym_IsPurgedScoped(symName)) {
|
||||
fatal("Unknown symbol \"%s\"; it was purged", symName.c_str());
|
||||
fatal("Undefined symbol \"%s\"; it was purged", symName.c_str());
|
||||
} else {
|
||||
fatal("Unknown symbol \"%s\"", symName.c_str());
|
||||
fatal("Undefined symbol \"%s\"", symName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -370,9 +370,9 @@ void fstk_RunMacro(std::string const ¯oName, std::shared_ptr<MacroArgs> macr
|
||||
|
||||
if (!macro) {
|
||||
if (sym_IsPurgedExact(macroName)) {
|
||||
error("Macro \"%s\" not defined; it was purged", macroName.c_str());
|
||||
error("Undefined macro \"%s\"; it was purged", macroName.c_str());
|
||||
} else {
|
||||
error("Macro \"%s\" not defined", macroName.c_str());
|
||||
error("Undefined macro \"%s\"", macroName.c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ static uint32_t readBracketedMacroArgNum() {
|
||||
|
||||
c = bumpChar();
|
||||
if (c != '>') {
|
||||
error("Invalid character in bracketed macro argument %s", printChar(c));
|
||||
error("Invalid character %s in bracketed macro argument", printChar(c));
|
||||
return 0;
|
||||
} else if (empty) {
|
||||
error("Empty bracketed macro argument");
|
||||
@@ -911,7 +911,7 @@ static void discardLineContinuation() {
|
||||
error("Invalid line continuation at end of file");
|
||||
break;
|
||||
} else {
|
||||
error("Invalid character after line continuation %s", printChar(c));
|
||||
error("Invalid character %s after line continuation", printChar(c));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1568,17 +1568,19 @@ static bool isGarbageCharacter(int c) {
|
||||
static void reportGarbageCharacters(int c) {
|
||||
// '#' can be garbage if it doesn't start a raw string or identifier
|
||||
assume(isGarbageCharacter(c) || c == '#');
|
||||
bool isAscii = isPrintable(c);
|
||||
if (isGarbageCharacter(peek())) {
|
||||
// At least two characters are garbage; group them into one error report
|
||||
std::string garbage = printChar(c);
|
||||
while (isGarbageCharacter(peek())) {
|
||||
c = bumpChar();
|
||||
isAscii &= isPrintable(c);
|
||||
garbage += ", ";
|
||||
garbage += printChar(c);
|
||||
}
|
||||
error("Unknown characters %s", garbage.c_str());
|
||||
error("Invalid characters %s%s", garbage.c_str(), isAscii ? "" : " (is the file UTF-8?)");
|
||||
} else {
|
||||
error("Unknown character %s", printChar(c));
|
||||
error("Invalid character %s%s", printChar(c), isAscii ? "" : " (is the file UTF-8?)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -284,9 +284,9 @@ void sym_Purge(std::string const &symName) {
|
||||
|
||||
if (!sym) {
|
||||
if (sym_IsPurgedScoped(symName)) {
|
||||
error("'%s' was already purged", symName.c_str());
|
||||
error("Undefined symbol '%s' was already purged", symName.c_str());
|
||||
} else {
|
||||
error("'%s' not defined", symName.c_str());
|
||||
error("Undefined symbol '%s'", symName.c_str());
|
||||
}
|
||||
} else if (sym->isBuiltin) {
|
||||
error("Built-in symbol '%s' cannot be purged", symName.c_str());
|
||||
|
||||
@@ -223,7 +223,7 @@ void layout_PlaceSection(std::string const &name, bool isOptional) {
|
||||
Section *section = sect_GetSection(name.c_str());
|
||||
if (!section) {
|
||||
if (!isOptional) {
|
||||
lexer_Error("Unknown section \"%s\"", name.c_str());
|
||||
lexer_Error("Undefined section \"%s\"", name.c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) {
|
||||
errorAt(
|
||||
patch,
|
||||
"Requested BANK() of symbol \"%s\", which was not found",
|
||||
"Requested BANK() of undefined symbol \"%s\"",
|
||||
fileSymbols[value].name.c_str()
|
||||
);
|
||||
isError = true;
|
||||
@@ -302,7 +302,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
while (getRPNByte(expression, size, patch)) {}
|
||||
|
||||
if (Section const *sect = sect_GetSection(name); !sect) {
|
||||
errorAt(patch, "Requested BANK() of section \"%s\", which was not found", name);
|
||||
errorAt(patch, "Requested BANK() of undefined section \"%s\"", name);
|
||||
isError = true;
|
||||
value = 1;
|
||||
} else {
|
||||
@@ -327,7 +327,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
while (getRPNByte(expression, size, patch)) {}
|
||||
|
||||
if (Section const *sect = sect_GetSection(name); !sect) {
|
||||
errorAt(patch, "Requested SIZEOF() of section \"%s\", which was not found", name);
|
||||
errorAt(patch, "Requested SIZEOF() of undefined section \"%s\"", name);
|
||||
isError = true;
|
||||
value = 1;
|
||||
} else {
|
||||
@@ -342,7 +342,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
while (getRPNByte(expression, size, patch)) {}
|
||||
|
||||
if (Section const *sect = sect_GetSection(name); !sect) {
|
||||
errorAt(patch, "Requested STARTOF() of section \"%s\", which was not found", name);
|
||||
errorAt(patch, "Requested STARTOF() of undefined section \"%s\"", name);
|
||||
isError = true;
|
||||
value = 1;
|
||||
} else {
|
||||
@@ -427,7 +427,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
isError = true;
|
||||
}
|
||||
} else if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) {
|
||||
errorAt(patch, "Unknown symbol \"%s\"", fileSymbols[value].name.c_str());
|
||||
errorAt(patch, "Undefined symbol \"%s\"", fileSymbols[value].name.c_str());
|
||||
sym_DumpLocalAliasedSymbols(fileSymbols[value].name);
|
||||
isError = true;
|
||||
} else if (std::holds_alternative<Label>(symbol->data)) {
|
||||
|
||||
@@ -13,6 +13,10 @@ bool isNewline(int c) {
|
||||
return c == '\r' || c == '\n';
|
||||
}
|
||||
|
||||
bool isPrintable(int c) {
|
||||
return c >= ' ' && c <= '~';
|
||||
}
|
||||
|
||||
bool startsIdentifier(int c) {
|
||||
// This returns false for anonymous labels, which internally start with a '!',
|
||||
// and for section fragment literal labels, which internally start with a '$'.
|
||||
@@ -34,7 +38,7 @@ char const *printChar(int c) {
|
||||
}
|
||||
|
||||
// Handle printable ASCII characters
|
||||
if (c >= ' ' && c <= '~') {
|
||||
if (isPrintable(c)) {
|
||||
buf[0] = '\'';
|
||||
buf[1] = c;
|
||||
buf[2] = '\'';
|
||||
|
||||
Reference in New Issue
Block a user