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