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

📄 skel.c

📁 flex编译器的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
  "#endif",
  "					}",
  "",
  "				case EOB_ACT_CONTINUE_SCAN:",
  "					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;",
  "					break;",
  "",
  "				case EOB_ACT_LAST_MATCH:",
  "#ifdef __cplusplus",
  "					YY_FATAL_ERROR(",
  "					\"unexpected last match in yyinput()\" );",
  "#else",
  "					YY_FATAL_ERROR(",
  "					\"unexpected last match in input()\" );",
  "#endif",
  "				}",
  "			}",
  "		}",
  "",
  "	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;",
  "",
  "%% update BOL and yylineno",
  "",
  "	return c;",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "void yyrestart( FILE *input_file )",
  "#else",
  "void yyrestart( input_file )",
  "FILE *input_file;",
  "#endif",
  "%+",
  "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();",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )",
  "#else",
  "void yy_switch_to_buffer( new_buffer )",
  "YY_BUFFER_STATE new_buffer;",
  "#endif",
  "%+",
  "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;",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "void yy_load_buffer_state( void )",
  "#else",
  "void yy_load_buffer_state()",
  "#endif",
  "%+",
  "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;",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )",
  "#else",
  "YY_BUFFER_STATE yy_create_buffer( file, size )",
  "FILE *file;",
  "int size;",
  "#endif",
  "%+",
  "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;",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "void yy_delete_buffer( YY_BUFFER_STATE b )",
  "#else",
  "void yy_delete_buffer( b )",
  "YY_BUFFER_STATE b;",
  "#endif",
  "%+",
  "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 );",
  "	}",
  "",
  "",
  "%-",
  "#ifndef YY_ALWAYS_INTERACTIVE",
  "#ifndef YY_NEVER_INTERACTIVE",
  "extern int isatty YY_PROTO(( int ));",
  "#endif",
  "#endif",
  "",
  "#ifdef YY_USE_PROTOS",
  "void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )",
  "#else",
  "void yy_init_buffer( b, file )",
  "YY_BUFFER_STATE b;",
  "FILE *file;",
  "#endif",
  "",
  "%+",
  "extern \"C\" int isatty YY_PROTO(( int ));",
  "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;",
  "",
  "%-",
  "#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",
  "%+",
  "	b->yy_is_interactive = 0;",
  "%*",
  "	}",
  "",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "void yy_flush_buffer( YY_BUFFER_STATE b )",
  "#else",
  "void yy_flush_buffer( b )",
  "YY_BUFFER_STATE b;",
  "#endif",
  "",
  "%+",
  "void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )",
  "%*",
  "	{",
  "	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_PROTOS",
  "YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )",
  "#else",
  "YY_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_PROTOS",
  "YY_BUFFER_STATE yy_scan_string( yyconst char *str )",
  "#else",
  "YY_BUFFER_STATE yy_scan_string( str )",
  "yyconst char *str;",
  "#endif",
  "	{",
  "	int len;",
  "	for ( len = 0; str[len]; ++len )",
  "		;",
  "",
  "	return yy_scan_bytes( str, len );",
  "	}",
  "%*",
  "#endif",
  "",
  "",
  "#ifndef YY_NO_SCAN_BYTES",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )",
  "#else",
  "YY_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 buffer, and we should throw it",
  "	 * away when we're done.",
  "	 */",
  "	b->yy_is_our_buffer = 1;",
  "",
  "	return b;",
  "	}",
  "%*",
  "#endif",
  "",
  "",
  "#ifndef YY_NO_PUSH_STATE",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "static void yy_push_state( int new_state )",
  "#else",
  "static void yy_push_state( new_state )",
  "int new_state;",
  "#endif",
  "%+",
  "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 *) 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_STATE",
  "%-",
  "static void yy_pop_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]);",
  "	}",
  "#endif",
  "",
  "",
  "#ifndef YY_NO_TOP_STATE",
  "%-",
  "static int yy_top_state()",
  "%+",
  "int yyFlexLexer::yy_top_state()",
  "%*",
  "	{",
  "	return yy_start_stack[yy_start_stack_ptr - 1];",
  "	}",
  "#endif",
  "",
  "#ifndef YY_EXIT_FAILURE",
  "#define YY_EXIT_FAILURE 2",
  "#endif",
  "",
  "%-",
  "#ifdef YY_USE_PROTOS",
  "static void yy_fatal_error( yyconst char msg[] )",
  "#else",
  "static void yy_fatal_error( msg )",
  "char msg[];",
  "#endif",
  "	{",
  "	(void) fprintf( stderr, \"%s\\n\", msg );",
  "	exit( YY_EXIT_FAILURE );",
  "	}",
  "",
  "%+",
  "",
  "void 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_MORE_ADJ; \\",
  "		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_PROTOS",
  "static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )",
  "#else",
  "static 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_USE_PROTOS",
  "static void *yy_flex_alloc( yy_size_t size )",
  "#else",
  "static void *yy_flex_alloc( size )",
  "yy_size_t size;",
  "#endif",
  "	{",
  "	return (void *) malloc( size );",
  "	}",
  "",
  "#ifdef YY_USE_PROTOS",
  "static void *yy_flex_realloc( void *ptr, yy_size_t size )",
  "#else",
  "static 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_PROTOS",
  "static void yy_flex_free( void *ptr )",
  "#else",
  "static void yy_flex_free( ptr )",
  "void *ptr;",
  "#endif",
  "	{",
  "	free( ptr );",
  "	}",
  "",
  "#if YY_MAIN",
  "int main()",
  "	{",
  "	yylex();",
  "	return 0;",
  "	}",
  "#endif",
  0
};

⌨️ 快捷键说明

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