-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.cpp
33 lines (31 loc) · 720 Bytes
/
token.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
enum class Token {
ILLEGAL,
FILEEND,
NEWLINE,
DEFINE,
DO,
END,
IDENT ,
INT ,
ASSIGN ,
PLUS ,
LPAREN ,
RPAREN
};
constexpr const char* getTokenLiteral(Token type) {
switch(type) {
case Token::ILLEGAL: return "ILLEGAL";
case Token::FILEEND: return "EOF";
case Token::NEWLINE: return "\n";
case Token::DEFINE: return "def";
case Token::DO: return "do";
case Token::END: return "end";
case Token::IDENT: return "IDENT"; // Identifie
case Token::INT: return "INT"; //Integer litera
case Token::ASSIGN: return "=";
case Token::PLUS: return "+";
case Token::LPAREN: return "(";
case Token::RPAREN: return ")";
default: return "ILLEGAL";
}
}