⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lexyy.c

📁 LEX程序 用来生成词法分析器
💻 C
📖 第 1 页 / 共 2 页
字号:
       0, 14,  9,  9, 15, 16,  9,  9,  9,  9,  9,  9,  9,  9, 17,  9,
       9,  9, 18,  9,  9,  9, 19,  9,  9,  9,  9,  0,  0,  0,  0,  0
};

YYPRIVATE YY_TTYPE Yy_rmap[25] =
{
      0,  1,  2,  3,  2,  2,  2,  2,  1,  1,  2,  4,  5,  6,  7,  8,
       9, 10, 11, 12, 13, 14, 15, 16, 17
};

YYPRIVATE YY_TTYPE Yy_nxt[ 18 ][ 20 ]=
{
/* 00 */ { -1,   6,   5,   4,   3,  11,   2,  -1,   1,   1,   1,   1,  24,  18,   1,   1,  23,   1,  22,  17
         },
/* 01 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1
         },
/* 02 */ { -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1
         },
/* 03 */ { -1,  -1,  -1,  -1,   3,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1
         },
/* 04 */ { -1,  -1,  -1,  -1,  -1,  -1,  -1,   7,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1
         },
/* 05 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   8,   1
         },
/* 06 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   8,   1,   1,   1,   1,   1,   1,   1
         },
/* 07 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,   9,   1,   1,   1,   1
         },
/* 08 */ { 10,  10,  10,  10,   1,  10,  10,  10,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1
         },
/* 09 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   9,   1,   1,   1,   1,   1,   1,   1,   1,   1
         },
/* 10 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,  12,   1,   1,   1,   1,   1
         },
/* 11 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,  13,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1
         },
/* 12 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,  14,   1,   1,   1,   1,   1
         },
/* 13 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,  15,   1,   1,   1,   1
         },
/* 14 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,  16,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1
         },
/* 15 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,   1,  19,   1,   1,   1
         },
/* 16 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  20,   1,   1
         },
/* 17 */ { -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,   1,   1,   1,  21,   1,   1,   1,   1,   1,   1,   1,   1
         } 
};

/*-----------------------------------------------
*yy_next( state, c ) is given the current state number and input
*character and evaluates to the next state. 
*/

#define yy_next( state, c ) ( Yy_nxt[ Yy_rmap[state] ][ Yy_cmap[c] ] )

/*-----------------------------------------------
*The Yyaccept array has two purposes. If Yyaccept[i] is 0 then 
*state i is nonaccepting. If it's nonzero then the number determines
*whether the string is anchored 
*/

YYPRIVATE YY_TTYPE Yyaccept[] =
{
	0 ,	/*state 0   */
	4  ,	/*state 1   */
	4  ,	/*state 2   */
	4  ,	/*state 3   */
	4  ,	/*state 4   */
	4  ,	/*state 5   */
	4  ,	/*state 6   */
	4  ,	/*state 7   */
	4  ,	/*state 8   */
	4  ,	/*state 9   */
	4  ,	/*state 10  */
	0 ,	/*state 11  */
	4  ,	/*state 12  */
	4  ,	/*state 13  */
	4  ,	/*state 14  */
	4  ,	/*state 15  */
	4  ,	/*state 16  */
	4  ,	/*state 17  */
	4  ,	/*state 18  */
	4  ,	/*state 19  */
	4  ,	/*state 20  */
	4  ,	/*state 21  */
	4  ,	/*state 22  */
	4  ,	/*state 23  */
	4   	/*state 24  */
};


#line 198 "lex.par"

/* Global variables used by the parser. */
char	*yytext ;
int		yyleng ;
int		yylineno ;
FILE	*yyout =stdout ;

#define output(c) 	putc(c,yyout)
#define ECHO		fprintf(yyout,"%s", yytext)

#ifndef	YYERROR
#	define	YYERROR(t)	fprintf(stderr,"%s", t )
#endif

#define yymore()	yymoreflg=1

#define	unput(c)	(ii_unput(c), --yyleng )
#define	yyless(n)	(  ii_unterm(), \
								( yyleng -=ii_pushback(n)? n:yyleng ), \
								ii_term() \
							)

