lexyy.c

来自「一个小型的c语言编译器,做的非常好,不过不是我做的.」· C语言 代码 · 共 999 行 · 第 1/2 页

C
999
字号
6,
0,

5,
0,

26,
0,

35,
0,

4,
0,

31,
0,

36,
0,

27,
0,

44,
0,

42,
0,

28,
0,

9,
0,

51,
0,

8,
0,

7,
0,

45,
0,

46,
0,

8,
0,

55,
0,
0};
# define YYTYPE char
struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0,	0,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,0,	1,0,	
1,0,	1,0,	1,3,	1,4,	
1,5,	1,0,	1,6,	1,7,	
1,8,	1,9,	1,10,	1,11,	
1,12,	1,13,	1,14,	1,15,	
1,16,	1,17,	1,18,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	1,18,	0,0,	1,19,	
1,20,	1,21,	1,22,	1,23,	
1,24,	1,0,	1,25,	0,0,	
0,0,	0,0,	1,25,	0,0,	
1,25,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	7,37,	
0,0,	0,0,	0,0,	0,0,	
0,0,	39,67,	12,42,	40,39,	
1,26,	1,0,	1,27,	1,28,	
3,33,	1,0,	14,44,	16,48,	
46,68,	0,0,	0,0,	0,0,	
16,49,	6,36,	7,38,	11,41,	
12,43,	22,60,	23,61,	23,62,	
28,63,	30,64,	14,45,	0,0,	
0,0,	0,0,	16,50,	0,0,	
0,0,	0,0,	0,0,	0,0,	
1,29,	1,30,	1,31,	1,32,	
1,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,0,	2,0,	2,0,	
2,0,	2,3,	4,4,	2,5,	
2,0,	2,6,	2,7,	5,35,	
2,9,	2,10,	2,11,	35,66,	
2,13,	2,14,	2,15,	2,16,	
30,65,	55,55,	55,55,	55,55,	
55,55,	55,55,	55,55,	55,55,	
55,55,	55,55,	2,19,	2,20,	
2,21,	2,22,	57,72,	2,24,	
2,0,	62,73,	66,74,	4,34,	
70,69,	74,77,	77,78,	78,79,	
4,4,	8,39,	79,80,	0,0,	
4,4,	0,0,	0,0,	0,0,	
0,0,	4,4,	4,4,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	4,4,	0,0,	2,26,	
2,0,	2,27,	2,28,	4,4,	
2,0,	0,0,	4,4,	0,0,	
70,69,	0,0,	4,4,	0,0,	
4,4,	0,0,	8,39,	0,0,	
0,0,	0,0,	0,0,	8,40,	
0,0,	0,0,	0,0,	8,39,	
0,0,	0,0,	0,0,	0,0,	
8,39,	8,39,	0,0,	2,29,	
2,30,	2,31,	2,32,	2,0,	
8,39,	0,0,	0,0,	0,0,	
0,0,	0,0,	8,39,	0,0,	
0,0,	8,39,	0,0,	0,0,	
0,0,	8,39,	15,46,	8,39,	
15,47,	15,47,	15,47,	15,47,	
15,47,	15,47,	15,47,	15,47,	
15,47,	15,47,	17,51,	21,56,	
17,52,	17,52,	17,52,	17,52,	
17,52,	17,52,	17,52,	17,52,	
17,53,	17,53,	18,51,	0,0,	
18,55,	18,18,	18,18,	18,18,	
18,18,	18,18,	18,18,	18,18,	
18,18,	18,18,	51,70,	51,70,	
51,70,	51,70,	51,70,	51,70,	
51,70,	51,70,	51,70,	51,70,	
21,56,	0,0,	0,0,	0,0,	
0,0,	21,56,	0,0,	0,0,	
17,54,	21,56,	0,0,	0,0,	
0,0,	0,0,	21,56,	21,56,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	21,56,	0,0,	
0,0,	0,0,	21,57,	21,58,	
21,59,	0,0,	0,0,	21,56,	
0,0,	0,0,	0,0,	21,56,	
0,0,	21,56,	0,0,	0,0,	
17,54,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	0,0,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
0,0,	0,0,	0,0,	0,0,	
25,25,	0,0,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
25,25,	25,25,	25,25,	25,25,	
47,47,	47,47,	47,47,	47,47,	
47,47,	47,47,	47,47,	47,47,	
47,47,	47,47,	52,52,	52,52,	
52,52,	52,52,	52,52,	52,52,	
52,52,	52,52,	52,53,	52,53,	
0,0,	47,69,	53,53,	53,53,	
53,53,	53,53,	53,53,	53,53,	
53,53,	53,53,	53,53,	53,53,	
0,0,	0,0,	0,0,	0,0,	
0,0,	54,71,	54,71,	54,71,	
54,71,	54,71,	54,71,	54,71,	
54,71,	54,71,	54,71,	0,0,	
0,0,	0,0,	0,0,	0,0,	
0,0,	47,69,	54,71,	54,71,	
54,71,	54,71,	54,71,	54,71,	
56,56,	69,75,	0,0,	69,75,	
0,0,	0,0,	69,76,	69,76,	
69,76,	69,76,	69,76,	69,76,	
69,76,	69,76,	69,76,	69,76,	
75,76,	75,76,	75,76,	75,76,	
75,76,	75,76,	75,76,	75,76,	
75,76,	75,76,	54,71,	54,71,	
54,71,	54,71,	54,71,	54,71,	
0,0,	56,56,	0,0,	0,0,	
0,0,	0,0,	56,56,	0,0,	
0,0,	0,0,	56,56,	0,0,	
0,0,	0,0,	0,0,	56,56,	
56,56,	0,0,	0,0,	0,0,	
0,0,	0,0,	0,0,	56,56,	
0,0,	0,0,	0,0,	0,0,	
0,0,	56,59,	0,0,	0,0,	
56,56,	0,0,	0,0,	0,0,	
56,56,	0,0,	56,56,	0,0,	
0,0};
struct yysvf yysvec[] = {
0,	0,	0,
yycrank+-1,	0,		0,	
yycrank+-128,	yysvec+1,	0,	
yycrank+35,	0,		yyvstop+1,
yycrank+-161,	0,		0,	
yycrank+62,	0,		0,	
yycrank+44,	0,		yyvstop+3,
yycrank+45,	0,		yyvstop+5,
yycrank+-200,	0,		yyvstop+7,
yycrank+0,	0,		yyvstop+9,
yycrank+0,	0,		yyvstop+11,
yycrank+46,	0,		yyvstop+13,
yycrank+47,	0,		yyvstop+15,
yycrank+0,	0,		yyvstop+17,
yycrank+53,	0,		yyvstop+19,
yycrank+224,	0,		0,	
yycrank+57,	0,		yyvstop+21,
yycrank+236,	0,		yyvstop+23,
yycrank+248,	0,		yyvstop+25,
yycrank+0,	0,		yyvstop+27,
yycrank+0,	0,		yyvstop+29,
yycrank+-282,	0,		yyvstop+31,
yycrank+48,	0,		yyvstop+33,
yycrank+49,	0,		yyvstop+35,
yycrank+0,	0,		yyvstop+37,
yycrank+309,	0,		yyvstop+39,
yycrank+0,	0,		yyvstop+41,
yycrank+0,	0,		yyvstop+43,
yycrank+51,	0,		yyvstop+45,
yycrank+0,	0,		yyvstop+47,
yycrank+52,	0,		yyvstop+49,
yycrank+0,	0,		yyvstop+51,
yycrank+0,	0,		yyvstop+53,
yycrank+0,	0,		yyvstop+55,
yycrank+0,	0,		yyvstop+57,
yycrank+61,	0,		0,	
yycrank+0,	0,		yyvstop+59,
yycrank+0,	0,		yyvstop+61,
yycrank+0,	0,		yyvstop+63,
yycrank+50,	0,		0,	
yycrank+52,	0,		0,	
yycrank+0,	0,		yyvstop+65,
yycrank+0,	0,		yyvstop+67,
yycrank+0,	0,		yyvstop+69,
yycrank+0,	0,		yyvstop+71,
yycrank+0,	0,		yyvstop+73,
yycrank+54,	0,		0,	
yycrank+384,	0,		yyvstop+75,
yycrank+0,	0,		yyvstop+77,
yycrank+0,	0,		yyvstop+79,
yycrank+0,	0,		yyvstop+81,
yycrank+258,	0,		0,	
yycrank+394,	yysvec+18,	yyvstop+83,
yycrank+406,	yysvec+18,	0,	
yycrank+421,	0,		0,	
yycrank+128,	yysvec+18,	yyvstop+85,
yycrank+-491,	0,		0,	
yycrank+-129,	yysvec+56,	yyvstop+87,
yycrank+0,	yysvec+56,	yyvstop+89,
yycrank+0,	0,		yyvstop+91,
yycrank+0,	0,		yyvstop+93,
yycrank+0,	0,		yyvstop+95,
yycrank+132,	0,		yyvstop+97,
yycrank+0,	0,		yyvstop+99,
yycrank+0,	0,		yyvstop+101,
yycrank+0,	0,		yyvstop+103,
yycrank+95,	0,		0,	
yycrank+0,	0,		yyvstop+105,
yycrank+0,	0,		yyvstop+107,
yycrank+450,	0,		0,	
yycrank+127,	yysvec+51,	yyvstop+109,
yycrank+0,	yysvec+54,	yyvstop+111,
yycrank+0,	yysvec+56,	yyvstop+113,
yycrank+0,	0,		yyvstop+115,
yycrank+89,	0,		0,	
yycrank+460,	0,		0,	
yycrank+0,	yysvec+75,	yyvstop+117,
yycrank+81,	0,		0,	
yycrank+99,	0,		0,	
yycrank+101,	0,		0,	
yycrank+0,	0,		yyvstop+119,
0,	0,	0};
struct yywork *yytop = yycrank+562;
struct yysvf *yybgin = yysvec+1;
char yymatch[] = {
00  ,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  ,047 ,
01  ,01  ,01  ,'+' ,01  ,'+' ,01  ,01  ,
'0' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,
'8' ,'8' ,01  ,01  ,01  ,01  ,'>' ,01  ,
01  ,'A' ,'A' ,'A' ,'A' ,'E' ,'A' ,'G' ,
'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
'G' ,'G' ,'G' ,01  ,01  ,01  ,01  ,'G' ,
01  ,'A' ,'A' ,'A' ,'A' ,'E' ,'A' ,'G' ,
'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
'G' ,'G' ,'G' ,01  ,01  ,01  ,01  ,01  ,
0};
char 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,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0};
/*	ncform	4.1	83/08/11	*/

