Inja
3.5.0
A Template Engine for Modern C++
Loading...
Searching...
No Matches
include
inja
token.hpp
1
#ifndef INCLUDE_INJA_TOKEN_HPP_
2
#define INCLUDE_INJA_TOKEN_HPP_
3
4
#include <string>
5
#include <string_view>
6
7
namespace
inja {
8
12
struct
Token {
13
enum class
Kind {
14
Text,
15
ExpressionOpen,
// {{
16
ExpressionClose,
// }}
17
LineStatementOpen,
// ##
18
LineStatementClose,
// \n
19
StatementOpen,
// {%
20
StatementClose,
// %}
21
CommentOpen,
// {#
22
CommentClose,
// #}
23
Id,
// this, this.foo
24
Number,
// 1, 2, -1, 5.2, -5.3
25
String,
// "this"
26
Plus,
// +
27
Minus,
// -
28
Times,
// *
29
Slash,
// /
30
Percent,
// %
31
Power,
// ^
32
Comma,
// ,
33
Dot,
// .
34
Colon,
// :
35
LeftParen,
// (
36
RightParen,
// )
37
LeftBracket,
// [
38
RightBracket,
// ]
39
LeftBrace,
// {
40
RightBrace,
// }
41
Equal,
// ==
42
NotEqual,
// !=
43
GreaterThan,
// >
44
GreaterEqual,
// >=
45
LessThan,
// <
46
LessEqual,
// <=
47
Pipe,
// |
48
Unknown,
49
Eof,
50
};
51
52
Kind kind {Kind::Unknown};
53
std::string_view text;
54
55
explicit
constexpr
Token() =
default
;
56
explicit
constexpr
Token(Kind kind, std::string_view text): kind(kind), text(text) {}
57
58
std::string describe()
const
{
59
switch
(kind) {
60
case
Kind::Text:
61
return
"<text>"
;
62
case
Kind::LineStatementClose:
63
return
"<eol>"
;
64
case
Kind::Eof:
65
return
"<eof>"
;
66
default
:
67
return
static_cast<
std::string
>
(text);
68
}
69
}
70
};
71
72
}
// namespace inja
73
74
#endif
// INCLUDE_INJA_TOKEN_HPP_
Generated by
1.14.0