Add backslash to invalid control character error, made pretty error messages use 1-based line index
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8541085b27
commit
6bcedaf743
|
@ -103,7 +103,7 @@ std::string DiagnosticsHolder::GetFullErrorMessage(Diagnostic diagnostic) {
|
|||
auto startPos = diagnostic.GetStartPosition();
|
||||
auto line = this -> GetLineFromPosition(startPos);
|
||||
auto linePos = startPos - this ->GetStartPositionForLine(line);
|
||||
stream << " (" << line << ", " << linePos << ") ";
|
||||
stream << " (" << line + 1 << ", " << linePos + 1 << ") ";
|
||||
auto unformatted = ErrorMessages.find(diagnostic.GetCode());
|
||||
if (unformatted != ErrorMessages.end()){
|
||||
stream << PrettyDiagnostic(unformatted->second, diagnostic.GetArguments());
|
||||
|
|
|
@ -304,9 +304,9 @@ namespace Porygon::Parser {
|
|||
if (ControlCharacters.find(c) != ControlCharacters.end()) {
|
||||
stream << ControlCharacters.at(c);
|
||||
} else {
|
||||
auto v = string(1, c).c_str();
|
||||
auto v = ("\\" + string(1, c)).c_str();
|
||||
this->ScriptData->Diagnostics->LogError(Diagnostics::DiagnosticCode::InvalidStringControlCharacter,
|
||||
start + 1 + i, 1, {v});
|
||||
start + i, 2, {v});
|
||||
stream << c;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ TEST_CASE( "Get full diagnostic message", "[integration]" ) {
|
|||
REQUIRE(script->Diagnostics -> HasErrors());
|
||||
auto diags = script->Diagnostics -> GetDiagnostics();
|
||||
auto msg = script -> Diagnostics -> GetFullErrorMessage(diags[0]);
|
||||
REQUIRE(msg == "[Error] (1, 2) 'x' is not a valid control character.");
|
||||
REQUIRE(msg == "[Error] (2, 2) '\\x' is not a valid control character.");
|
||||
delete script;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue