|
|
@ -60,17 +60,15 @@ void Job::printErrorLine(Token token, const char* message) |
|
|
|
"%s" |
|
|
|
"%s" |
|
|
|
"\n"; |
|
|
|
"\n"; |
|
|
|
printf(errorFormat.c_str(), |
|
|
|
printf(errorFormat.c_str(), |
|
|
|
token.line, |
|
|
|
token.line + 1, |
|
|
|
token.column, |
|
|
|
token.column + 1, |
|
|
|
message); |
|
|
|
message); |
|
|
|
|
|
|
|
|
|
|
|
// Get the JSON line that caused the error
|
|
|
|
// Get the JSON line that caused the error
|
|
|
|
std::istringstream input(m_input); |
|
|
|
std::istringstream input(m_input); |
|
|
|
std::string line; |
|
|
|
std::string line; |
|
|
|
size_t count = 0; |
|
|
|
for (size_t i = 0; std::getline(input, line); ++i) { |
|
|
|
while (std::getline(input, line)) { |
|
|
|
if (i == token.line) { |
|
|
|
count++; |
|
|
|
|
|
|
|
if (count == token.line) { |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -92,9 +90,9 @@ void Job::printErrorLine(Token token, const char* message) |
|
|
|
"\033[0m" // Reset
|
|
|
|
"\033[0m" // Reset
|
|
|
|
"\n"; |
|
|
|
"\n"; |
|
|
|
printf(lineFormat.c_str(), |
|
|
|
printf(lineFormat.c_str(), |
|
|
|
token.line, |
|
|
|
token.line + 1, |
|
|
|
line.substr(0, token.column - 1).c_str(), |
|
|
|
line.substr(0, token.column).c_str(), |
|
|
|
line.substr(token.column - 1).c_str()); |
|
|
|
line.substr(token.column).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Arrow pointer
|
|
|
|
// Arrow pointer
|
|
|
|
std::string arrowFormat = " %s | " |
|
|
|
std::string arrowFormat = " %s | " |
|
|
@ -104,7 +102,7 @@ void Job::printErrorLine(Token token, const char* message) |
|
|
|
"\n"; |
|
|
|
"\n"; |
|
|
|
printf(arrowFormat.c_str(), |
|
|
|
printf(arrowFormat.c_str(), |
|
|
|
std::string(m_lineNumbersWidth, ' ').c_str(), |
|
|
|
std::string(m_lineNumbersWidth, ' ').c_str(), |
|
|
|
std::string(token.column - 1, ' ').c_str(), |
|
|
|
std::string(token.column, ' ').c_str(), |
|
|
|
std::string(line.length() - token.column, '~').c_str()); |
|
|
|
std::string(line.length() - token.column, '~').c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|