2 |
- |
1 |
/*
|
|
|
2 |
* substitution list
|
|
|
3 |
*/
|
|
|
4 |
#define NSUBEXP 32
|
|
|
5 |
typedef struct Resublist Resublist;
|
|
|
6 |
struct Resublist
|
|
|
7 |
{
|
|
|
8 |
Resub m[NSUBEXP];
|
|
|
9 |
};
|
|
|
10 |
|
|
|
11 |
/*
|
|
|
12 |
* Actions and Tokens (Reinst types)
|
|
|
13 |
*
|
|
|
14 |
* 02xx are operators, value == precedence
|
|
|
15 |
* 03xx are tokens, i.e. operands for operators
|
|
|
16 |
*/
|
|
|
17 |
#define RUNE 0177
|
|
|
18 |
#define OPERATOR 0200 /* Bitmask of all operators */
|
|
|
19 |
#define START 0200 /* Start, used for marker on stack */
|
|
|
20 |
#define RBRA 0201 /* Right bracket, ) */
|
|
|
21 |
#define LBRA 0202 /* Left bracket, ( */
|
|
|
22 |
#define OR 0203 /* Alternation, | */
|
|
|
23 |
#define CAT 0204 /* Concatentation, implicit operator */
|
|
|
24 |
#define STAR 0205 /* Closure, * */
|
|
|
25 |
#define PLUS 0206 /* a+ == aa* */
|
|
|
26 |
#define QUEST 0207 /* a? == a|nothing, i.e. 0 or 1 a's */
|
|
|
27 |
#define ANY 0300 /* Any character except newline, . */
|
|
|
28 |
#define ANYNL 0301 /* Any character including newline, . */
|
|
|
29 |
#define NOP 0302 /* No operation, internal use only */
|
|
|
30 |
#define BOL 0303 /* Beginning of line, ^ */
|
|
|
31 |
#define EOL 0304 /* End of line, $ */
|
|
|
32 |
#define CCLASS 0305 /* Character class, [] */
|
|
|
33 |
#define NCCLASS 0306 /* Negated character class, [] */
|
|
|
34 |
#define END 0377 /* Terminate: match found */
|
|
|
35 |
|
|
|
36 |
/*
|
|
|
37 |
* regexec execution lists
|
|
|
38 |
*/
|
|
|
39 |
#define LISTSIZE 10
|
|
|
40 |
#define BIGLISTSIZE (25*LISTSIZE)
|
|
|
41 |
typedef struct Relist Relist;
|
|
|
42 |
struct Relist
|
|
|
43 |
{
|
|
|
44 |
Reinst* inst; /* Reinstruction of the thread */
|
|
|
45 |
Resublist se; /* matched subexpressions in this thread */
|
|
|
46 |
};
|
|
|
47 |
typedef struct Reljunk Reljunk;
|
|
|
48 |
struct Reljunk
|
|
|
49 |
{
|
|
|
50 |
Relist* relist[2];
|
|
|
51 |
Relist* reliste[2];
|
|
|
52 |
int starttype;
|
|
|
53 |
Rune startchar;
|
|
|
54 |
char* starts;
|
|
|
55 |
char* eol;
|
|
|
56 |
Rune* rstarts;
|
|
|
57 |
Rune* reol;
|
|
|
58 |
};
|
|
|
59 |
|
|
|
60 |
extern Relist* _renewthread(Relist*, Reinst*, int, Resublist*);
|
|
|
61 |
extern void _renewmatch(Resub*, int, Resublist*);
|
|
|
62 |
extern Relist* _renewemptythread(Relist*, Reinst*, int, char*);
|
|
|
63 |
extern Relist* _rrenewemptythread(Relist*, Reinst*, int, Rune*);
|