#define yywrap()	1

/*-------------------------------------------------------------------*/

yylex()
{
	int	yymoreflg ;
	static int 	yystate =-1 ;
	int	yylastaccept ;
	int yyprev ;
	int yynstate ;
	int	yylook ;
	int	yyanchor ;

	yystate =0 ;
	yylastaccept =0;
	yymoreflg =0 ;
	ii_unterm();
	ii_mark_start();

	while(1)
	{
		while(1)
		{
			yylook = ii_look(1);
			if( yylook == EOLN )
			{
				yynstate = YYF;
				break;
			}
			if( yylook !=EOF )
			{
				yynstate =yy_next( yystate, yylook );
				break ;
			}
			else
			{
				if( yylastaccept )
				{
					yynstate =YYF ;
					break ;
				}
				else if( yywrap() )
				{
					yytext ="" ;
					yyleng =0 ;
					return 0 ;
				}
				else
				{
					ii_advance() ;
					ii_pushback(1) ;
				}
			}
		}

		if( yynstate !=YYF )
		{
			YY_D( printf("  Transition from state %d", yystate)  ) ;
			YY_D( printf(" to state %d on <%c>\n", yynstate, yylook ) );

			ii_advance();

			if( (yyanchor =Yyaccept[ yynstate ]) != 0)
			{
				yyprev =yystate;
				yylastaccept =yynstate;
				ii_mark_end();
			}
			yystate =yynstate;
		}
		else
		{
			if( !yylastaccept )
			{
#ifdef	YYBADINP
				YYERROR("Ignoring bad input\n") ;
#endif
				ii_advance() ;
			}
			else
			{
				ii_to_mark();

				ii_term();
				yyleng =ii_length();
				yytext =ii_text() ;
				yylineno =ii_lineno() ;

				YY_D( printf("Accepting state %d, ", yylastaccept ) ) ;
				YY_D( printf("line %d: <%s>\n", yylineno, yytext ) );

				switch( yylastaccept )
				{
		case 1:					/* state 1   */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 2:					/* state 2   */
#line 9 "test.lex"
		    { cc[4]++;}
		    break;
		case 3:					/* state 3   */
#line 13 "test.lex"
		    {cc[2]++; }
		    break;
		case 4:					/* state 4   */
#line 6 "test.lex"
		    {cc[3]++; }
		    break;
		case 5:					/* state 5   */
#line 8 "test.lex"
		    { cc[4]++;}
		    break;
		case 6:					/* state 6   */
#line 5 "test.lex"
		    {cc[3]++;}
		    break;
		case 7:					/* state 7   */
#line 7 "test.lex"
		    { cc[4]++;}
		    break;
		case 8:					/* state 8   */
#line 10 "test.lex"
		    {cc[1]++; }
		    break;
		case 9:					/* state 9   */
#line 11 "test.lex"
		    {cc[1]++; }
		    break;
		case 10:					/* state 10  */
#line 14 "test.lex"
		    { printf("\nident:%5d\treserved:%5d\tnumber:%5d\toperator:%5d\tseparator:%5d",cc[0],cc[1],cc[2],cc[3],cc[4]); }
		    break;
		case 12:					/* state 12  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 13:					/* state 13  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 14:					/* state 14  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 15:					/* state 15  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 16:					/* state 16  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 17:					/* state 17  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 18:					/* state 18  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 19:					/* state 19  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 20:					/* state 20  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 21:					/* state 21  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 22:					/* state 22  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 23:					/* state 23  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;
		case 24:					/* state 24  */
#line 12 "test.lex"
		    {cc[0]++; }
		    break;

#line 315 "lex.par"
				default:
						YYERROR( "Internal error, yylex\n") ;
						break ;
				}
			}

			ii_unterm() ;
			yylastaccept =0 ;

			if( !yymoreflg )
			{
				yystate=0 ;
				ii_mark_start() ;
			}
			else
			{
				yystate =yyprev ;
				yymoreflg =0 ;
            }
		}
	}
}
#line 16 "test.lex"

⌨️ 快捷键说明

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