Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/srch/xid.c

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


typedef unsigned char Uchar;
# include <u.h>
# include <libc.h>
# include <stdio.h>
# define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
# define YYLMAX 200
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
# define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
int yyleng; extern char yytext[];
int yymorfg;
extern Uchar *yysptr, yysbuf[];
int yytchar;
FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf { 
	struct yywork *yystoff;
	struct yysvf *yyother;
	int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
int yylook(void), yywrap(void), yyback(int *, int);
int infd, outfd;

void
output(char c)
{
	int rv;
	if ((rv = write(outfd, &c, 1)) < 0)
		sysfatal("output: %r");
	if (rv == 0)
		sysfatal("output: EOF?");
}

int
input(void)
{
	if(yysptr > yysbuf)
		yytchar = U(*--yysptr);
	else {
		int rv;
		if ((rv = read(infd, &yytchar, 1)) < 0)
			sysfatal("input: %r");
		if (rv == 0)
			return 0;
	}
	if (yytchar == '\n')
		yylineno++;
	return yytchar;
}
/* xid.l - extract identifiers from c source		Steve Simon		2005 */
#include <bio.h>

#undef YYLMAX
#define YYLMAX	(1024 * 16)

#define FUNC_CALL	1
#define FUNC_DEF	2

struct {			/* last function name found */
	int line;
	int fnum;
	int brace;
	char *name;
} func;

int	nolvars = 0;		/* don't extract info from variables */
int	nocomments = 0;		/* don't extract info from comments */

Biobuf	*symb;			/* symbols index */
Biobuf	*file;			/* filenames index */
int	fnum = 0;		/* file "number" */
int	incomment = 0;		/* inside a comment */
int	line = 0;		/* current line number */
int	brace = 0;		/* nesting level of braces */
int	gotid = 0;		/* have a buffered identifier */
char	*infile = "stdin";	/* current file name */
char	*prefix = NULL;		/* prefix to remove from filenames */

int yywrap(void);
void vardef(void);
void varuse(void);
void charconst(void);
void keepfun(void);
void outfun(int);
void outdef(void);
void getstring(void);
void getcomment(void);
void xid(Biobuf *);

#define YYNEWLINE 10
yylex(void){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
	case 2:
case 3:
	case 4:
	case 5:
	case 6:
	case 7:
	case 8:
	case 9:
	case 10:
	case 11:
	case 12:
case 13:
	case 14:
	case 15:
case 16:
	case 17:
	case 18:
	case 19:
case 20:
	case 21:
	case 22:
case 23:
	case 24:
      	case 25:
case 26:
	case 27:
case 28:
	case 29:
case 30:
case 31:
	case 32:
	case 33:
	case 34:
	case 35:
	case 36:
	case 37:
	case 38:
	case 39:
	case 40:
case 41:
	{ ; }
break;
case 42:
{ getstring(); }
break;
case 43:
{ line++; }
break;
case 44:
{ keepfun(); }
break;
case 45:
{ outfun(';'); }
break;
case 46:
{ outfun('{'); brace++; }
break;
case 47:
{ brace--; }
break;
case 48:
{ getcomment(); }
break;
case 49:
;
break;
case 50:
;
break;
case 51:
{ outdef(); }
break;
case 52:
{ vardef(); }
break;
case 53:
{ varuse(); }
break;
case 54:
        case 55:
case 56:
{ charconst(); }
break;
case 57:
;
break;
case -1:
break;
default:
fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */

int
yywrap(void)
{
	return(1);
}


void
vardef(void)	/* variable definition */
{
	if (brace == 0)
		Bprint(symb, "g %d %d %s\n", fnum, line, yytext);
	else
		Bprint(symb, "l %d %d %s\n", fnum, line, yytext);
}


void
varuse(void)	/* variable use */
{
	if (!nolvars)
		Bprint(symb, "v %d %d %s\n", fnum, line, yytext);
}


void
charconst(void)	/* character constant */
{
	Bprint(symb, "c %d %d %s\n", fnum, line, yytext);
}


void
keepfun(void)	/* rembember function, definition or call */
{
	int i;

	if ((i = strlen(yytext)) > 1)		/* trim bracket */
		yytext[i -1] = 0;
	func.fnum = fnum;
	func.line = line;
	func.brace = brace;
	if (func.name)
		free(func.name);
	func.name = strdup(yytext);
	if (func.name == nil)
		sysfatal("no memory\n");

}


void
outfun(int c) /* function call definition, or prototype */
{
	if (func.line == 0)
		return;

	if (brace)
		Bprint(symb, "f %d %d %s\n", func.fnum, func.line, func.name);
	else
	if (c == '{')
		Bprint(symb, "F %d %d %s\n", func.fnum, func.line, func.name);
	else
		Bprint(symb, "P %d %d %s\n", func.fnum, func.line, func.name);

	func.line = 0;
}


void
outdef(void) /* #define */
{
	int i;
	char *p;

	/* trim op to last first whitespace */
	if ((i = strlen(yytext)) > 1) {
		for (p = &yytext[i -1]; *p != ' ' && *p != '\t' && *p; p--)
			continue;
		p++;
		Bprint(symb, "d %d %d %s\n", fnum, line, p);
	}
}


void
getstring(void)
{
	char c;
	int p = 0;

	Bprint(symb, "s %d %d ", fnum, line);
	while (1) {
		switch (c = input()) {
		case '\n':
			line++;
		case '\r':
		case '\b':
		case '\f':
		case '\t':
		case ' ' :
			if (p == 0)
				continue;
			c = ' ';
			break;
		case 0:
			fprint(2, "%s:%d EOF in string\n", infile, line);
			goto fini;
		case '"':
			if (p != '\\')
				goto fini;
			break;
		default:
			break;
		}
		if (p != ' ' || c != ' ')
			Bputc(symb, c);

		if (p == '\\' && c == '\\')	/* kludge around the string \\" */
			p = '#';
		else
			p = c;
	}

fini:
	Bputc(symb, '\n');
}


void
getcomment(void)
{
	char c, p = 0;

	Bprint(symb, "x %d %d ", fnum, line);
	while (1) {
		switch (c = input()) {
		case '\n':
			line++;
		case '\r':
		case '\b':
		case '\f':
		case '\t':
		case ' ' :
			if (p == 0)
				continue;
			c = ' ';
			break;
		case 0:
			fprint(2, "%s:%d EOF in comment\n", infile, line);
			goto fini;
		case '*':
			p = c;
			continue;
		case '/':
			if (p == '*')
				goto fini;
			break;
		default:
			break;
		}
		if (p == '*')			/* catchup delayed '*' */
			Bputc(symb, p);
		if (!(p == ' ' && c == ' '))	/* colapse multiple spaces into one */
			Bputc(symb, c);
		p = c;
	}

fini:
	Bputc(symb, '\n');
}



void
xid(Biobuf *bi)
{
	int l;
	char *p, *buf;

	l = (prefix)? strlen(prefix): 0;

	while ((buf = Brdline(bi, '\n')) != NULL) {
		buf[Blinelen(bi)-1] = 0;
		if ((p = strchr(buf, '\n')) != NULL)
			*p = 0;
		if ((infd = open(buf, OREAD)) == -1) {
			fprint(2, "%s can't open\n", buf);
			continue;
		}
		if (prefix && strncmp(buf, prefix, l) == 0)
			Bprint(file, "%d %s\n", ++fnum, buf+l);
		else
			Bprint(file, "%d %s\n", ++fnum, buf);
		infile = buf;
		line = 1;
		incomment = 0;
		brace = 0;

		yylex();
		close(infd);
	}

}


void
usage(void)
{
	fprint(2, "usage: %s [-vc] [-p path] [index-base]\n", argv0);
	exits("usage");
}


void
main(int argc, char *argv[])
{
	Biobuf bin;
	char *fi, *sy;

	ARGBEGIN {
	case 'c':
		nocomments = 1;
		break;
	case 'v':
		nolvars = 1;
		break;
	case 'p':
		prefix = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND;

	if (argc > 1)
		usage();

	if (argc == 0) {
		fi = "files.idx";
		sy = "symbs.idx";
	} else {
		fi = smprint("%s/files.idx", argv[0]);
		sy = smprint("%s/symbs.idx", argv[0]);
	}
	if (fi == nil || sy == nil)
		sysfatal("no memory");

	if ((file = Bopen(fi, OWRITE)) == NULL)
		sysfatal("%s can't open for writing", fi);
	if ((symb = Bopen(sy, OWRITE)) == NULL)
		sysfatal("%s can't open for writing", sy);

	Binit(&bin, 0, OREAD);
	xid(&bin);
	Bterm(symb);
	Bterm(file);
	exits(0);
}


int yyvstop[] = {
0,

57,
0,

43,
0,

42,
57,
0,

57,
0,

57,
0,

45,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

53,
57,
0,

46,
57,
0,

47,
57,
0,

57,
0,

48,
0,

44,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

28,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

54,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

25,
44,
0,

53,
0,

53,
0,

53,
0,

4,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

56,
0,

55,
0,

52,
0,

13,
53,
0,

53,
0,

31,
53,
0,

5,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

26,
53,
0,

53,
0,

53,
0,

34,
53,
0,

53,
0,

53,
0,

27,
44,
0,

18,
53,
0,

53,
0,

53,
0,

53,
0,

10,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

3,
53,
0,

53,
0,

53,
0,

23,
53,
0,

1,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

41,
53,
0,

33,
53,
0,

53,
0,

6,
53,
0,

37,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

11,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

36,
53,
0,

9,
53,
0,

53,
0,

53,
0,

53,
0,

-49,
0,

53,
0,

53,
0,

35,
53,
0,

7,
53,
0,

14,
53,
0,

38,
53,
0,

53,
0,

53,
0,

20,
53,
0,

21,
53,
0,

17,
53,
0,

8,
53,
0,

53,
0,

53,
0,

53,
0,

53,
0,

29,
44,
0,

49,
0,

55,
0,

53,
0,

32,
53,
0,

53,
0,

39,
53,
0,

53,
0,

19,
44,
0,

22,
44,
0,

30,
44,
0,

16,
53,
0,

53,
0,

53,
0,

24,
53,
0,

40,
44,
0,

15,
53,
0,

12,
53,
0,

2,
53,
0,

-50,
0,

51,
0,

50,
0,

55,
0,
0};
# define YYTYPE Uchar
struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0,	0,0,	1,3,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	1,3,	1,4,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	1,5,	
0,0,	0,0,	0,0,	0,0,	
1,6,	28,63,	64,106,	7,30,	
65,107,	1,3,	0,0,	80,125,	
1,7,	1,3,	82,82,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
1,8,	0,0,	0,0,	0,0,	
0,0,	2,27,	1,9,	0,0,	
0,0,	27,59,	80,125,	0,0,	
0,0,	82,82,	0,0,	0,0,	
0,0,	2,7,	80,126,	0,0,	
0,0,	82,83,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	2,8,	0,0,	0,0,	
27,59,	1,3,	0,0,	0,0,	
0,0,	0,0,	1,10,	1,11,	
1,12,	1,13,	1,14,	1,15,	
1,16,	19,50,	1,17,	24,58,	
35,68,	1,18,	15,44,	1,9,	
22,56,	15,45,	16,46,	1,19,	
1,20,	1,21,	1,22,	1,23,	
1,24,	10,34,	2,3,	11,35,	
1,25,	18,49,	1,26,	2,10,	
6,28,	2,12,	2,13,	2,14,	
2,15,	2,16,	17,47,	2,17,	
6,28,	6,28,	2,18,	21,55,	
2,9,	13,39,	17,48,	12,36,	
2,19,	2,20,	2,21,	2,22,	
2,23,	2,24,	12,37,	13,40,	
14,41,	2,25,	14,42,	2,26,	
23,57,	12,38,	34,67,	36,69,	
27,60,	6,28,	20,51,	20,52,	
14,43,	27,61,	6,0,	37,70,	
27,62,	38,71,	9,31,	6,28,	
39,72,	40,73,	20,53,	6,28,	
41,74,	20,54,	42,75,	43,78,	
44,79,	45,80,	46,81,	48,86,	
49,88,	50,89,	51,91,	52,92,	
53,93,	54,95,	55,96,	56,97,	
6,28,	9,31,	42,76,	42,77,	
56,98,	58,102,	50,90,	57,100,	
48,87,	9,32,	57,101,	60,103,	
61,104,	53,94,	56,99,	62,105,	
67,110,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	6,29,	
68,111,	69,112,	70,113,	71,114,	
71,115,	6,28,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
73,118,	74,119,	75,120,	76,121,	
9,33,	77,122,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
9,33,	9,33,	9,33,	9,33,	
29,64,	72,116,	78,123,	79,124,	
81,127,	29,64,	84,128,	85,129,	
86,130,	72,117,	88,131,	89,132,	
90,133,	91,134,	29,65,	29,65,	
29,65,	29,65,	29,65,	29,65,	
29,65,	29,65,	29,65,	29,65,	
92,135,	93,136,	94,137,	95,138,	
31,31,	96,139,	97,140,	98,141,	
99,142,	100,143,	101,144,	102,145,	
103,146,	104,147,	105,148,	107,149,	
111,150,	114,151,	115,152,	116,153,	
117,154,	118,155,	120,156,	121,157,	
123,158,	124,159,	125,125,	31,31,	
47,82,	128,160,	129,161,	130,162,	
132,163,	133,164,	29,64,	31,32,	
134,165,	135,166,	136,167,	137,168,	
29,64,	138,169,	139,170,	140,171,	
29,64,	141,172,	142,173,	144,174,	
145,175,	125,125,	29,64,	47,82,	
29,64,	146,176,	147,177,	148,178,	
29,64,	125,126,	29,64,	47,83,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	152,180,	153,181,	
154,182,	155,183,	31,66,	158,184,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	31,66,	31,66,	
31,66,	31,66,	66,108,	47,84,	
108,108,	161,185,	162,186,	163,187,	
164,188,	166,189,	167,190,	168,191,	
169,192,	47,85,	149,179,	149,179,	
149,179,	149,179,	149,179,	149,179,	
149,179,	149,179,	149,179,	149,179,	
170,193,	66,108,	173,194,	108,108,	
174,195,	176,198,	177,199,	179,201,	
180,202,	181,203,	182,204,	186,205,	
187,206,	66,109,	193,213,	108,109,	
194,214,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	195,215,	
66,109,	198,216,	108,109,	199,217,	
201,218,	202,219,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
206,222,	214,223,	215,224,	217,226,	
66,66,	227,230,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
66,66,	66,66,	66,66,	66,66,	
175,196,	178,178,	188,207,	216,225,	
189,209,	192,211,	196,196,	204,220,	
0,0,	178,178,	178,200,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	207,207,	209,209,	
211,211,	0,0,	0,0,	175,196,	
0,0,	188,207,	216,225,	189,209,	
192,211,	196,196,	204,220,	175,197,	
0,0,	188,208,	178,178,	189,210,	
192,212,	196,197,	204,221,	178,178,	
220,220,	207,207,	209,209,	211,211,	
178,178,	225,225,	0,0,	0,0,	
178,178,	207,208,	209,210,	211,212,	
218,227,	218,227,	218,227,	218,227,	
218,227,	218,227,	218,227,	218,227,	
218,227,	218,227,	0,0,	220,220,	
0,0,	178,178,	0,0,	0,0,	
225,225,	0,0,	0,0,	220,221,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	178,178,	0,0,	
0,0,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	0,0,	
0,0,	0,0,	0,0,	225,228,	
0,0,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	225,228,	
225,228,	225,228,	225,228,	226,226,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	226,226,	
226,229,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
226,226,	0,0,	0,0,	0,0,	
0,0,	226,226,	0,0,	0,0,	
0,0,	0,0,	226,226,	0,0,	
0,0,	0,0,	226,226,	0,0,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	0,0,	0,0,	
0,0,	0,0,	0,0,	226,226,	
0,0,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	0,0,	
0,0,	0,0,	0,0,	228,228,	
226,226,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	228,228,	
228,228,	228,228,	228,228,	0,0,	
0,0};
struct yysvf yysvec[] = {
0,	0,	0,
yycrank+-1,	0,		0,	
yycrank+-30,	yysvec+1,	0,	
yycrank+0,	0,		yyvstop+1,
yycrank+0,	0,		yyvstop+3,
yycrank+0,	0,		yyvstop+5,
yycrank+-127,	0,		yyvstop+8,
yycrank+1,	0,		yyvstop+10,
yycrank+0,	0,		yyvstop+12,
yycrank+161,	0,		yyvstop+15,
yycrank+4,	yysvec+9,	yyvstop+18,
yycrank+9,	yysvec+9,	yyvstop+21,
yycrank+46,	yysvec+9,	yyvstop+24,
yycrank+40,	yysvec+9,	yyvstop+27,
yycrank+44,	yysvec+9,	yyvstop+30,
yycrank+2,	yysvec+9,	yyvstop+33,
yycrank+3,	yysvec+9,	yyvstop+36,
yycrank+32,	yysvec+9,	yyvstop+39,
yycrank+14,	yysvec+9,	yyvstop+42,
yycrank+4,	yysvec+9,	yyvstop+45,
yycrank+58,	yysvec+9,	yyvstop+48,
yycrank+18,	yysvec+9,	yyvstop+51,
yycrank+2,	yysvec+9,	yyvstop+54,
yycrank+45,	yysvec+9,	yyvstop+57,
yycrank+3,	yysvec+9,	yyvstop+60,
yycrank+0,	0,		yyvstop+63,
yycrank+0,	0,		yyvstop+66,
yycrank+60,	0,		yyvstop+69,
yycrank+2,	0,		0,	
yycrank+250,	0,		0,	
yycrank+0,	0,		yyvstop+71,
yycrank+303,	0,		0,	
yycrank+0,	0,		yyvstop+73,
yycrank+0,	yysvec+9,	yyvstop+75,
yycrank+42,	yysvec+9,	yyvstop+77,
yycrank+7,	yysvec+9,	yyvstop+79,
yycrank+44,	yysvec+9,	yyvstop+81,
yycrank+70,	yysvec+9,	yyvstop+83,
yycrank+59,	yysvec+9,	yyvstop+85,
yycrank+70,	yysvec+9,	yyvstop+87,
yycrank+56,	yysvec+9,	yyvstop+89,
yycrank+61,	yysvec+9,	yyvstop+92,
yycrank+78,	yysvec+9,	yyvstop+94,
yycrank+63,	yysvec+9,	yyvstop+96,
yycrank+69,	yysvec+9,	yyvstop+98,
yycrank+67,	yysvec+9,	yyvstop+100,
yycrank+66,	yysvec+9,	yyvstop+102,
yycrank+327,	yysvec+9,	yyvstop+104,
yycrank+84,	yysvec+9,	yyvstop+106,
yycrank+74,	yysvec+9,	yyvstop+108,
yycrank+82,	yysvec+9,	yyvstop+110,
yycrank+75,	yysvec+9,	yyvstop+112,
yycrank+65,	yysvec+9,	yyvstop+114,
yycrank+91,	yysvec+9,	yyvstop+116,
yycrank+84,	yysvec+9,	yyvstop+118,
yycrank+78,	yysvec+9,	yyvstop+120,
yycrank+91,	yysvec+9,	yyvstop+122,
yycrank+94,	yysvec+9,	yyvstop+124,
yycrank+92,	yysvec+9,	yyvstop+126,
yycrank+0,	yysvec+27,	0,	
yycrank+102,	0,		0,	
yycrank+94,	0,		0,	
yycrank+102,	0,		0,	
yycrank+0,	0,		yyvstop+128,
yycrank+3,	0,		0,	
yycrank+5,	0,		0,	
yycrank+417,	0,		0,	
yycrank+97,	yysvec+9,	yyvstop+130,
yycrank+123,	yysvec+9,	yyvstop+132,
yycrank+120,	yysvec+9,	yyvstop+134,
yycrank+108,	yysvec+9,	yyvstop+136,
yycrank+108,	yysvec+9,	yyvstop+138,
yycrank+188,	yysvec+9,	yyvstop+140,
yycrank+154,	yysvec+9,	yyvstop+142,
yycrank+152,	yysvec+9,	yyvstop+144,
yycrank+149,	yysvec+9,	yyvstop+146,
yycrank+141,	yysvec+9,	yyvstop+148,
yycrank+148,	yysvec+9,	yyvstop+150,
yycrank+185,	yysvec+9,	yyvstop+152,
yycrank+190,	yysvec+9,	yyvstop+154,
yycrank+38,	yysvec+9,	yyvstop+156,
yycrank+177,	yysvec+9,	yyvstop+158,
yycrank+41,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+160,
yycrank+189,	yysvec+9,	yyvstop+163,
yycrank+191,	yysvec+9,	yyvstop+165,
yycrank+184,	yysvec+9,	yyvstop+167,
yycrank+0,	yysvec+9,	yyvstop+169,
yycrank+191,	yysvec+9,	yyvstop+172,
yycrank+190,	yysvec+9,	yyvstop+174,
yycrank+179,	yysvec+9,	yyvstop+176,
yycrank+183,	yysvec+9,	yyvstop+178,
yycrank+207,	yysvec+9,	yyvstop+180,
yycrank+193,	yysvec+9,	yyvstop+182,
yycrank+193,	yysvec+9,	yyvstop+184,
yycrank+195,	yysvec+9,	yyvstop+186,
yycrank+212,	yysvec+9,	yyvstop+188,
yycrank+213,	yysvec+9,	yyvstop+190,
yycrank+204,	yysvec+9,	yyvstop+192,
yycrank+211,	yysvec+9,	yyvstop+194,
yycrank+217,	yysvec+9,	yyvstop+196,
yycrank+221,	yysvec+9,	yyvstop+198,
yycrank+211,	yysvec+9,	yyvstop+200,
yycrank+218,	0,		0,	
yycrank+222,	0,		0,	
yycrank+212,	0,		0,	
yycrank+0,	0,		yyvstop+202,
yycrank+231,	0,		yyvstop+204,
yycrank+419,	0,		0,	
yycrank+0,	0,		yyvstop+206,
yycrank+0,	yysvec+9,	yyvstop+208,
yycrank+217,	yysvec+9,	yyvstop+211,
yycrank+0,	yysvec+9,	yyvstop+213,
yycrank+0,	yysvec+9,	yyvstop+216,
yycrank+209,	yysvec+9,	yyvstop+219,
yycrank+221,	yysvec+9,	yyvstop+221,
yycrank+210,	yysvec+9,	yyvstop+223,
yycrank+218,	yysvec+9,	yyvstop+225,
yycrank+221,	yysvec+9,	yyvstop+227,
yycrank+0,	yysvec+9,	yyvstop+229,
yycrank+228,	yysvec+9,	yyvstop+232,
yycrank+210,	yysvec+9,	yyvstop+234,
yycrank+0,	yysvec+9,	yyvstop+236,
yycrank+218,	yysvec+9,	yyvstop+239,
yycrank+217,	yysvec+9,	yyvstop+241,
yycrank+325,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+243,
yycrank+0,	yysvec+9,	yyvstop+246,
yycrank+235,	yysvec+9,	yyvstop+249,
yycrank+237,	yysvec+9,	yyvstop+251,
yycrank+222,	yysvec+9,	yyvstop+253,
yycrank+0,	yysvec+9,	yyvstop+255,
yycrank+225,	yysvec+9,	yyvstop+258,
yycrank+227,	yysvec+9,	yyvstop+260,
yycrank+228,	yysvec+9,	yyvstop+262,
yycrank+234,	yysvec+9,	yyvstop+264,
yycrank+241,	yysvec+9,	yyvstop+266,
yycrank+248,	yysvec+9,	yyvstop+268,
yycrank+250,	yysvec+9,	yyvstop+270,
yycrank+250,	yysvec+9,	yyvstop+272,
yycrank+249,	yysvec+9,	yyvstop+274,
yycrank+243,	yysvec+9,	yyvstop+276,
yycrank+251,	yysvec+9,	yyvstop+278,
yycrank+0,	yysvec+9,	yyvstop+280,
yycrank+239,	yysvec+9,	yyvstop+283,
yycrank+255,	yysvec+9,	yyvstop+285,
yycrank+256,	0,		0,	
yycrank+254,	0,		0,	
yycrank+262,	0,		0,	
yycrank+390,	0,		0,	
yycrank+0,	yysvec+9,	yyvstop+287,
yycrank+0,	yysvec+9,	yyvstop+290,
yycrank+284,	yysvec+9,	yyvstop+293,
yycrank+287,	yysvec+9,	yyvstop+295,
yycrank+295,	yysvec+9,	yyvstop+297,
yycrank+296,	yysvec+9,	yyvstop+299,
yycrank+0,	yysvec+9,	yyvstop+301,
yycrank+0,	yysvec+9,	yyvstop+304,
yycrank+289,	yysvec+9,	yyvstop+307,
yycrank+0,	yysvec+9,	yyvstop+309,
yycrank+0,	yysvec+9,	yyvstop+312,
yycrank+327,	yysvec+9,	yyvstop+315,
yycrank+330,	yysvec+9,	yyvstop+317,
yycrank+315,	yysvec+9,	yyvstop+319,
yycrank+322,	yysvec+9,	yyvstop+321,
yycrank+0,	yysvec+9,	yyvstop+323,
yycrank+331,	yysvec+9,	yyvstop+326,
yycrank+335,	yysvec+9,	yyvstop+328,
yycrank+319,	yysvec+9,	yyvstop+330,
yycrank+332,	yysvec+9,	yyvstop+332,
yycrank+347,	yysvec+9,	yyvstop+334,
yycrank+0,	yysvec+9,	yyvstop+336,
yycrank+0,	yysvec+9,	yyvstop+339,
yycrank+340,	yysvec+9,	yyvstop+342,
yycrank+347,	yysvec+9,	yyvstop+344,
yycrank+531,	yysvec+9,	yyvstop+346,
yycrank+343,	0,		0,	
yycrank+337,	0,		0,	
yycrank+-540,	0,		yyvstop+348,
yycrank+416,	0,		0,	
yycrank+339,	yysvec+9,	yyvstop+350,
yycrank+341,	yysvec+9,	yyvstop+352,
yycrank+358,	yysvec+9,	yyvstop+354,
yycrank+0,	yysvec+9,	yyvstop+357,
yycrank+0,	yysvec+9,	yyvstop+360,
yycrank+0,	yysvec+9,	yyvstop+363,
yycrank+358,	yysvec+9,	yyvstop+366,
yycrank+359,	yysvec+9,	yyvstop+368,
yycrank+533,	yysvec+9,	yyvstop+370,
yycrank+535,	yysvec+9,	yyvstop+373,
yycrank+0,	yysvec+9,	yyvstop+376,
yycrank+0,	yysvec+9,	yyvstop+379,
yycrank+536,	yysvec+9,	yyvstop+382,
yycrank+360,	yysvec+9,	yyvstop+384,
yycrank+363,	yysvec+9,	yyvstop+386,
yycrank+367,	yysvec+9,	yyvstop+388,
yycrank+537,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+390,
yycrank+376,	0,		0,	
yycrank+379,	0,		0,	
yycrank+0,	0,		yyvstop+393,
yycrank+388,	0,		yyvstop+395,
yycrank+380,	yysvec+9,	yyvstop+397,
yycrank+0,	yysvec+9,	yyvstop+399,
yycrank+538,	yysvec+9,	yyvstop+402,
yycrank+0,	yysvec+9,	yyvstop+404,
yycrank+394,	yysvec+9,	yyvstop+407,
yycrank+549,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+409,
yycrank+550,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+412,
yycrank+551,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+415,
yycrank+0,	yysvec+9,	yyvstop+418,
yycrank+409,	yysvec+9,	yyvstop+421,
yycrank+409,	yysvec+9,	yyvstop+423,
yycrank+534,	0,		0,	
yycrank+410,	0,		0,	
yycrank+544,	0,		0,	
yycrank+0,	yysvec+9,	yyvstop+425,
yycrank+571,	yysvec+31,	0,	
yycrank+0,	0,		yyvstop+428,
yycrank+0,	yysvec+9,	yyvstop+431,
yycrank+0,	yysvec+9,	yyvstop+434,
yycrank+0,	yysvec+9,	yyvstop+437,
yycrank+576,	0,		0,	
yycrank+-698,	0,		yyvstop+440,
yycrank+474,	0,		0,	
yycrank+700,	0,		yyvstop+442,
yycrank+0,	0,		yyvstop+444,
yycrank+0,	0,		yyvstop+446,
0,	0,	0};
struct yywork *yytop = yycrank+822;
struct yysvf *yybgin = yysvec+1;
Uchar yymatch[] = {
00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
011 ,01  ,'"' ,01  ,01  ,01  ,01  ,047 ,
01  ,01  ,01  ,01  ,',' ,01  ,01  ,01  ,
'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
'0' ,'0' ,01  ,',' ,01  ,01  ,01  ,01  ,
01  ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,01  ,047 ,01  ,01  ,'A' ,
01  ,'A' ,'b' ,'A' ,'A' ,'A' ,'b' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'b' ,'A' ,'b' ,'A' ,
'A' ,'A' ,'b' ,'A' ,'b' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
0};
Uchar yyextra[] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,1,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0};
#pragma lib	"libl.a"
int yylineno =1;
# define YYU(x) x
char yytext[YYLMAX];
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
Uchar yysbuf[YYLMAX];
Uchar *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
# ifdef LEXDEBUG
extern void allprint(int);
# endif
yylook(void){
	struct yysvf *yystate, **lsp;
	struct yywork *yyt;
	struct yysvf *yyz;
	int yych;
	struct yywork *yyr;
# ifdef LEXDEBUG
	int debug;
# endif
	Uchar *yylastch;
	/* start off machines */
# ifdef LEXDEBUG
	debug = 0;
# endif
	if (!yymorfg)
		yylastch = (Uchar*)yytext;
	else {
		yymorfg=0;
		yylastch = (Uchar*)yytext+yyleng;
		}
	for(;;){
		lsp = yylstate;
		yyestate = yystate = yybgin;
		if (yyprevious==YYNEWLINE) yystate++;
		for (;;){
# ifdef LEXDEBUG
			if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
			yyt = yystate->yystoff;
			if(yyt == yycrank){		/* may not be any transitions */
				yyz = yystate->yyother;
				if(yyz == 0)break;
				if(yyz->yystoff == yycrank)break;
				}
			*yylastch++ = yych = input();
		tryagain:
# ifdef LEXDEBUG
			if(debug){
				fprintf(yyout,"char ");
				allprint(yych);
				putchar('\n');
				}
# endif
			yyr = yyt;
			if ( (int)yyt > (int)yycrank){
				yyt = yyr + yych;
				if (yyt <= yytop && yyt->verify+yysvec == yystate){
					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
						{unput(*--yylastch);break;}
					*lsp++ = yystate = yyt->advance+yysvec;
					goto contin;
					}
				}
# ifdef YYOPTIM
			else if((int)yyt < (int)yycrank) {		/* r < yycrank */
				yyt = yyr = yycrank+(yycrank-yyt);
# ifdef LEXDEBUG
				if(debug)fprintf(yyout,"compressed state\n");
# endif
				yyt = yyt + yych;
				if(yyt <= yytop && yyt->verify+yysvec == yystate){
					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
						{unput(*--yylastch);break;}
					*lsp++ = yystate = yyt->advance+yysvec;
					goto contin;
					}
				yyt = yyr + YYU(yymatch[yych]);
# ifdef LEXDEBUG
				if(debug){
					fprintf(yyout,"try fall back character ");
					allprint(YYU(yymatch[yych]));
					putchar('\n');
					}
# endif
				if(yyt <= yytop && yyt->verify+yysvec == yystate){
					if(yyt->advance+yysvec == YYLERR)	/* error transition */
						{unput(*--yylastch);break;}
					*lsp++ = yystate = yyt->advance+yysvec;
					goto contin;
					}
				}
			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
# ifdef LEXDEBUG
				if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
# endif
				goto tryagain;
				}
# endif
			else
				{unput(*--yylastch);break;}
		contin:
# ifdef LEXDEBUG
			if(debug){
				fprintf(yyout,"state %d char ",yystate-yysvec-1);
				allprint(yych);
				putchar('\n');
				}
# endif
			;
			}
# ifdef LEXDEBUG
		if(debug){
			fprintf(yyout,"stopped at %d with ",lsp>yylstate?*(lsp-1)-yysvec-1:0);
			allprint(yych);
			putchar('\n');
			}
# endif
		while (lsp-- > yylstate){
			*yylastch-- = 0;
			if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
				yyolsp = lsp;
				if(yyextra[*yyfnd]){		/* must backup */
					while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
						lsp--;
						unput(*yylastch--);
						}
					}
				yyprevious = YYU(*yylastch);
				yylsp = lsp;
				yyleng = yylastch-(Uchar*)yytext+1;
				yytext[yyleng] = 0;
# ifdef LEXDEBUG
				if(debug){
					fprintf(yyout,"\nmatch '%s'", yytext);
					fprintf(yyout," action %d\n",*yyfnd);
					}
# endif
				return(*yyfnd++);
				}
			unput(*yylastch);
			}
		if (yytext[0] == 0  /* && feof(yyin) */)
			{
			yysptr=yysbuf;
			return(0);
			}
		yyprevious = input();
		yytext[0] = yyprevious;
		if (yyprevious>0)
			output(yyprevious);
		yylastch = (Uchar*)yytext;
# ifdef LEXDEBUG
		if(debug)putchar('\n');
# endif
		}
	}
yyback(int *p, int m)
{
if (p==0) return(0);
while (*p)
	{
	if (*p++ == m)
		return(1);
	}
return(0);
}
	/* the following are only used in the lex library */
yyinput(void){
	return(input());
}
void
yyoutput(int c)
{
	output(c);
}
void
yyunput(int c)
{
	unput(c);
}

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.