| 1 |
root |
1.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 |
root |
1.2 |
* this is undefined. |
| 12 |
|
|
*/ |
| 13 |
root |
1.1 |
|
| 14 |
|
|
#define RE_TOKEN_MAX 64 /* Max amount of tokens in a regexp. |
| 15 |
root |
1.2 |
* 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 |
root |
1.1 |
|
| 21 |
|
|
/* D o n o t c h a n g e b e l o w |
| 22 |
|
|
*/ |
| 23 |
|
|
|
| 24 |
|
|
#ifdef uchar |
| 25 |
|
|
# undef uchar |
| 26 |
|
|
#endif |
| 27 |
|
|
#ifdef Boolean |
| 28 |
|
|
# undef Boolean |
| 29 |
|
|
#endif |
| 30 |
|
|
#ifdef True |
| 31 |
|
|
# undef True |
| 32 |
|
|
#endif |
| 33 |
|
|
#ifdef False |
| 34 |
|
|
# undef False |
| 35 |
|
|
#endif |
| 36 |
|
|
|
| 37 |
|
|
#define uchar unsigned char |
| 38 |
|
|
#define Boolean uchar |
| 39 |
|
|
#define True 1 /* Changing this value will break the code */ |
| 40 |
|
|
#define False 0 |
| 41 |
|
|
|
| 42 |
|
|
typedef enum { |
| 43 |
|
|
sel_any, /* corresponds to e.g. . */ |
| 44 |
|
|
sel_end, /* " $ */ |
| 45 |
|
|
sel_single, /* " q */ |
| 46 |
|
|
sel_range, /* " [A-F] */ |
| 47 |
|
|
sel_array, /* " [AF-RqO-T] */ |
| 48 |
|
|
sel_not_single, /* " [^f] */ |
| 49 |
|
|
sel_not_range /* " [^A-F] */ |
| 50 |
|
|
} selection_type; |
| 51 |
|
|
|
| 52 |
|
|
typedef enum { |
| 53 |
|
|
rep_once, /* corresponds to no meta-char */ |
| 54 |
|
|
rep_once_or_more, /* " + */ |
| 55 |
|
|
rep_null_or_once, /* " ? */ |
| 56 |
|
|
rep_null_or_more /* " * */ |
| 57 |
|
|
} repetetion_type; |
| 58 |
|
|
|
| 59 |
|
|
typedef struct { |
| 60 |
|
|
selection_type type; |
| 61 |
|
|
union { |
| 62 |
root |
1.2 |
uchar single; |
| 63 |
|
|
struct { |
| 64 |
|
|
uchar low, high; |
| 65 |
|
|
} range; |
| 66 |
|
|
Boolean array[UCHAR_MAX]; |
| 67 |
root |
1.1 |
} u; |
| 68 |
|
|
repetetion_type repeat; |
| 69 |
|
|
} selection; |