int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
char yytext[YYLMAX];
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
yylook(){
	register struct yysvf *yystate, **lsp;
	register struct yywork *yyt;
	struct yysvf *yyz;
	int yych;
	struct yywork *yyr;
# ifdef LEXDEBUG
	int debug;
# endif
	char *yylastch;
	/* start off machines */
# ifdef LEXDEBUG
	debug = 0;
# endif
	if (!yymorfg)
		yylastch = yytext;
	else {
		yymorfg=0;
		yylastch = 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-1)-yysvec-1);
			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-yytext+1;
				yytext[yyleng] = 0;
# ifdef LEXDEBUG
				if(debug){
					fprintf(yyout,"\nmatch ");
					sprint(yytext);
					fprintf(yyout," action %d\n",*yyfnd);
					}
# endif
				return(*yyfnd++);
				}
			unput(*yylastch);
			}
		if (yytext[0] == 0  /* && feof(yyin) */)
			{
			yysptr=yysbuf;
			return(0);
			}
		yyprevious = yytext[0] = input();
		if (yyprevious>0)
			output(yyprevious);
		yylastch=yytext;
# ifdef LEXDEBUG
		if(debug)putchar('\n');
# endif
		}
	}
yyback(p, m)
	int *p;
{
if (p==0) return(0);
while (*p)
	{
	if (*p++ == m)
		return(1);
	}
return(0);
}
	/* the following are only used in the lex library */
yyinput(){
	return(input());
	}
yyoutput(c)
  int c; {
	output(c);
	}
yyunput(c)
   int c; {
	unput(c);
	}



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?