Blob


1 #ifndef _REGEXP9H_
3 #define _REGEXP9H_ 1
4 #include <utf.h>
6 typedef struct Resub Resub;
7 typedef struct Reclass Reclass;
8 typedef struct Reinst Reinst;
9 typedef struct Reprog Reprog;
11 /*
12 * Sub expression matches
13 */
14 struct Resub{
15 union
16 {
17 char *sp;
18 Rune *rsp;
19 }s;
20 union
21 {
22 char *ep;
23 Rune *rep;
24 }e;
25 };
27 /*
28 * character class, each pair of rune's defines a range
29 */
30 struct Reclass{
31 Rune *end;
32 Rune spans[64];
33 };
35 /*
36 * Machine instructions
37 */
38 struct Reinst{
39 int type;
40 union {
41 Reclass *cp; /* class pointer */
42 Rune r; /* character */
43 int subid; /* sub-expression id for RBRA and LBRA */
44 Reinst *right; /* right child of OR */
45 }u1;
46 union { /* regexp relies on these two being in the same union */
47 Reinst *left; /* left child of OR */
48 Reinst *next; /* next instruction for CAT & LBRA */
49 }u2;
50 };
52 /*
53 * Reprogram definition
54 */
55 struct Reprog{
56 Reinst *startinst; /* start pc */
57 Reclass class[16]; /* .data */
58 Reinst firstinst[5]; /* .text */
59 };
61 extern Reprog *regcomp(char*);
62 extern Reprog *regcomplit(char*);
63 extern Reprog *regcompnl(char*);
64 extern void regerror(char*);
65 extern int regexec(Reprog*, char*, Resub*, int);
66 extern void regsub(char*, char*, int, Resub*, int);
68 extern int rregexec(Reprog*, Rune*, Resub*, int);
69 extern void rregsub(Rune*, Rune*, Resub*, int);
71 #endif