-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.h
More file actions
42 lines (30 loc) · 675 Bytes
/
Copy pathtoken.h
File metadata and controls
42 lines (30 loc) · 675 Bytes
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
34
35
36
37
38
39
40
41
42
#ifndef TOKEN_H
#define TOKEN_H
#include <string>
enum class TokenType {
// keywords
KW_INT, KW_FLOAT, KW_BOOL, KW_STRING, KW_CHAR,
KW_FUN, KW_DONE, KW_RETURN,
KW_PRINT,
KW_TRUE, KW_FALSE,
// NEW:
KW_WHILE, KW_FOR,
// Else/if
KW_IF, KW_ELSE, KW_DO,
// identifiers & literals
IDENT, NUMBER, STRING_LIT, CHAR_LIT,
// operators
ASSIGN, PLUS, MINUS, MUL, DIV, MOD,
EQ, NEQ, LT, GT, LE, GE,
AND, OR, NOT,
// punctuation
LPAREN, RPAREN, COLON, SEMI, COMMA,
END, INVALID
};
struct Token {
TokenType type;
std::string lexeme;
int line;
};
std::string tokenTypeName(TokenType t);
#endif