6#include <unordered_map>
7#include <unordered_set>
14using Lexeme = std::string;
21 SELECT, PUT, DELETE, CREATE, DROP, ADD, REMOVE,
22 DATA, AVG, SUM, COUNT, MIN, MAX,
23 TABLE, TABLES, TAGS, ALL, BETWEEN, AND, AT, WHERE, FROM, INTO, TO,
24 EQUAL, COMMA, SEMICOLON,
33static const std::unordered_set<TokenType> QUERY_BASE_WORDS{
34 TokenType::SELECT, TokenType::PUT, TokenType::DELETE,
35 TokenType::CREATE, TokenType::DROP, TokenType::ADD, TokenType::REMOVE,
43static const std::unordered_map<TokenType, std::string> TOKEN_TYPE_TO_STRING{
44 {TokenType::SELECT,
"SELECT"},
45 {TokenType::PUT,
"PUT"},
46 {TokenType::DELETE,
"DELETE"},
47 {TokenType::CREATE,
"CREATE"},
48 {TokenType::DROP,
"DROP"},
49 {TokenType::ADD,
"ADD"},
50 {TokenType::REMOVE,
"REMOVE"},
51 {TokenType::TABLES,
"TABLES"},
52 {TokenType::DATA,
"DATA"},
53 {TokenType::AVG,
"AVG"},
54 {TokenType::SUM,
"SUM"},
55 {TokenType::COUNT,
"COUNT"},
56 {TokenType::MIN,
"MIN"},
57 {TokenType::MAX,
"MAX"},
58 {TokenType::TABLE,
"TABLE"},
59 {TokenType::TAGS,
"TAGS"},
60 {TokenType::ALL,
"ALL"},
61 {TokenType::BETWEEN,
"BETWEEN"},
62 {TokenType::AND,
"AND"},
63 {TokenType::AT,
"AT"},
64 {TokenType::WHERE,
"WHERE"},
65 {TokenType::FROM,
"FROM"},
66 {TokenType::INTO,
"INTO"},
67 {TokenType::TO,
"TO"},
68 {TokenType::EQUAL,
"EQUAL"},
69 {TokenType::COMMA,
"COMMA"},
70 {TokenType::SEMICOLON,
"SEMICOLON"},
71 {TokenType::IDENTIFIER,
"IDENTIFIER"},
72 {TokenType::NUMBER,
"NUMBER"},
73 {TokenType::END_OF_FILE,
"END_OF_FILE"},
74 {TokenType::UNKNOWN,
"UNKNOWN"}
83 using size_type = uint64_t;
144 [[nodiscard]]
bool operator==(const
Token& other) const noexcept;
151 [[nodiscard]] TokenType
type() const noexcept;
158 [[nodiscard]] Lexeme
lexeme() const noexcept;
165 [[nodiscard]] size_type
line() const noexcept;
172 [[nodiscard]] size_type
column() const noexcept;
179 [[nodiscard]]
std::
string str() const noexcept;
size_type column() const noexcept
Get the column number of the token.
Token()=delete
Deleted default constructor.
Lexeme lexeme() const noexcept
Get the lexeme of the token.
size_type line() const noexcept
Get the line number of the token.
TokenType type() const noexcept
Get the type of the token.
Token(Token &&) noexcept=default
Move-construct a Token object.
std::string str() const noexcept
Get the string representation of the token.