Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

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