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