File: re-cmp.h

package info (click to toggle)
crossfire 1.75.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,168 kB
  • sloc: ansic: 83,169; sh: 4,659; perl: 1,736; lex: 1,443; makefile: 1,199; python: 43
file content (76 lines) | stat: -rw-r--r-- 1,993 bytes parent folder | download | duplicates (8)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
 * @file
 * Datastructures for representing a subset of regular expressions.
 *
 * @author
 * Kjetil T. Homme \<kjetilho@ifi.uio.no\> May 1993
 */

#ifndef RE_CMP_H
#define RE_CMP_H

/*   C o n f i g u r a t i o n
 */

#define SAFE_CHECKS     /**< Regexp's with syntax errors will core dump if
                         * this is undefined.
                         */

#define RE_TOKEN_MAX 64 /**< Max amount of tokens in a regexp.
                         * Each token uses ~264 bytes. They are allocated
                         * as needed, but never de-allocated.
                         * E.g. [A-Za-z0-9_] counts as one token, so 64
                         * should be plenty for most purposes.
                         */

/*   D o   n o t   c h a n g e    b e l o w
 */

#ifdef uchar
#    undef uchar
#endif
#ifdef Boolean
#    undef Boolean
#endif
#ifdef True
#    undef True
#endif
#ifdef False
#    undef False
#endif

#define uchar   unsigned char
#define Boolean uchar
#define True    1       /**< Changing this value will break the code */
#define False   0

typedef enum {
    sel_any,            /**< corresponds to eg . */
    sel_end,            /**< corresponds to eg \$ */
    sel_single,         /**< corresponds to eg q */
    sel_range,          /**< corresponds to eg [A-F] */
    sel_array,          /**< corresponds to eg [AF-RqO-T] */
    sel_not_single,     /**< corresponds to eg [^f] */
    sel_not_range       /**< corresponds to eg [^A-F] */
} selection_type;

typedef enum {
    rep_once,           /**< corresponds to no meta-char */
    rep_once_or_more,   /**< corresponds to + */
    rep_null_or_once,   /**< corresponds to eg ? */
    rep_null_or_more    /**< corresponds to eg * */
} repetetion_type;

typedef struct {
    selection_type type;
    union {
        uchar single;
        struct {
            uchar low, high;
        } range;
        Boolean array[UCHAR_MAX];
    } u;
    repetetion_type repeat;
} selection;

#endif /* RE_CMP_H */