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

📄 test.c

📁 一个使用Lex编写的C语言词法加亮的小程序。能将指定的C源程序进行词法加亮
💻 C
📖 第 1 页 / 共 4 页
字号:
#define ECHO fputs(yytext,yyout)
#define FLEX_COMPRESSED
/* A lexical scanner generated by flex */

/* scanner skeleton version:
 * $Header: flex.skel,v 2.0 89/06/20 15:49:46 vern Locked $
 */

#include <stdio.h>

#define FLEX_SCANNER

/* amount of stuff to slurp up with each read */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif

#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of input buffer */
#endif

/* returned upon end-of-file */
#define YY_END_TOK 0

/* copy whatever the last rule matched to the standard output */

#define ECHO fputs( yytext, yyout )

/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#define YY_INPUT(buf,result,max_size) \
	if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
	    YY_FATAL_ERROR( "read() in flex scanner failed" );
#define YY_NULL 0
#define yyterminate() return ( YY_NULL )

/* report a fatal error */
#define YY_FATAL_ERROR(msg) \
	{ \
	fputs( msg, stderr ); \
	putc( '\n', stderr ); \
	exit( 1 ); \
	}

/* default yywrap function - always treat EOF as an EOF */
#define yywrap() 1

/* enter a start condition.  This macro really ought to take a parameter,
 * but we do it the disgusting crufty way forced on us by the ()-less
 * definition of BEGIN
 */
#define BEGIN yy_start = 1 + 2 *

/* action number for EOF rule of a given start state */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)

/* special action meaning "start processing a new file" */
#define YY_NEW_FILE goto new_file

/* default declaration of generated scanner - a define so the user can
 * easily add parameters
 */
#define YY_DECL int yylex( void )

/* code executed at the end of each rule */
#define YY_BREAK break;

#define YY_END_OF_BUFFER_CHAR 0

/* done after the current pattern has been matched and before the
 * corresponding action - sets up yytext
 */
#define YY_DO_BEFORE_ACTION \
	yytext = yy_bp; \
	yy_hold_char = *yy_cp; \
	*yy_cp = '\0'; \
	yy_c_buf_p = yy_cp;

/* returns the length of the matched text */
#define yyleng (yy_cp - yy_bp)

#define EOB_ACT_RESTART_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2

/* return all but the first 'n' matched characters back to the input stream */
#define yyless(n) \
	{ \
	*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
	yy_c_buf_p = yy_cp = yy_bp + n; \
	YY_DO_BEFORE_ACTION; /* set up yytext again */ \
	}

#define unput(c) yyunput( c, yy_bp )

#define YY_USER_ACTION

FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
unsigned char  *yytext;

# line 1 "cscanner.txt"
#define INITIAL 0
/*C语言语法着色器*/
/*作者:RockCarry*/
/*定义部分*/
# line 6 "cscanner.txt"
/*文件包含*/
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*常量定义*/
#define KEY       0  /*关键字*/
#define IDEN      1  /*标识符*/
#define NUMBER    2  /*数字*/
#define STRING    3  /*字符串*/
#define DEFINE    4  /*预处理*/
#define COMMENT   5  /*注释*/
#define OP        6  /*运算符*/
#define ERRORCHAR 7  /*其他符号*/
#define FILENAME  8  /*文件名*/
#define COLOR_NUM 9  /*颜色数*/

/*全局变量定义*/
int   rownum        = 0;    /*当前行号*/
int   colnum        = 0;    /*当前列号*/
int   tabsize       = 4;    /*Tab键大小*/

FILE *outfp         = NULL;
char configfile[30];
char outputfile[30];
char inputfile[30];

/*颜色数组*/
char  colors[COLOR_NUM][10] =
{
    "#0000ff",    /* KEY       */
    "#000000",    /* IDEN      */
    "#ee0000",    /* NUMBER    */
    "#057595",    /* STRING    */
    "#a0009e",    /* DEFINE    */
    "#009900",    /* COMMENT   */
    "#000000",    /* OP        */
    "#000000",    /* ERRORCHAR */
	"#000000"     /* FILENAME  */
};

