blob: 4c6662bfec6368ae622c82752260af7f5d41f136 (
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
|
#ifndef HENCE_LEX_H
#define HENCE_LEX_H
#include <stdio.h>
#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,
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;
};
struct token* lex_file(FILE*);
const char *get_token_description(enum TOKEN_TYPE);
#endif
|