Implemented overload for ostream and token as well as constructors for token

This commit is contained in:
2024-04-14 17:05:39 +06:30
parent a8f605c89b
commit e55871195a

View File

@@ -396,3 +396,17 @@ lerr_t tokenise_buffer(string_view source, std::vector<token_t> &tokens)
}
return lerr_t::OK;
}
std::ostream &operator<<(std::ostream &os, token_t &t)
{
return os << "TOKEN[" << token_type_as_cstr(t.type) << "(`" << t.content
<< "`)@" << t.line << ", " << t.column << "]";
}
token_t::token_t()
{}
token_t::token_t(token_type_t type, string content, size_t col, size_t line)
: type{type}, column{col}, line{line}, content{content}
{}