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

📄 scan_isa.cpp

📁 arm的模拟器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
			int yy_c_buf_p_offset =				(int) (yy_c_buf_p - b->yy_ch_buf);			if ( b->yy_is_our_buffer )				{				int new_size = b->yy_buf_size * 2;				if ( new_size <= 0 )					b->yy_buf_size += b->yy_buf_size / 8;				else					b->yy_buf_size *= 2;				b->yy_ch_buf = (char *)					/* Include room in for 2 EOB chars. */					yy_flex_realloc( (void *) b->yy_ch_buf,							 b->yy_buf_size + 2 );				}			else				/* Can't grow it, we don't own it. */				b->yy_ch_buf = 0;			if ( ! b->yy_ch_buf )				YY_FATAL_ERROR(				"fatal error - scanner input buffer overflow" );			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];			num_to_read = yy_current_buffer->yy_buf_size -						number_to_move - 1;#endif			}		if ( num_to_read > YY_READ_BUF_SIZE )			num_to_read = YY_READ_BUF_SIZE;		/* Read in more data. */		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),			yy_n_chars, num_to_read );		yy_current_buffer->yy_n_chars = yy_n_chars;		}	if ( yy_n_chars == 0 )		{		if ( number_to_move == YY_MORE_ADJ )			{			ret_val = EOB_ACT_END_OF_FILE;			yyrestart( yyin );			}		else			{			ret_val = EOB_ACT_LAST_MATCH;			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 */yy_state_type yyFlexLexer::yy_get_previous_state()	{	register yy_state_type yy_current_state;	register char *yy_cp;	yy_current_state = yy_start;	yy_state_ptr = yy_state_buf;	*yy_state_ptr++ = yy_current_state;	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);		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 >= 64 )				yy_c = yy_meta[(unsigned int) yy_c];			}		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];		*yy_state_ptr++ = yy_current_state;		}	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 ); */yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )	{	register int yy_is_jam;	register YY_CHAR yy_c = 1;	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 >= 64 )			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 == 63);	if ( ! yy_is_jam )		*yy_state_ptr++ = yy_current_state;	return yy_is_jam ? 0 : yy_current_state;	}void yyFlexLexer::yyunput( int c, register char* yy_bp )	{	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;	if ( c == '\n' )		--yylineno;	yytext_ptr = yy_bp;	yy_hold_char = *yy_cp;	yy_c_buf_p = yy_cp;	}int yyFlexLexer::yyinput()	{	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;	if ( c == '\n' )		++yylineno;	return c;	}void yyFlexLexer::yyrestart( istream* input_file )	{	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();	}void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )	{	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;	}void yyFlexLexer::yy_load_buffer_state()	{	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;	}YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )	{	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;	}void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )	{	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 );	}void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )	{	yy_flush_buffer( b );	b->yy_input_file = file;	b->yy_fill_buffer = 1;	b->yy_is_interactive = 0;	}void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )	{	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#endif#ifndef YY_NO_SCAN_STRING#endif#ifndef YY_NO_SCAN_BYTES#endif#ifndef YY_NO_PUSH_STATEvoid yyFlexLexer::yy_push_state( int new_state )	{	if ( yy_start_stack_ptr >= yy_start_stack_depth )		{		yy_size_t new_size;		yy_start_stack_depth += YY_START_STACK_INCR;		new_size = yy_start_stack_depth * sizeof( int );		if ( ! yy_start_stack )			yy_start_stack = (int *) yy_flex_alloc( new_size );		else			yy_start_stack = (int *) yy_flex_realloc(					(void *) yy_start_stack, new_size );		if ( ! yy_start_stack )			YY_FATAL_ERROR(			"out of memory expanding start-condition stack" );		}	yy_start_stack[yy_start_stack_ptr++] = YY_START;	BEGIN(new_state);	}#endif#ifndef YY_NO_POP_STATEvoid yyFlexLexer::yy_pop_state()	{	if ( --yy_start_stack_ptr < 0 )		YY_FATAL_ERROR( "start-condition stack underflow" );	BEGIN(yy_start_stack[yy_start_stack_ptr]);	}#endif#ifndef YY_NO_TOP_STATEint yyFlexLexer::yy_top_state()	{	return yy_start_stack[yy_start_stack_ptr - 1];	}#endif#ifndef YY_EXIT_FAILURE#define YY_EXIT_FAILURE 2#endifvoid yyFlexLexer::LexerError( yyconst char msg[] )	{	cerr << msg << '\n';	exit( YY_EXIT_FAILURE );	}/* Redefine yyless() so it works in section 3 code. */#undef yyless#define yyless(n) \	do \		{ \		/* Undo effects of setting up yytext. */ \		yytext[yyleng] = yy_hold_char; \		yy_c_buf_p = yytext + n; \		yy_hold_char = *yy_c_buf_p; \		*yy_c_buf_p = '\0'; \		yyleng = n; \		} \	while ( 0 )/* Internal utility routines. */#ifndef yytext_ptr#ifdef YY_USE_PROTOSstatic void yy_flex_strncpy( char *s1, yyconst char *s2, int n )#elsestatic void yy_flex_strncpy( s1, s2, n )char *s1;yyconst char *s2;int n;#endif	{	register int i;	for ( i = 0; i < n; ++i )		s1[i] = s2[i];	}#endif#ifdef YY_NEED_STRLEN#ifdef YY_USE_PROTOSstatic int yy_flex_strlen( yyconst char *s )#elsestatic int yy_flex_strlen( s )yyconst char *s;#endif	{	register int n;	for ( n = 0; s[n]; ++n )		;	return n;	}#endif#ifdef YY_USE_PROTOSstatic void *yy_flex_alloc( yy_size_t size )#elsestatic void *yy_flex_alloc( size )yy_size_t size;#endif	{	return (void *) malloc( size );	}#ifdef YY_USE_PROTOSstatic void *yy_flex_realloc( void *ptr, yy_size_t size )#elsestatic void *yy_flex_realloc( ptr, size )void *ptr;yy_size_t size;#endif	{	/* The cast to (char *) in the following accommodates both	 * implementations that use char* generic pointers, and those	 * that use void* generic pointers.  It works with the latter	 * because both ANSI C and C++ allow castless assignment from	 * any pointer type to void*, and deal with argument conversions	 * as though doing an assignment.	 */	return (void *) realloc( (char *) ptr, size );	}#ifdef YY_USE_PROTOSstatic void yy_flex_free( void *ptr )#elsestatic void yy_flex_free( ptr )void *ptr;#endif	{	free( ptr );	}#if YY_MAINint main()	{	yylex();	return 0;	}#endif#line 106 "scan_isa.l"void isa_error (char *s){	fprintf(stderr, "%s near line %d\n", s, isa_lexer->lineno());	exit(1);}int isa_lex(){    return isa_lexer->yylex();                                    }isa_prog *isa_parse_wrapper(ifstream *infile, const char *fname){	isa_filename = fname;	isa_lexer = new isa_FlexLexer(infile);	isa_parse();	delete isa_lexer;	return isa_parser_result;}

⌨️ 快捷键说明

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