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

📄 lexer.c

📁 这是一个非常有价值的参考代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			yy_current_buffer->yy_buffer_status =				YY_BUFFER_EOF_PENDING;			}		}	else		ret_val = EOB_ACT_CONTINUE_SCAN;	yy_n_chars += number_to_move;	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];	return ret_val;	}/* yy_get_previous_state - get the state just before the EOB char was reached */static yy_state_type yy_get_previous_state()	{	register yy_state_type yy_current_state;	register char *yy_cp;	yy_current_state = yy_start;	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )		{		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);		if ( yy_accept[yy_current_state] )			{			yy_last_accepting_state = yy_current_state;			yy_last_accepting_cpos = yy_cp;			}		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )			{			yy_current_state = (int) yy_def[yy_current_state];			if ( yy_current_state >= 552 )				yy_c = yy_meta[(unsigned int) yy_c];			}		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];		}	return yy_current_state;	}/* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis *	next_state = yy_try_NUL_trans( current_state ); */#ifdef YY_USE_PROTOSstatic yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )#elsestatic yy_state_type yy_try_NUL_trans( yy_current_state )yy_state_type yy_current_state;#endif	{	register int yy_is_jam;	register char *yy_cp = yy_c_buf_p;	register YY_CHAR yy_c = 1;	if ( yy_accept[yy_current_state] )		{		yy_last_accepting_state = yy_current_state;		yy_last_accepting_cpos = yy_cp;		}	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )		{		yy_current_state = (int) yy_def[yy_current_state];		if ( yy_current_state >= 552 )			yy_c = yy_meta[(unsigned int) yy_c];		}	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];	yy_is_jam = (yy_current_state == 551);	return yy_is_jam ? 0 : yy_current_state;	}#ifndef YY_NO_UNPUT#ifdef YY_USE_PROTOSstatic void yyunput( int c, register char *yy_bp )#elsestatic void yyunput( c, yy_bp )int c;register char *yy_bp;#endif	{	register char *yy_cp = yy_c_buf_p;	/* undo effects of setting up yytext */	*yy_cp = yy_hold_char;	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )		{ /* need to shift things up to make room */		/* +2 for EOB chars. */		register int number_to_move = yy_n_chars + 2;		register char *dest = &yy_current_buffer->yy_ch_buf[					yy_current_buffer->yy_buf_size + 2];		register char *source =				&yy_current_buffer->yy_ch_buf[number_to_move];		while ( source > yy_current_buffer->yy_ch_buf )			*--dest = *--source;		yy_cp += (int) (dest - source);		yy_bp += (int) (dest - source);		yy_current_buffer->yy_n_chars =			yy_n_chars = yy_current_buffer->yy_buf_size;		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )			YY_FATAL_ERROR( "flex scanner push-back overflow" );		}	*--yy_cp = (char) c;	yytext_ptr = yy_bp;	yy_hold_char = *yy_cp;	yy_c_buf_p = yy_cp;	}#endif	/* ifndef YY_NO_UNPUT */#ifdef __cplusplusstatic int yyinput()#elsestatic int input()#endif	{	int c;	*yy_c_buf_p = yy_hold_char;	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )		{		/* yy_c_buf_p now points to the character we want to return.		 * If this occurs *before* the EOB characters, then it's a		 * valid NUL; if not, then we've hit the end of the buffer.		 */		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )			/* This was really a NUL. */			*yy_c_buf_p = '\0';		else			{ /* need more input */			int offset = yy_c_buf_p - yytext_ptr;			++yy_c_buf_p;			switch ( yy_get_next_buffer() )				{				case EOB_ACT_LAST_MATCH:					/* This happens because yy_g_n_b()					 * sees that we've accumulated a					 * token and flags that we need to					 * try matching the token before					 * proceeding.  But for input(),					 * there's no matching to consider.					 * So convert the EOB_ACT_LAST_MATCH					 * to EOB_ACT_END_OF_FILE.					 */					/* Reset buffer status. */					yyrestart( yyin );					/* fall through */				case EOB_ACT_END_OF_FILE:					{					if ( yywrap() )						return EOF;					if ( ! yy_did_buffer_switch_on_eof )						YY_NEW_FILE;#ifdef __cplusplus					return yyinput();#else					return input();#endif					}				case EOB_ACT_CONTINUE_SCAN:					yy_c_buf_p = yytext_ptr + offset;					break;				}			}		}	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */	*yy_c_buf_p = '\0';	/* preserve yytext */	yy_hold_char = *++yy_c_buf_p;	return c;	}#ifdef YY_USE_PROTOSvoid yyrestart( FILE *input_file )#elsevoid yyrestart( input_file )FILE *input_file;#endif	{	if ( ! yy_current_buffer )		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );	yy_init_buffer( yy_current_buffer, input_file );	yy_load_buffer_state();	}#ifdef YY_USE_PROTOSvoid yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )#elsevoid yy_switch_to_buffer( new_buffer )YY_BUFFER_STATE new_buffer;#endif	{	if ( yy_current_buffer == new_buffer )		return;	if ( yy_current_buffer )		{		/* Flush out information for old buffer. */		*yy_c_buf_p = yy_hold_char;		yy_current_buffer->yy_buf_pos = yy_c_buf_p;		yy_current_buffer->yy_n_chars = yy_n_chars;		}	yy_current_buffer = new_buffer;	yy_load_buffer_state();	/* We don't actually know whether we did this switch during	 * EOF (yywrap()) processing, but the only time this flag	 * is looked at is after yywrap() is called, so it's safe	 * to go ahead and always set it.	 */	yy_did_buffer_switch_on_eof = 1;	}#ifdef YY_USE_PROTOSvoid yy_load_buffer_state( void )#elsevoid yy_load_buffer_state()#endif	{	yy_n_chars = yy_current_buffer->yy_n_chars;	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;	yyin = yy_current_buffer->yy_input_file;	yy_hold_char = *yy_c_buf_p;	}#ifdef YY_USE_PROTOSYY_BUFFER_STATE yy_create_buffer( FILE *file, int size )#elseYY_BUFFER_STATE yy_create_buffer( file, size )FILE *file;int size;#endif	{	YY_BUFFER_STATE b;	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );	if ( ! b )		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );	b->yy_buf_size = size;	/* yy_ch_buf has to be 2 characters longer than the size given because	 * we need to put in 2 end-of-buffer characters.	 */	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );	if ( ! b->yy_ch_buf )		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );	b->yy_is_our_buffer = 1;	yy_init_buffer( b, file );	return b;	}#ifdef YY_USE_PROTOSvoid yy_delete_buffer( YY_BUFFER_STATE b )#elsevoid yy_delete_buffer( b )YY_BUFFER_STATE b;#endif	{	if ( ! b )		return;	if ( b == yy_current_buffer )		yy_current_buffer = (YY_BUFFER_STATE) 0;	if ( b->yy_is_our_buffer )		yy_flex_free( (void *) b->yy_ch_buf );	yy_flex_free( (void *) b );	}#ifndef YY_ALWAYS_INTERACTIVE#ifndef YY_NEVER_INTERACTIVEextern int isatty YY_PROTO(( int ));#endif#endif#ifdef YY_USE_PROTOSvoid yy_init_buffer( YY_BUFFER_STATE b, FILE *file )#elsevoid yy_init_buffer( b, file )YY_BUFFER_STATE b;FILE *file;#endif	{	yy_flush_buffer( b );	b->yy_input_file = file;	b->yy_fill_buffer = 1;#if YY_ALWAYS_INTERACTIVE	b->yy_is_interactive = 1;#else#if YY_NEVER_INTERACTIVE	b->yy_is_interactive = 0;#else	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;#endif#endif	}#ifdef YY_USE_PROTOSvoid yy_flush_buffer( YY_BUFFER_STATE b )#elsevoid yy_flush_buffer( b )YY_BUFFER_STATE b;#endif	{	if ( ! b )		return;	b->yy_n_chars = 0;	/* We always need two end-of-buffer characters.  The first causes	 * a transition to the end-of-buffer state.  The second causes	 * a jam in that state.	 */	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;	b->yy_buf_pos = &b->yy_ch_buf[0];	b->yy_at_bol = 1;	b->yy_buffer_status = YY_BUFFER_NEW;	if ( b == yy_current_buffer )		yy_load_buffer_state();	}#ifndef YY_NO_SCAN_BUFFER#ifdef YY_USE_PROTOSYY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )#elseYY_BUFFER_STATE yy_scan_buffer( base, size )char *base;yy_size_t size;#endif	{	YY_BUFFER_STATE b;	if ( size < 2 ||	     base[size-2] != YY_END_OF_BUFFER_CHAR ||	     base[size-1] != YY_END_OF_BUFFER_CHAR )		/* They forgot to leave room for the EOB's. */		return 0;	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );	if ( ! b )		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */	b->yy_buf_pos = b->yy_ch_buf = base;	b->yy_is_our_buffer = 0;	b->yy_input_file = 0;	b->yy_n_chars = b->yy_buf_size;	b->yy_is_interactive = 0;	b->yy_at_bol = 1;	b->yy_fill_buffer = 0;	b->yy_buffer_status = YY_BUFFER_NEW;	yy_switch_to_buffer( b );	return b;	}#endif#ifndef YY_NO_SCAN_STRING#ifdef YY_USE_PROTOSYY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )#elseYY_BUFFER_STATE yy_scan_string( yy_str )yyconst char *yy_str;#endif	{	int len;	for ( len = 0; yy_str[len]; ++len )		;	return yy_scan_bytes( yy_str, len );	}#endif#ifndef YY_NO_SCAN_BYTES#ifdef YY_USE_PROTOSYY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )#elseYY_BUFFER_STATE yy_scan_bytes( bytes, len )yyconst char *bytes;int len;#endif	{	YY_BUFFER_STATE b;	char *buf;	yy_size_t n;	int i;	/* Get memory for full buffer, including space for trailing EOB's. */	n = len + 2;	buf = (char *) yy_flex_alloc( n );	if ( ! buf )		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );	for ( i = 0; i < len; ++i )		buf[i] = bytes[i];	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;	b = yy_scan_buffer( buf, n );	if ( ! b )		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );	/* It's okay to grow etc. this buff

⌨️ 快捷键说明

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