lex.yy.c

来自「TCP-IP红宝书源代码」· C语言 代码 · 共 1,411 行 · 第 1/3 页

C
1,411
字号
	register yy_state_type yy_current_state;
	register char *yy_cp, *yy_bp;
	register int yy_act;

# line 4 "config.l"


	if ( yy_init )
		{
#ifdef YY_USER_INIT
		YY_USER_INIT;
#endif

		if ( ! yy_start )
			yy_start = 1;	/* first start state */

		if ( ! yyin )
			yyin = stdin;

		if ( ! yyout )
			yyout = stdout;

		if ( yy_current_buffer )
			yy_init_buffer( yy_current_buffer, yyin );
		else
			yy_current_buffer =
				yy_create_buffer( yyin, YY_BUF_SIZE );

		yy_load_buffer_state();

		yy_init = 0;
		}

	while ( 1 )		/* loops until end-of-file is reached */
		{
		yy_cp = yy_c_buf_p;

		/* Support of yytext. */
		*yy_cp = yy_hold_char;

		/* yy_bp points to the position in yy_ch_buf of the start of
		 * the current run.
		 */
		yy_bp = yy_cp;

		yy_current_state = yy_start;
yy_match:
		do
			{
			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
			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 >= 77 )
					yy_c = yy_meta[(unsigned int) yy_c];
				}
			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
			++yy_cp;
			}
		while ( yy_base[yy_current_state] != 91 );

yy_find_action:
		yy_act = yy_accept[yy_current_state];

		YY_DO_BEFORE_ACTION;


