blob: bbb901c531e9937dd62fd22efbfe671751256933 (
plain) (
blame)
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
50
51
52
53
54
|
#ifndef PP_H
#define PP_H
#include "util.h"
#include "syntax.h"
/* TODO */
typedef struct MACRO_STRUC {
char* id;
char* val;
} macro_t;
/*
The preprocessor struct.
TODO: Keep track of macros.
*/
typedef struct PP_STRUC {
/* Original source. */
char* src;
/* Pre-processed source. */
char* psrc;
/* What the preprocessor is looking at right now. */
enum PP_STATE {
PP_STATE_REG, /* Regular. */
PP_STATE_STR, /* String. */
PP_STATE_COM, /* Comment. */
PP_STATE_ESC /* Escaped character in string. */
/* PP_STATE_MCO, */ /* Macro. */
} state;
} pp_t;
/* Creates a new preprocessor from some source code. */
pp_t* pp_init(char*);
/*
Destroys a preprocessor.
- Does not free the pre-processed source.
*/
void pp_destroy(pp_t*);
/* Copy over the current character from src to psrc. */
void pp_cpy_char(pp_t*);
void pp_do_reg(pp_t*);
void pp_do_str(pp_t*);
void pp_do_com(pp_t*);
/* Run the preprocessor. */
void pp_run(pp_t*);
#endif
|