summaryrefslogtreecommitdiff
path: root/igen/preprocessor.h
blob: 7a85e45c7dfac57d5a852fcd0d6a55ae59dc2feb (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
#ifndef PREPROCESSOR_H
#define PREPROCESSOR_H

typedef enum comment_type comment_type;
typedef struct cursor cursor;
typedef struct whitespace whitespace;
typedef struct comment comment;
typedef struct source source;

enum comment_type {
	COMM_NONE,
	COMM_MULTI,
	COMM_SINGLE,
	NUM_COMMS
};

struct cursor {
	int line;
	int column;
};

struct whitespace {
	int spaces;
	int bspaces;
	int tabs;
	int vtabs;
	int lines;
};

struct comment {
	enum comment_type type;
	char *text;
	cursor start_pos;
	cursor end_pos;
	whitespace wsp;
};

struct source {
	source **include_list;
	char *filename;
	char *text;
	int tab_width;
	cursor cur;
};

extern source *preprocess(const char *str, int dbg);
#endif