Token to_string now include source name and is printed error style

So instead of the previous weird format, we have the format
<source_name>:<line>:<column>: <TYPE> which also allows me to quickly
go to that token via Emacs' (compile).
This commit is contained in:
2024-07-06 17:36:58 +01:00
parent f9acb23671
commit 1145b97c4c
3 changed files with 5 additions and 6 deletions

View File

@@ -556,13 +556,13 @@ namespace Lexer
std::string to_string(const Token &t)
{
std::stringstream stream;
stream << to_string(t.type);
stream << t.source_name << ":" << t.line << ":" << t.column << ": "
<< to_string(t.type);
if (t.operand_type != Token::OperandType::NIL)
stream << "[" << to_string(t.operand_type) << "]";
if (t.content != "")
stream << "(`" << t.content << "`)";
stream << "@" << t.line << ", " << t.column;
return stream.str();
}