-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtoken.h
51 lines (48 loc) · 873 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
#ifndef TOKEN_H
#define TOKEN_H
typedef enum {
// Keywords
TOKEN_INT,
TOKEN_FLOAT,
TOKEN_IF,
TOKEN_ELSE,
TOKEN_WHILE,
TOKEN_RETURN,
// Identifiers and literals
TOKEN_IDENTIFIER,
TOKEN_INTEGER_LITERAL,
TOKEN_FLOAT_LITERAL,
// Operators
TOKEN_PLUS,
TOKEN_MINUS,
TOKEN_ASTERISK,
TOKEN_SLASH,
TOKEN_ASSIGN,
TOKEN_EQUAL_EQUAL,
TOKEN_BANG,
TOKEN_BANG_EQUAL,
TOKEN_LESS,
TOKEN_LESS_EQUAL,
TOKEN_GREATER,
TOKEN_GREATER_EQUAL,
// Logical operators
TOKEN_AND,
TOKEN_OR,
// Punctuation
TOKEN_SEMICOLON,
TOKEN_COMMA,
TOKEN_LPAREN,
TOKEN_RPAREN,
TOKEN_LBRACE,
TOKEN_RBRACE,
// Special tokens
TOKEN_EOF,
TOKEN_ERROR
} TokenType;
typedef struct {
TokenType type;
const char *lexeme;
int line;
int column;
} Token;
#endif