summaryrefslogtreecommitdiff
path: root/token.h
blob: 453b5542a2ff64a5b6a661a2a6a011accf61d5d4 (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
#ifndef HENCE_TOKEN_H
#define HENCE_TOKEN_H

#define MAX_IDENT_LENGTH 128

enum TOKEN_TYPE {
	/* Nop token to indicate lexer success */
	TOK_BEGIN,

	/* Keywords */
	TOK_MODULE,
	TOK_INPUT,
	TOK_EXPR,
	TOK_COLON,
	TOK_EOL,
	TOK_OR,
	TOK_AND,
	TOK_XOR,
	TOK_NOT,
	TOK_NAND,
	TOK_NOR,

	/* 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;
};

#endif