plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

regcomp.h (1885B)


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