summaryrefslogtreecommitdiff
path: root/src/lexer.h
blob: 52d00faaa98209ce7cd0dbf5aba6ad2ba3aff0d6 (plain)
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
#ifndef LEXER
#define LEXER
typedef enum TokenType {
	ERR,
	EOL,
	NAME,
	KEYWORD,
	STRING_LIT,
	INT_LIT,
	SEMICOLON,
	OPEN_PAREN,
	CLOSE_PAREN,
	OPEN_BRACE,
	CLOSE_BRACE,
	OPEN_BRACKET,
	CLOSE_BRACKET,
	START_COMMENT,
	EQUALS,
	DOUBLE_EQUALS,
	NEGATION,
	ASTERISK,
	PLUS_SIGN,
	FUNCTION
} tokenType_t;
typedef enum Keyword {
	K_NONE,
	K_VOID,
	K_INT,
	K_FLOAT,
	K_STRING
} keyword_t;
typedef struct Token {
	tokenType_t type;
	void* value;
} token_t;
token_t init_token(tokenType_t type, void* value);
typedef struct TokenSet {
	token_t* tokens;
	int count;
} tokenSet_t;
tokenSet_t init_tokenset(token_t* tokens, int count);
char* tttos(tokenType_t tokenType);
int advance_whitespace(char** linePointer);
keyword_t try_get_keyword(char* name);
char keyword_is_type(keyword_t keyword);
token_t lex_first_token(char** content);
token_t lex_first_string(char** content);
token_t lex_first_int(char** content);
#endif