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

📄 test.c

📁 一个使用Lex编写的C语言词法加亮的小程序。能将指定的C源程序进行词法加亮
💻 C
📖 第 1 页 / 共 4 页
字号:
	*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;
	do
	    {
	    register unsigned char   yy_c = yy_ec[*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 = yy_def[yy_current_state];
		if ( yy_current_state >= 494 )
		    yy_c = yy_meta[yy_c];
		}
	    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
	    ++yy_cp;
	    }
	while ( yy_current_state != 493 );
	yy_cp = yy_last_accepting_cpos;
	yy_current_state = yy_last_accepting_state;

	/* bogus while loop to let YY_BACK_TRACK, EOB_ACT_LAST_MATCH,
	 * and EOF actions branch here without introducing an optimizer-
	 * daunting goto
	 */
	while ( 1 )
	    {
	    yy_act = yy_accept[yy_current_state];

	    YY_DO_BEFORE_ACTION;
	    YY_USER_ACTION;

#ifdef FLEX_DEBUG
	    fprintf( stderr, "--accepting rule #%d (\"%s\")\n",
		     yy_act, yytext );
#endif

do_action:	/* this label is used only to access EOF actions */
	    switch ( yy_act )
		{
		case 0: /* must backtrack */
		/* 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;
		continue; /* go to "YY_DO_BEFORE_ACTION" */

case 1:
# line 70 "cscanner.txt"
{ECHO; BEGIN 0; BEGIN C_COMMENT; fprintf(outfp,"<font color=%s>/*",colors[COMMENT]);; colnum+=yyleng;}
	YY_BREAK
case 2:
# line 72 "cscanner.txt"
case 3:
# line 72 "cscanner.txt"
{ECHO; OutPutHTMLEncodeStr();}
	YY_BREAK
case 4:
# line 73 "cscanner.txt"
{ECHO; BEGIN 0; fprintf(outfp,"*/</font>\n"); colnum+=yyleng;}
	YY_BREAK
                 /*识别关键字*/
case 5:
# line 78 "cscanner.txt"
case 6:
# line 79 "cscanner.txt"
case 7:
# line 80 "cscanner.txt"
case 8:
# line 81 "cscanner.txt"
case 9:
# line 82 "cscanner.txt"
case 10:
# line 83 "cscanner.txt"
case 11:
# line 84 "cscanner.txt"
case 12:
# line 85 "cscanner.txt"
case 13:
# line 86 "cscanner.txt"
case 14:
# line 87 "cscanner.txt"
case 15:
# line 88 "cscanner.txt"
case 16:
# line 89 "cscanner.txt"
case 17:
# line 90 "cscanner.txt"
case 18:
# line 91 "cscanner.txt"
case 19:
# line 92 "cscanner.txt"
case 20:
# line 93 "cscanner.txt"
case 21:
# line 94 "cscanner.txt"
case 22:
# line 95 "cscanner.txt"
case 23:
# line 96 "cscanner.txt"
case 24:
# line 97 "cscanner.txt"
case 25:
# line 98 "cscanner.txt"
case 26:
# line 99 "cscanner.txt"
case 27:
# line 100 "cscanner.txt"
case 28:
# line 101 "cscanner.txt"
case 29:
# line 102 "cscanner.txt"
case 30:
# line 103 "cscanner.txt"
case 31:
# line 104 "cscanner.txt"
case 32:
# line 105 "cscanner.txt"
case 33:
# line 105 "cscanner.txt"
{ECHO; OutPut(KEY);}
	YY_BREAK
                            /*识别预处理*/
case 34:
# line 108 "cscanner.txt"
{
                            ECHO; BEGIN C_INCLUDE; 
							OutPut(DEFINE);
							}
	YY_BREAK
case 35:
# line 112 "cscanner.txt"
{ECHO; OutPut(FILENAME);}
	YY_BREAK
case 36:
# line 113 "cscanner.txt"
{ECHO; BEGIN 0; OutPutHTMLEncodeStr();}
	YY_BREAK
case 37:
# line 116 "cscanner.txt"
case 38:
# line 117 "cscanner.txt"
case 39:
# line 118 "cscanner.txt"
case 40:
# line 118 "cscanner.txt"
{ECHO; OutPut(DEFINE);}
	YY_BREAK
                 /*识别标识符*/
case 41:
# line 121 "cscanner.txt"
{ECHO; OutPut(IDEN);}
	YY_BREAK
                 /*识别字符串*/
case 42:
# line 124 "cscanner.txt"
{ECHO; OutPut(STRING);}
	YY_BREAK
                          /*识别数字*/
case 43:
# line 129 "cscanner.txt"
case 44:
# line 130 "cscanner.txt"
case 45:
# line 131 "cscanner.txt"
case 46:
# line 132 "cscanner.txt"
case 47:
# line 133 "cscanner.txt"
case 48:
# line 134 "cscanner.txt"
case 49:
# line 135 "cscanner.txt"
case 50:
# line 135 "cscanner.txt"
{ECHO; OutPut(NUMBER);}
	YY_BREAK
case 51:
# line 138 "cscanner.txt"
case 52:
# line 139 "cscanner.txt"
case 53:
# line 140 "cscanner.txt"
case 54:
# line 141 "cscanner.txt"
case 55:
# line 142 "cscanner.txt"
case 56:
# line 143 "cscanner.txt"
case 57:
# line 144 "cscanner.txt"
case 58:
# line 145 "cscanner.txt"
case 59:
# line 147 "cscanner.txt"
case 60:
# line 148 "cscanner.txt"
case 61:
# line 149 "cscanner.txt"
case 62:
# line 150 "cscanner.txt"
case 63:
# line 152 "cscanner.txt"
case 64:
# line 153 "cscanner.txt"
case 65:
# line 155 "cscanner.txt"
case 66:
# line 156 "cscanner.txt"
case 67:
# line 157 "cscanner.txt"
case 68:
# line 158 "cscanner.txt"
case 69:
# line 160 "cscanner.txt"
case 70:
# line 161 "cscanner.txt"
case 71:
# line 162 "cscanner.txt"
case 72:
# line 164 "cscanner.txt"
case 73:
# line 165 "cscanner.txt"
case 74:
# line 166 "cscanner.txt"
case 75:
# line 167 "cscanner.txt"
case 76:
# line 168 "cscanner.txt"
case 77:
# line 169 "cscanner.txt"
case 78:
# line 171 "cscanner.txt"
case 79:
# line 172 "cscanner.txt"
case 80:
# line 173 "cscanner.txt"
case 81:
# line 173 "cscanner.txt"
{ECHO; OutPut(OP);}
	YY_BREAK
case 82:
# line 177 "cscanner.txt"
case 83:
# line 178 "cscanner.txt"
case 84:
# line 178 "cscanner.txt"
{ECHO; OutPutHTMLEncodeStr();}
	YY_BREAK
case 85:
# line 180 "cscanner.txt"
{ECHO; OutPut(ERRORCHAR);}
	YY_BREAK
case 86:
# line 182 "cscanner.txt"
ECHO;
	YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(C_COMMENT):
case YY_STATE_EOF(C_INCLUDE):
    yyterminate();

		case YY_END_OF_BUFFER:
		    /* undo the effects of YY_DO_BEFORE_ACTION */
		    *yy_cp = yy_hold_char;

		    yytext = yy_bp;

		    switch ( yy_get_next_buffer() )
			{
			case EOB_ACT_END_OF_FILE:
			    {
			    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;

				yy_act = YY_STATE_EOF((yy_start - 1) / 2);
				goto do_action;
				}

			    else
				YY_NEW_FILE;
			    }
			    break;

			case EOB_ACT_RESTART_SCAN:
			    yy_c_buf_p = yytext;
			    yy_hold_char = *yy_c_buf_p;
			    break;

			case EOB_ACT_LAST_MATCH:
			    yy_c_buf_p = &yy_ch_buf[yy_n_chars];

			    yy_current_state = yy_get_previous_state();

			    yy_cp = yy_c_buf_p;
			    yy_bp = yytext;
			    continue; /* go to "YY_DO_BEFORE_ACTION" */
			}
		    break;

		default:
		    printf( "action # %d\n", yy_act );
		    YY_FATAL_ERROR( "fatal flex scanner internal error" );
		}

	    break; /* exit bogus while loop */
	    }
	}
    }


/* yy_get_next_buffer - try to read in new buffer
 *
 * synopsis
 *     int yy_get_next_buffer();
 *
 * returns a code representing an action
 *     EOB_ACT_LAST_MATCH -
 *     EOB_ACT_RESTART_SCAN - restart the scanner
 *     EOB_ACT_END_OF_FILE - end of file
 */

static int yy_get_next_buffer()

    {
	register unsigned char  *dest = yy_ch_buf;
	register unsigned char  *source = yytext - 1; /* copy prev. char, too */
    register int number_to_move, i;
    int ret_val;

    if ( yy_c_buf_p != &yy_ch_buf[yy_n_chars + 1] )
	{
	YY_FATAL_ERROR( "NULL in input" );
	/*NOTREACHED*/
	}

    /* try to read more data */

⌨️ 快捷键说明

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