Add backslash to invalid control character error, made pretty error messages use 1-based line index
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-19 13:33:01 +02:00
parent 8541085b27
commit 6bcedaf743
3 changed files with 4 additions and 4 deletions

View File

@@ -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());

View File

@@ -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 {