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

📄 cmdlex.cc

📁 sdcc是为51等小型嵌入式cpu设计的c语言编译器支持数种不同类型的cpu
💻 CC
📖 第 1 页 / 共 3 页
字号:
		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )			*--dest = *--source;		yy_cp += (int) (dest - source);		yy_bp += (int) (dest - source);		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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;}    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_LVALUE->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 );					/*FALLTHROUGH*/				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;}/** Immediately switch to a different input stream. * @param input_file A readable stream. *  * @note This function does not reset the start condition to @c INITIAL . */    void yyFlexLexer::yyrestart( std::istream* input_file ){    	if ( ! YY_CURRENT_BUFFER ){        yyensure_buffer_stack ();		YY_CURRENT_BUFFER_LVALUE =            yy_create_buffer( yyin, YY_BUF_SIZE );	}	yy_init_buffer( YY_CURRENT_BUFFER, input_file );	yy_load_buffer_state(  );}/** Switch to a different input buffer. * @param new_buffer The new input buffer. *  */    void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ){    	/* TODO. We should be able to replace this entire function body	 * with	 *		yypop_buffer_state();	 *		yypush_buffer_state(new_buffer);     */	yyensure_buffer_stack ();	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_LVALUE->yy_buf_pos = (yy_c_buf_p);		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);		}	YY_CURRENT_BUFFER_LVALUE = 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_LVALUE->yy_n_chars;	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;	(yy_hold_char) = *(yy_c_buf_p);}/** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. *  * @return the allocated buffer state. */    YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ){	YY_BUFFER_STATE b;    	b = (YY_BUFFER_STATE) yyalloc(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 *) yyalloc(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;}/** Destroy the buffer. * @param b a buffer created with yy_create_buffer() *  */    void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ){    	if ( ! b )		return;	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;	if ( b->yy_is_our_buffer )		yyfree((void *) b->yy_ch_buf  );	yyfree((void *) b  );}extern "C" int isatty (int );/* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */    void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file ){	int oerrno = errno;    	yy_flush_buffer( b );	b->yy_input_file = file;	b->yy_fill_buffer = 1;    /* If b is the current buffer, then yy_init_buffer was _probably_     * called from yyrestart() or through yy_get_next_buffer.     * In that case, we don't want to reset the lineno or column.     */    if (b != YY_CURRENT_BUFFER){        b->yy_bs_lineno = 1;        b->yy_bs_column = 0;    }	b->yy_is_interactive = 0;	errno = oerrno;}/** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. *  */    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(  );}/** Pushes the new state onto the stack. The new state becomes *  the current state. This function will allocate the stack *  if necessary. *  @param new_buffer The new state. *   */void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer){    	if (new_buffer == NULL)		return;	yyensure_buffer_stack();	/* This block is copied from yy_switch_to_buffer. */	if ( YY_CURRENT_BUFFER )		{		/* Flush out information for old buffer. */		*(yy_c_buf_p) = (yy_hold_char);		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);		}	/* Only push if top exists. Otherwise, replace top. */	if (YY_CURRENT_BUFFER)		(yy_buffer_stack_top)++;	YY_CURRENT_BUFFER_LVALUE = new_buffer;	/* copied from yy_switch_to_buffer. */	yy_load_buffer_state(  );	(yy_did_buffer_switch_on_eof) = 1;}/** Removes and deletes the top of the stack, if present. *  The next element becomes the new top. *   */void yyFlexLexer::yypop_buffer_state (void){    	if (!YY_CURRENT_BUFFER)		return;	yy_delete_buffer(YY_CURRENT_BUFFER );	YY_CURRENT_BUFFER_LVALUE = NULL;	if ((yy_buffer_stack_top) > 0)		--(yy_buffer_stack_top);	if (YY_CURRENT_BUFFER) {		yy_load_buffer_state(  );		(yy_did_buffer_switch_on_eof) = 1;	}}/* Allocates the stack if it does not exist. *  Guarantees space for at least one push. */void yyFlexLexer::yyensure_buffer_stack(void){	int num_to_alloc;    	if (!(yy_buffer_stack)) {		/* First allocation is just for 2 elements, since we don't know if this		 * scanner will even need a stack. We use 2 instead of 1 to avoid an		 * immediate realloc on the next call.         */		num_to_alloc = 1;		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc								(num_to_alloc * sizeof(struct yy_buffer_state*)								);				memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));						(yy_buffer_stack_max) = num_to_alloc;		(yy_buffer_stack_top) = 0;		return;	}	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){		/* Increase the buffer to prepare for a possible push. */		int grow_size = 8 /* arbitrary grow size */;		num_to_alloc = (yy_buffer_stack_max) + grow_size;		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc								((yy_buffer_stack),								num_to_alloc * sizeof(struct yy_buffer_state*)								);		/* zero only the new slots.*/		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));		(yy_buffer_stack_max) = num_to_alloc;	}}    void 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 *) yyalloc(new_size  );		else			(yy_start_stack) = (int *) yyrealloc((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);}    void 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)]);}    int yyFlexLexer::yy_top_state(){    	return (yy_start_stack)[(yy_start_stack_ptr) - 1];}#ifndef YY_EXIT_FAILURE#define YY_EXIT_FAILURE 2#endifvoid yyFlexLexer::LexerError( yyconst char msg[] ){    	std::cerr << msg << std::endl;	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. */ \        int yyless_macro_arg = (n); \        YY_LESS_LINENO(yyless_macro_arg);\		yytext[yyleng] = (yy_hold_char); \		(yy_c_buf_p) = yytext + yyless_macro_arg; \		(yy_hold_char) = *(yy_c_buf_p); \		*(yy_c_buf_p) = '\0'; \		yyleng = yyless_macro_arg; \		} \	while ( 0 )/* Accessor  methods (get/set functions) to struct members. *//* * Internal utility routines. */#ifndef yytext_ptrstatic void yy_flex_strncpy (char* s1, yyconst char * s2, int n ){	register int i;    	for ( i = 0; i < n; ++i )		s1[i] = s2[i];}#endif#ifdef YY_NEED_STRLENstatic int yy_flex_strlen (yyconst char * s ){	register int n;    	for ( n = 0; s[n]; ++n )		;	return n;}#endifvoid *yyalloc (yy_size_t  size ){	return (void *) malloc( size );}void *yyrealloc  (void * ptr, yy_size_t  size ){	/* 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 );}void yyfree (void * ptr ){	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */}#define YYTABLES_NAME "yytables"#undef YY_NEW_FILE#undef YY_FLUSH_BUFFER#undef yy_set_bol#undef yy_new_buffer#undef yy_set_interactive#undef yytext_ptr#undef YY_DO_BEFORE_ACTION#ifdef YY_DECL_IS_OURS#undef YY_DECL_IS_OURS#undef YY_DECL#endif#line 39 "cmdlex.l"#undef lexer_objintyywrap(void){  return(1);}#include "cmdlexcl.h"#include "globals.h"intcl_ucsim_lexer::LexerInput(char *buf, int max_size){  if (!string_to_parse)    return(yyFlexLexer::LexerInput(buf, max_size));  int lrem= strlen(string_ptr);  int n= max_size;  if (lrem < max_size)    n= lrem;  strncpy(buf, string_ptr, n);  string_ptr+= n;  return(n);}voidcl_ucsim_lexer::activate_lexer_to_parse_into(void *yylv){  yylval= (YY_cl_ucsim_parser_STYPE *)yylv;}intcl_ucsim_lexer::check_id(char *token){  class cl_uc *uc= application->get_uc();  //printf("checking id=\"%s\"\n",token);  if (uc)    {      class cl_memory *mem= uc->memory(token);      if (mem)	{	  yylval->memory_object= mem;	  return(tok(PTOK_MEMORY_OBJECT));	}            t_addr addr;      bool found= uc->symbol2address(yytext, uc->sfr_tbl(), &addr);      if (found)	{	  /*yylval->number= addr;	    return(tok(PTOK_NUMBER));*/	  yylval->memory.memory= uc->address_space(MEM_SFR_ID);	  yylval->memory.address= addr;	  return(tok(PTOK_MEMORY));	}      found= uc->symbol2address(yytext, uc->bit_tbl(), &addr);      if (found)	{	  t_addr memaddr;	  t_mem mask;	  yylval->bit.memory= uc->bit2mem(addr, &memaddr, &mask);	  yylval->bit.mem_address= memaddr;	  yylval->bit.bit_address= addr;	  yylval->bit.mask= mask;	  return(tok(PTOK_BIT));	}    }  return(0);}

⌨️ 快捷键说明

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