do_action:	/* This label is used only to access EOF actions. */


		switch ( yy_act )
	{ /* beginning of action switch */
			case 0: /* must back up */
			/* undo the effects of YY_DO_BEFORE_ACTION */
			*yy_cp = yy_hold_char;
			yy_cp = yy_last_accepting_cpos;
			yy_current_state = yy_last_accepting_state;
			goto yy_find_action;

case 1:
YY_USER_ACTION
# line 5 "config.l"
{skipping = 1;}
	YY_BREAK
case 2:
YY_USER_ACTION
# line 6 "config.l"
{skipping = 0;}
	YY_BREAK
case 3:
YY_USER_ACTION
# line 7 "config.l"
{extern	int	brkcount;
			 if (! skipping)
				if (++brkcount == 2)
					return 0; /* end-of-file */
				else
					return DEFBRK;
			}
	YY_BREAK
case 4:
YY_USER_ACTION
# line 14 "config.l"
{if (! skipping) return COLON;}
	YY_BREAK
case 5:
YY_USER_ACTION
# line 15 "config.l"
{if (! skipping) return INTEGER;}
	YY_BREAK
case 6:
YY_USER_ACTION
# line 16 "config.l"
{if (! skipping) return INTEGER;}
	YY_BREAK
case 7:
YY_USER_ACTION
# line 17 "config.l"
{if (! skipping) return INTEGER;}
	YY_BREAK
case 8:
YY_USER_ACTION
# line 18 "config.l"
{if (! skipping) return IS;}
	YY_BREAK
case 9:
YY_USER_ACTION
# line 19 "config.l"
{if (! skipping) return ON;}
	YY_BREAK
case 10:
YY_USER_ACTION
# line 20 "config.l"
;
	YY_BREAK
case 11:
YY_USER_ACTION
# line 21 "config.l"
{if (! skipping) return IINT;}
	YY_BREAK
case 12:
YY_USER_ACTION
# line 22 "config.l"
{if (! skipping) return OINT;}
	YY_BREAK
case 13:
YY_USER_ACTION
# line 23 "config.l"
{if (! skipping) return CSR;}
	YY_BREAK
case 14:
YY_USER_ACTION
# line 24 "config.l"
{if (! skipping) return IVEC;}
	YY_BREAK
case 15:
YY_USER_ACTION
# line 25 "config.l"
{if (! skipping) return IRQ;}
	YY_BREAK
case 16:
YY_USER_ACTION
# line 26 "config.l"
{if (! skipping) return OVEC;}
	YY_BREAK
case 17:
YY_USER_ACTION
# line 27 "config.l"
{if (! skipping) return INIT;}
	YY_BREAK
case 18:
YY_USER_ACTION
# line 28 "config.l"
{if (! skipping) return OPEN;}
	YY_BREAK
case 19:
YY_USER_ACTION
# line 29 "config.l"
{if (! skipping) return CLOSE;}
	YY_BREAK
case 20:
YY_USER_ACTION
# line 30 "config.l"
{if (! skipping) return READ;}
	YY_BREAK
case 21:
YY_USER_ACTION
# line 31 "config.l"
{if (! skipping) return GETC;}
	YY_BREAK
case 22:
YY_USER_ACTION
# line 32 "config.l"
{if (! skipping) return PUTC;}
	YY_BREAK
case 23:
YY_USER_ACTION
# line 33 "config.l"
{if (! skipping) return WRITE;}
	YY_BREAK
case 24:
YY_USER_ACTION
# line 34 "config.l"
{if (! skipping) return SEEK;}
	YY_BREAK
case 25:
YY_USER_ACTION
# line 35 "config.l"
{if (! skipping) return CNTL;}
	YY_BREAK
case 26:
YY_USER_ACTION
# line 36 "config.l"
;
	YY_BREAK
case 27:
YY_USER_ACTION
# line 37 "config.l"
{extern int linectr;
			 linectr++;
			}
	YY_BREAK
case 28:
YY_USER_ACTION
# line 40 "config.l"
{if (! skipping) return IDENT;}
	YY_BREAK
case 29:
YY_USER_ACTION
# line 41 "config.l"
{if (! skipping) return yytext[0];}
	YY_BREAK
case 30:
YY_USER_ACTION
# line 42 "config.l"
ECHO;
	YY_BREAK
case YY_STATE_EOF(INITIAL):
	yyterminate();

	case YY_END_OF_BUFFER:
		{
		/* Amount of text matched not including the EOB char. */
		int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1;

		/* Undo the effects of YY_DO_BEFORE_ACTION. */
		*yy_cp = yy_hold_char;

		if ( yy_current_buffer->yy_input_file != yyin )
			{
			/* This can happen if we scan a file, yywrap() returns
			 * 1, and then later the user points yyin at a new
			 * file to resume scanning.  We have to assure
			 * consistency between yy_current_buffer and our
			 * globals.  Here is the right place to do so, because
			 * this is the first action (other than possibly a
			 * back-up) that will match for the new input file.
			 */
			yy_current_buffer->yy_input_file = yyin;
			yy_n_chars = yy_current_buffer->yy_n_chars;
			}

		/* Note that here we test for yy_c_buf_p "<=" to the position
		 * of the first EOB in the buffer, since yy_c_buf_p will
		 * already have been incremented past the NUL character
		 * (since all states make transitions on EOB to the
		 * end-of-buffer state).  Contrast this with the test
		 * in input().
		 */
		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
			{ /* This was really a NUL. */
			yy_state_type yy_next_state;

			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;

			yy_current_state = yy_get_previous_state();

			/* Okay, we're now positioned to make the NUL
			 * transition.  We couldn't have
			 * yy_get_previous_state() go ahead and do it
			 * for us because it doesn't know how to deal
			 * with the possibility of jamming (and we don't
			 * want to build jamming into it because then it
			 * will run more slowly).
			 */

			yy_next_state = yy_try_NUL_trans( yy_current_state );

			yy_bp = yytext_ptr + YY_MORE_ADJ;

			if ( yy_next_state )
				{
				/* Consume the NUL. */
				yy_cp = ++yy_c_buf_p;
				yy_current_state = yy_next_state;
				goto yy_match;
				}

			else
				{
				goto yy_find_action;
				}
			}

		else switch ( yy_get_next_buffer() )
			{
			case EOB_ACT_END_OF_FILE:
				{
				yy_did_buffer_switch_on_eof = 0;

				if ( yywrap() )
					{
					/* Note: because we've taken care in
					 * yy_get_next_buffer() to have set up
					 * yytext, we can now set up
					 * yy_c_buf_p so that if some total
					 * hoser (like flex itself) wants to
					 * call the scanner after we return the
					 * YY_NULL, it'll still work - another
					 * YY_NULL will get returned.
					 */
					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;

					yy_act = YY_STATE_EOF(YY_START);
					goto do_action;
					}

				else
					{
					if ( ! yy_did_buffer_switch_on_eof )
						YY_NEW_FILE;
					}
				break;
				}

			case EOB_ACT_CONTINUE_SCAN:
				yy_c_buf_p =
					yytext_ptr + yy_amount_of_matched_text;

				yy_current_state = yy_get_previous_state();

				yy_cp = yy_c_buf_p;
				yy_bp = yytext_ptr + YY_MORE_ADJ;
				goto yy_match;

			case EOB_ACT_LAST_MATCH:
				yy_c_buf_p =
				&yy_current_buffer->yy_ch_buf[yy_n_chars];

				yy_current_state = yy_get_previous_state();

				yy_cp = yy_c_buf_p;
				yy_bp = yytext_ptr + YY_MORE_ADJ;
				goto yy_find_action;
			}
		break;
		}

	default:
		YY_FATAL_ERROR(
			"fatal flex scanner internal error--no action found" );
	} /* end of action switch */
		} /* end of scanning one token */
	} /* end of yylex */


