diff --git a/src/Diagnostics/DiagnosticsHolder.cpp b/src/Diagnostics/DiagnosticsHolder.cpp index 41c245e..0139081 100644 --- a/src/Diagnostics/DiagnosticsHolder.cpp +++ b/src/Diagnostics/DiagnosticsHolder.cpp @@ -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()); diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index 3773bbb..39b5b8d 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -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 { diff --git a/tests/integration/DiagnosticsTests.cpp b/tests/integration/DiagnosticsTests.cpp index 1ed9e31..11c79e5 100644 --- a/tests/integration/DiagnosticsTests.cpp +++ b/tests/integration/DiagnosticsTests.cpp @@ -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; }