summaryrefslogtreecommitdiff
path: root/lex.h
blob: 3ce15f4425b9cfe4221b293a13ca24a42ff1c60a (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
#define MAX_IDENT_LENGTH 128

enum TOKEN_TYPE {
	/* Keywords */
	TOK_MODULE,
	TOK_INPUT,
	TOK_EXPR,
	TOK_COLON,
	TOK_EOL,
	TOK_OR,
	TOK_AND,
	TOK_XOR,
	TOK_NOT,

	/* Etc */
	TOK_IDENT
};

struct location {
	size_t line;
	size_t column;
	size_t leading_whitespace_len;
};

struct token {
	enum TOKEN_TYPE type;
	struct location loc;
	char value[MAX_IDENT_LENGTH];
	size_t span;
	struct token *next;
};

struct token* lex_file(FILE*);
const char *get_token_description(enum TOKEN_TYPE);