/*函数声明*/
int  OutPut(int type);
void OutPutHTMLEncodeStr();
void ReadCommand(int argc,char *argv[]);
void LoadColorConfig(char *file);
/*以下是宏定义*/
#define C_COMMENT 1
#define C_INCLUDE 2
# line 67 "cscanner.txt"
#define YY_END_OF_BUFFER 87
typedef int yy_state_type;
static const short int yy_accept[494] =
    {   0,
        0,    0,    2,    2,    0,    0,   87,   85,   83,   82,
       84,   69,   85,   85,   56,   65,   85,   59,   60,   54,
       52,   79,   53,   64,   55,   47,   49,   80,   81,   72,
       51,   76,   78,   41,   61,   62,   68,   41,   41,   41,
       41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
       41,   41,   66,   67,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    3,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,

        2,   36,   85,   72,   77,    0,   42,    0,    0,    0,
        0,    0,   70,    0,    0,   57,   58,   63,   50,    1,
       50,   47,    0,   47,    0,   49,    0,   50,   49,   73,
       74,   75,   41,   41,   41,   41,   41,   41,   41,   12,
       41,   41,   41,   41,   41,   19,   41,   41,   41,   41,
       41,   41,   41,   41,   41,   41,   41,   71,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        4,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,

        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    0,    0,    0,   42,    0,    0,    0,
        0,    0,   43,    0,   43,    0,    0,   50,   48,    0,
       50,   41,   41,   41,   41,   41,   41,   41,   41,   41,
       41,   17,   41,   20,   41,   41,   41,   41,   41,   41,
       41,   41,   41,   41,   41,   41,   41,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    0,

        0,    0,    0,    0,    0,    0,   44,   44,    0,    0,
       48,   48,    5,   41,    7,    8,   41,   41,   41,   41,
       14,   41,   41,   18,   21,   41,   41,   41,   41,   41,
       41,   41,   41,   41,   41,   32,   41,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    0,    0,    0,    0,    0,    0,    0,
       45,    0,   46,    0,    6,    9,   41,   41,   41,   41,
       16,   41,   41,   24,   41,   41,   41,   41,   41,   30,

       41,   33,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,    2,   35,
       35,   35,    0,   40,   38,    0,    0,    0,   41,   41,
       13,   15,   41,   23,   25,   26,   27,   28,   41,   41,
        2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
        2,    2,    2,    2,    2,    2,    2,    2,   37,   39,
        0,   41,   11,   41,   29,   41,    2,    2,    2,    2,
        2,    2,    2,    2,   34,   10,   22,   31,    2,    2,
        2,    2,    0

    } ;

static const unsigned char   yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    4,    5,    6,    7,    1,    8,    9,   10,   11,
       12,   13,   14,   15,   16,   17,   18,   19,   20,   20,
       20,   20,   20,   20,   20,   21,   21,   22,   23,   24,
       25,   26,   27,    1,   28,   28,   28,   28,   29,   30,
       28,   28,   28,   28,   28,   31,   28,   28,   28,   28,
       28,   28,   28,   28,   31,   28,   28,   32,   28,   28,
       33,   34,   35,   36,   28,   37,   38,   39,   40,   41,

       42,   43,   44,   45,   46,   47,   48,   49,   47,   50,
       51,   52,   47,   53,   54,   55,   56,   57,   58,   59,
       60,   61,    1,   62,    1,   63,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1
    } ;

static const char yy_meta[64] =
    {   0,
        1,    1,    2,    1,    1,    1,    1,    1,    1,    3,
        1,    1,    4,    1,    1,    1,    1,    1,    5,    5,
        5,    1,    1,    1,    6,    1,    1,    7,    7,    7,
        7,    7,    8,    8,    8,    8,    8,    7,    7,    7,
        7,    7,    7,    9,    9,    9,    9,    9,    9,    9,
        9,    9,    9,    9,    9,    9,    9,    9,    9,    9,
        9,    1,    1
    } ;

