-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token.h
76 lines (67 loc) · 875 Bytes
/
Token.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef _TOKEN_H_
#define _TOKEN_H_
#include <string>
// Keep track of the location
struct Location {
std::string file;
int line;
int col;
};
enum TOK {
// Symbol token
__SYM_START,
L_BRACKET,
R_BRACKET,
L_PAREN,
R_PAREN,
S_COLON,
L_SBRACKET,
R_SBRACKET,
DOT,
COMMA,
QUOTE,
__SYM_END,
// Operations
__OP_START,
ASSIGN,
LTHAN,
TIMES,
PLUS,
MINUS,
NOT,
AND,
__OP_END,
// Key words
__KEYWORD_START,
CLASS,
PUBLIC,
STATIC,
VOID,
STRING,
MAIN,
EXTENDS,
RETURN,
BOOL,
INT,
IF,
ELSE,
WHILE,
PRINT,
LENGTH,
TRUE,
FALSE,
THIS,
NEW,
__KEYWORD_END,
// Others
TOK_EOF,
INTEGER_LITERAL,
ID,
};
extern bool isKeyWord(TOK tk);
extern bool isIntLiteral(TOK tk);
extern bool isId(TOK tk);
extern bool isSymbol(TOK tk);
extern bool isOp(TOK tk);
extern bool isEOF(TOK tk);
#endif