1 |
/* re-cmp.h |
2 |
* Datastructures for representing a subset of regular expressions. |
3 |
* |
4 |
* Author: Kjetil T. Homme <kjetilho@ifi.uio.no> May 1993 |
5 |
*/ |
6 |
|
7 |
/* C o n f i g u r a t i o n |
8 |
*/ |
9 |
|
10 |
#define SAFE_CHECKS /* Regexp's with syntax errors will core dump if |
11 |
* this is undefined. |
12 |
*/ |
13 |
|
14 |
#define RE_TOKEN_MAX 64 /* Max amount of tokens in a regexp. |
15 |
* Each token uses ~264 bytes. They are allocated |
16 |
* as needed, but never de-allocated. |
17 |
* E.g. [A-Za-z0-9_] counts as one token, so 64 |
18 |
* should be plenty for most purposes. |
19 |
*/ |
20 |
|
21 |
/* D o n o t c h a n g e b e l o w |
22 |
*/ |
23 |
|
24 |
typedef enum { |
25 |
sel_any, /* corresponds to e.g. . */ |
26 |
sel_end, /* " $ */ |
27 |
sel_single, /* " q */ |
28 |
sel_range, /* " [A-F] */ |
29 |
sel_array, /* " [AF-RqO-T] */ |
30 |
sel_not_single, /* " [^f] */ |
31 |
sel_not_range /* " [^A-F] */ |
32 |
} selection_type; |
33 |
|
34 |
typedef enum { |
35 |
rep_once, /* corresponds to no meta-char */ |
36 |
rep_once_or_more, /* " + */ |
37 |
rep_null_or_once, /* " ? */ |
38 |
rep_null_or_more /* " * */ |
39 |
} repetetion_type; |
40 |
|
41 |
typedef struct { |
42 |
selection_type type; |
43 |
union { |
44 |
unsigned char single; |
45 |
struct { |
46 |
unsigned char low, high; |
47 |
} range; |
48 |
bool array[UCHAR_MAX]; |
49 |
} u; |
50 |
repetetion_type repeat; |
51 |
} selection; |