aboutsummaryrefslogtreecommitdiff
path: root/lib/Lexer
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-21 14:03:31 +0000
committer_ov4 <ov4@ov4.org>2026-10-21 14:03:31 +0000
commitb4ffb2d9498560557821714e2d4651279dd6817c (patch)
tree995ad02bdb8cc461f48a53683c4fd7f2ddd8656b /lib/Lexer
parentf1f5fa394a67a789914ccf2b24d534a0e466ae1b (diff)
feat(diagnostics): print source diagnostics in gcc file:line: layout
Lexer, parser, driver and codegen diagnostics now read "<path>:<line>: error: <message>" instead of "error: <message> at line N in <path>". The path is always printed as given on the command line. Call sites pass the bare message to cps::sourceError/sourceWarning, which carry printf format checking; reportError routes through the same helper. The suite iii harness parses the new layout and matches the reason against the message only. iii/template-class-pack-field passed only because its reason regex matched the case path, so it is now case-insensitive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/Lexer')
-rw-r--r--lib/Lexer/Lexer.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Lexer/Lexer.cc b/lib/Lexer/Lexer.cc
index 91ce88a..437aed4 100644
--- a/lib/Lexer/Lexer.cc
+++ b/lib/Lexer/Lexer.cc
@@ -12,7 +12,7 @@ using namespace cps;
std::string Lexer::readEscape(bool IsChar) {
auto Error = [&](const char *Reason) {
- cps::sourceDiagnostic(TokenLine, "error: %s at line %d\n", Reason, TokenLine);
+ cps::sourceError(TokenLine, "%s", Reason);
HadError = true;
return std::string("?");
};
@@ -106,7 +106,7 @@ int Lexer::readToken() {
Directive.pop_back();
if (Directive == "#LIB") Library = true;
else {
- cps::sourceDiagnostic(TokenLine, "error: Unknown compiler directive at line %d\n", TokenLine);
+ cps::sourceError(TokenLine, "Unknown compiler directive");
HadError = true;
}
return readToken();
@@ -127,12 +127,12 @@ int Lexer::readToken() {
}
if (LastChar == Quote) LastChar = Input.get();
else {
- cps::sourceDiagnostic(TokenLine, "error: Unterminated %s literal at line %d\n", IsChar ? "char" : "string", TokenLine);
+ cps::sourceError(TokenLine, "Unterminated %s literal", IsChar ? "char" : "string");
HadError = true;
}
if (IsChar) {
if (StringVal.size() != 1) {
- cps::sourceDiagnostic(TokenLine, "error: CHAR literal must contain exactly one character at line %d\n", TokenLine);
+ cps::sourceError(TokenLine, "CHAR literal must contain exactly one character");
HadError = true;
}
CharVal = StringVal.size() == 1 ? StringVal[0] : '?';
@@ -154,7 +154,7 @@ int Lexer::readToken() {
std::transform(Prefix.begin(), Prefix.end(), Prefix.begin(),
[](unsigned char C) { return std::tolower(C); });
if (Prefix == "__cps_") {
- cps::sourceDiagnostic(TokenLine, "error: Reserved runtime identifier at line %d\n", TokenLine);
+ cps::sourceError(TokenLine, "Reserved runtime identifier");
HadError = true;
}
}
@@ -277,7 +277,7 @@ int Lexer::readToken() {
auto Parsed = std::from_chars(NumStr.data(), NumStr.data() + NumStr.size(), NumVal);
if (Parsed.ec != std::errc{} ||
NumVal > uint64_t(std::numeric_limits<int64_t>::max()) + 1) {
- cps::sourceDiagnostic(CurrentLine, "error: Integer literal is outside the i64 range at line %d\n", TokenLine);
+ cps::sourceError(TokenLine, "Integer literal is outside the i64 range");
HadError = true;
NumVal = 0;
}
@@ -327,7 +327,7 @@ int Lexer::readToken() {
LastChar = Input.get();
return tok_ellipsis;
}
- cps::sourceDiagnostic(CurrentLine, "error: Expected '...' at line %d\n", CurrentLine);
+ cps::sourceError(CurrentLine, "Expected '...'");
HadError = true;
LastChar = Input.get();
return tok_ellipsis;