-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token.h
47 lines (38 loc) · 983 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
#ifndef ELC_TOKEN_H_
#define ELC_TOKEN_H_
#include <stdlib.h>
typedef enum {
TOKEN_TYPE_IDENTIFIER = 0,
TOKEN_TYPE_NIL,
TOKEN_TYPE_NILLABLE,
TOKEN_TYPE_TYPE,
TOKEN_TYPE_ASSIGN,
TOKEN_TYPE_PLUS, // Unused
TOKEN_TYPE_MINUS, // Unused
TOKEN_TYPE_MULT, // Unused
TOKEN_TYPE_DIV, // Unused
TOKEN_TYPE_INT,
TOKEN_TYPE_FLOAT,
TOKEN_TYPE_STRING,
TOKEN_TYPE_CHAR,
TOKEN_TYPE_BOOL // TODO: Not implemented
} TokenType;
const char* TokenType_toString(TokenType type);
#define TYPES_COUNT 5
extern const char* types[TYPES_COUNT];
typedef struct {
TokenType type;
char* text;
unsigned int line;
unsigned int col;
} Token;
typedef struct {
Token* tokens;
size_t size;
size_t capacity;
} TokenVector;
void TokenVector_init(TokenVector* vec);
void TokenVector_push(TokenVector* vec, Token* token);
void TokenVector_display(TokenVector* vec);
void TokenVector_free(TokenVector* vec);
#endif // ELC_TOKEN_H_