static const short int yy_base[510] =
    {   0,
        0,    0,   63,    0,  124,  125,  991,  992,  992,  992,
      992,  965,  123,  130,  992,  980,  954,  992,  992,  992,
      973,  992,  117,  116,  973,  121,  164,  992,  992,  960,
      959,  958,  992,    0,  992,  992,  992,  926,  928,  109,
      104,  102,  107,  929,  116,  928,  936,  133,  917,  926,
      924,  929,  911,  992,    0,    0,    0,    0,  947,  156,
      163,    0,  962,  183,    0,    0,  952,  955,    0,  147,
      178,  955,  191,  234,    0,    0,  942,  941,  940,    0,
      290,    0,    0,    0,  908,  910,  176,  150,  115,  138,
      911,  125,  910,  918,  170,  899,  908,  906,  911,  893,

        0,  992,  348,  929,  992,  196,  992,  197,  232,  911,
      902,  176,  992,  941,  225,  992,  992,  992,  239,  992,
      341,  393,  222,  992,    0,    0,  353,  992,  992,  992,
      992,  992,    0,  895,  907,  894,  909,  896,  902,  888,
      889,  887,  890,  887,  884,    0,  883,  887,   95,  885,
      874,  180,  888,  881,  178,  886,  885,  992,    0,    0,
      351,    0,  412,  415,  888,  879,  206,    0,  918,  413,
      992,    0,    0,    0,  401,  408,  443,  268,    0,  481,
      508,  420,    0,    0,    0,    0,    0,    0,  872,  884,
      871,  886,  873,  879,  865,  866,  864,  867,  864,  861,

        0,  860,  864,  193,  862,  851,  208,  865,  858,  216,
      863,  862,    0,  890,  250,  232,  246,  449,  863,  864,
      315,  864,  992,  893,  892,  448,  891,  461,  417,  450,
      465,  849,  861,  856,  844,   90,  858,  856,  852,  851,
      854,    0,  840,    0,  846,  843,  832,  834,  844,  830,
      828,  828,  840,  830,  834,  838,  829,  441,  492,  527,
      834,  835,  318,  835,    0,  864,  863,  468,  555,  524,
      500,  515,  539,  821,  833,  828,  816,  217,  830,  828,
      824,  823,  826,    0,  812,    0,  818,  815,  804,  806,
      816,  802,  800,  800,  812,  802,  806,  810,  801,  571,

        0,  803,  802,  805,  805,  796,  992,  992,  487,  834,
      521,  992,    0,  795,    0,    0,  787,  795,  784,  790,
        0,  785,  782,    0,    0,  782,  782,  779,  782,  786,
      791,  790,  788,  778,  783,    0,  784,  779,  778,  781,
      781,  772,    0,    0,  522,  623,  524,    0,    0,  772,
        0,    0,  764,  772,  761,  767,    0,  762,  759,    0,
        0,  759,  759,  756,  759,  763,  768,  767,  763,  752,
      754,    0,  754,  349,  453,  743,  746,  744,  723,  700,
      992,  734,  992,  708,    0,    0,  663,  662,  660,  625,
        0,  619,  623,    0,  629,  631,  615,  605,  607,    0,

      598,    0,  597,  603,  602,  599,  584,    0,  629,    0,
      648,    0,    0,  588,  588,  594,  585,    0,  579,  558,
        0,  564,  566,  550,  559,  539,    0,  529,    0,  992,
      459,  992,  536,  992,  992,  529,  530,  558,  507,  507,
        0,    0,  506,    0,    0,    0,    0,    0,  504,  504,
      454,    0,    0,  451,  448,  467,  420,  398,    0,    0,
      393,    0,    0,    0,    0,    0,  368,  339,  992,  992,
      324,  321,    0,  305,    0,  262,    0,    0,  244,  237,
        0,  176,    0,  141,  992,    0,    0,    0,    0,    0,
        0,    0,  992,  691,  700,  705,  714,  723,  732,  736,

      745,  754,  759,  767,  776,  783,  785,  792,  798
    } ;

static const short int yy_def[510] =
    {   0,
      493,    1,  493,    3,    1,    1,  493,  493,  493,  493,
      493,  493,  494,  493,  493,  493,  495,  493,  493,  493,
      493,  493,  493,  493,  493,  493,  493,  493,  493,  493,
      493,  493,  493,  496,  493,  493,  493,  496,  496,  496,
      496,  496,  496,  496,  496,  496,  496,  496,  496,  496,
      496,  496,  493,  493,  497,  497,  497,  497,  497,  498,
      497,  497,  497,  499,  497,  497,  493,  497,  497,  497,
      497,  497,  497,  497,  497,  497,  497,  497,  497,  497,
      493,  497,  497,  497,   81,   81,   81,   81,   81,   81,
       81,   81,   81,   81,   81,   81,   81,   81,   81,  497,

      497,  493,  494,  500,  493,  494,  493,  501,  493,  493,
      493,  493,  493,  493,  502,  493,  493,  493,  493,  493,
      493,  493,  493,  493,  503,   27,  493,  493,  493,  493,
      493,  493,  496,  496,  496,  496,  496,  496,  496,  496,
      496,  496,  496,  496,  496,  496,  496,  496,  496,  496,
      496,  496,  496,  496,  496,  496,  496,  493,  497,  497,
      498,  497,  504,  497,  497,  497,  497,  497,  497,  505,
      493,  497,  497,  497,  497,  497,  497,  497,  497,  497,
      497,  497,  497,  497,  497,  497,  497,   81,   81,   81,
       81,   81,   81,   81,   81,   81,   81,   81,   81,   81,

       81,   81,   81,   81,   81,   81,   81,   81,   81,   81,
       81,   81,  497,  103,  500,  494,  494,  501,  493,  493,
      493,  493,  493,  493,  493,  493,  506,  493,  503,  493,
      493,  496,  496,  496,  496,  496,  496,  496,  496,  496,
      496,  496,  496,  496,  496,  496,  496,  496,  496,  496,
      496,  496,  496,  496,  496,  496,  496,  498,  498,  504,
      497,  497,  497,  497,  497,  497,  497,  497,  497,  497,
      180,  497,  497,   81,   81,   81,   81,   81,   81,   81,
       81,   81,   81,   81,   81,   81,   81,   81,   81,   81,

⌨️ 快捷键说明

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