Plan 9 from Bell Labs’s /usr/web/sources/contrib/lucio/sys/include/alef/regexp.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#pragma	src	"/sys/src/alef/lib/libregexp"
#pragma	lib	"/$M/lib/alef/libregexp.a"

/*
 *	Sub expression matches
 */
aggr Resub{
	union
	{
		byte *sp;
		Rune *rsp;
		uint	qsp;	/* for acme */
	};
	union
	{
		byte *ep;
		Rune *rep;
		uint	qep;	/* for acme */
	};
};

/*
 *	character class, each pair of rune's defines a range
 */
aggr Reclass{
	Rune	*end;
	Rune	spans[64];
};

/*
 *	Machine instructions
 */
aggr Reinst{
	int	type;
	union	{
		Reclass	*cp;		/* class pointer */
		Rune	r;		/* character */
		int	subid;		/* sub-expression id for RBRA and LBRA */
		Reinst	*right;		/* right child of OR */
	};
	union {	/* regexp relies on these two being in the same union */
		Reinst *left;		/* left child of OR */
		Reinst *next;		/* next instruction for CAT & LBRA */
	};
};

/*
 *	Reprogram definition
 */
aggr Reprog{
	Reinst	*startinst;	/* start pc */
	Reclass	class[16];	/* .data */
	Reinst	firstinst[5];	/* .text */
};

Reprog	*regcomp(byte*);
Reprog	*regcomplit(byte*);
Reprog	*regcompnl(byte*);
void	regerror(byte*);
int	regexec(Reprog*, byte*, Resub*, int);
void	regsub(byte*, byte*, Resub*, int);
int	rregexec(Reprog*, Rune*, Resub*, int);
void	rregsub(Rune*, Rune*, Resub*, int);

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.