Improve syntax error reporting
This commit is contained in:
@@ -5,9 +5,11 @@
|
||||
|
||||
void PrintBadToken(Token::Token const & token, std::vector<std::string> const & lines)
|
||||
{
|
||||
std::printf("at line number %i, column %i:\n",
|
||||
std::printf("at line number %i, column %i: ",
|
||||
token.lineNumber + 1,
|
||||
token.lineColumn + 1);
|
||||
std::puts(token.errorMessage.c_str());
|
||||
|
||||
std::printf("%s\n", lines[token.lineNumber].c_str());
|
||||
for(int i = 0; i < token.lineColumn; ++i)
|
||||
{
|
||||
@@ -109,6 +111,7 @@ bool Wassembler::LoadFromFile(std::string const & filePath)
|
||||
catch(Interpret::InterpretationError & e)
|
||||
{
|
||||
PrintBadToken(e.errorToken, lines);
|
||||
std::puts("Aborting due to semantic error(s)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user