/* yy_get_next_buffer - try to read in a new buffer
 *
 * Returns a code representing an action:
 *	EOB_ACT_LAST_MATCH -
 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 *	EOB_ACT_END_OF_FILE - end of file
 */

static int yy_get_next_buffer()
	{
	register char *dest = yy_current_buffer->yy_ch_buf;
	register char *source = yytext_ptr - 1; /* copy prev. char, too */
	register int number_to_move, i;
	int ret_val;

	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
		YY_FATAL_ERROR(
		"fatal flex scanner internal error--end of buffer missed" );

	if ( yy_current_buffer->yy_fill_buffer == 0 )
		{ /* Don't try to fill the buffer, so this is an EOF. */
		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
			{
			/* We matched a singled characater, the EOB, so
			 * treat this as a final EOF.
			 */
			return EOB_ACT_END_OF_FILE;
			}

		else
			{
			/* We matched some text prior to the EOB, first
			 * process it.
			 */
			return EOB_ACT_LAST_MATCH;
			}
		}

	/* Try to read more data. */

	/* First move last chars to start of buffer. */
	number_to_move = yy_c_buf_p - yytext_ptr;

	for ( i = 0; i < number_to_move; ++i )
		*(dest++) = *(source++);

	if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
		/* don't do the read, it's not guaranteed to return an EOF,
		 * just force an EOF
		 */
		yy_n_chars = 0;

	else
		{
		int num_to_read =
			yy_current_buffer->yy_buf_size - number_to_move - 1;

		while ( num_to_read <= 0 )
			{ /* Not enough room in the buffer - grow it. */
#ifdef YY_USES_REJECT
			YY_FATAL_ERROR(
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
#else

			/* just a shorter name for the current buffer */
			YY_BUFFER_STATE b = yy_current_buffer;

			int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf;

			b->yy_buf_size *= 2;
			b->yy_ch_buf = (char *)
				yy_flex_realloc( (void *) b->yy_ch_buf,
						 b->yy_buf_size );

			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 );
		}

	if ( yy_n_chars == 0 )
		{
		if ( number_to_move - YY_MORE_ADJ == 1 )
			{
			ret_val = EOB_ACT_END_OF_FILE;
			yyrestart( yyin );
			}

⌨️ 快捷键说明

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