mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
TokenType.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
5
6
7namespace m {
8
10{
11#define M_TOKENTYPE(tok) TK_##tok,
12#include <mutable/tables/TokenType.tbl>
13#undef M_TOKENTYPE
14 TokenType_MAX = TK_EOF
15};
16
17inline char const * get_name(const TokenType tt)
18{
19 switch (tt) {
20 case TK_ERROR: return "error";
21 case TK_EOF: return "eof";
22 case TK_BACKSLASH: return "\\";
23 case TK_IDENTIFIER: return "identifier";
24 case TK_STRING_LITERAL: return "string-literal";
25 case TK_DATE: return "date";
26 case TK_DATE_TIME: return "datetime";
27 case TK_INSTRUCTION: return "instruction";
28
29 case TK_OCT_INT:
30 case TK_DEC_INT:
31 case TK_HEX_INT:
32 case TK_DEC_FLOAT:
33 case TK_HEX_FLOAT:
34 return "constant";
35
36#define M_KEYWORD(tt, name) case TK_ ## tt:
37#include <mutable/tables/Keywords.tbl>
38#undef M_KEYWORD
39 return "keyword";
40
41#define M_OPERATOR(tt) case TK_ ## tt:
42#include <mutable/tables/Operators.tbl>
43#undef M_OPERATOR
44 return "punctuator";
45 }
46}
47
49inline std::ostream & operator<<(std::ostream &os, const TokenType tt)
50{
51 switch (tt) {
52#define M_TOKENTYPE(tok) case TK_ ## tok: return os << "TK_"#tok;
53#include <mutable/tables/TokenType.tbl>
54#undef M_TOKENTYPE
55 }
56}
57
58inline std::string to_string(const TokenType tt)
59{
60 switch (tt) {
61#define M_TOKENTYPE(tok) case TK_ ## tok: return "TK_"#tok;
62#include <mutable/tables/TokenType.tbl>
63#undef M_TOKENTYPE
64 }
65}
67
68}
‍mutable namespace
Definition: Backend.hpp:10
char const * get_name(const TokenType tt)
Definition: TokenType.hpp:17
std::string to_string(const TokenType tt)
Definition: TokenType.hpp:58
M_LCOV_EXCL_START std::ostream & operator<<(std::ostream &out, const PlanTableBase< Actual > &PT)
Definition: PlanTable.hpp:401
TokenType
Definition: TokenType.hpp:10
@ TokenType_MAX
Definition: TokenType.hpp:14