From e55871195adfca7abd477abd3c5a8c95fe7da2c5 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 14 Apr 2024 17:05:39 +0630 Subject: Implemented overload for ostream and token as well as constructors for token --- asm/lexer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'asm') diff --git a/asm/lexer.cpp b/asm/lexer.cpp index 8b30c55..42ea5eb 100644 --- a/asm/lexer.cpp +++ b/asm/lexer.cpp @@ -396,3 +396,17 @@ lerr_t tokenise_buffer(string_view source, std::vector &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} +{} + -- cgit v1.2.3-13-gbd6f