vkdb
A time series database engine in C++.
Loading...
Searching...
No Matches
token.cpp
1#include <vkdb/token.h>
2
3namespace vkdb {
5 TokenType type,
6 const Lexeme& lexeme,
7 Token::size_type line,
8 Token::size_type column
9) noexcept
10 : type_{type}
11 , lexeme_{lexeme}
12 , line_{line}
13 , column_{column} {}
14
15bool Token::operator==(const Token& other) const noexcept {
16 return type_ == other.type() &&
17 lexeme_ == other.lexeme() &&
18 line_ == other.line() &&
19 column_ == other.column();
20}
21
22TokenType Token::type() const noexcept {
23 return type_;
24}
25
26Lexeme Token::lexeme() const noexcept {
27 return lexeme_;
28}
29
30Token::size_type Token::line() const noexcept {
31 return line_;
32}
33
34Token::size_type Token::column() const noexcept {
35 return column_;
36}
37
38std::string Token::str() const noexcept {
39 auto type_str{TOKEN_TYPE_TO_STRING.at(type_)};
40 return type_str + " "
41 + lexeme_ + " "
42 + std::to_string(line_) + " "
43 + std::to_string(column_);
44}
45} // namespace vkdb
Represents a token.
Definition token.h:81
size_type column() const noexcept
Get the column number of the token.
Definition token.cpp:34
bool operator==(const Token &other) const noexcept
Equality operator for Token objects.
Definition token.cpp:15
Token()=delete
Deleted default constructor.
Lexeme lexeme() const noexcept
Get the lexeme of the token.
Definition token.cpp:26
size_type line() const noexcept
Get the line number of the token.
Definition token.cpp:30
TokenType type() const noexcept
Get the type of the token.
Definition token.cpp:22
std::string str() const noexcept
Get the string representation of the token.
Definition token.cpp:38