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

📄 lexer.c

📁 这是一个非常有价值的参考代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* A lexical scanner generated by flex *//* Scanner skeleton version: * $Header: /cvs/root/flex/flex/skel.c,v 1.2 2004/05/07 00:28:17 jkh Exp $ */#define FLEX_SCANNER#define YY_FLEX_MAJOR_VERSION 2#define YY_FLEX_MINOR_VERSION 5#include <stdio.h>/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */#ifdef c_plusplus#ifndef __cplusplus#define __cplusplus#endif#endif#ifdef __cplusplus#include <stdlib.h>#include <unistd.h>/* Use prototypes in function declarations. */#define YY_USE_PROTOS/* The "const" storage-class-modifier is valid. */#define YY_USE_CONST#else	/* ! __cplusplus */#if __STDC__#define YY_USE_PROTOS#define YY_USE_CONST#endif	/* __STDC__ */#endif	/* ! __cplusplus */#ifdef __TURBOC__ #pragma warn -rch #pragma warn -use#include <io.h>#include <stdlib.h>#define YY_USE_CONST#define YY_USE_PROTOS#endif#ifdef YY_USE_CONST#define yyconst const#else#define yyconst#endif#ifdef YY_USE_PROTOS#define YY_PROTO(proto) proto#else#define YY_PROTO(proto) ()#endif/* Returned upon end-of-file. */#define YY_NULL 0/* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index.  If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)/* 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 */* Translate the current start state into a value that can be later handed * to BEGIN to return to the state.  The YYSTATE alias is for lex * compatibility. */#define YY_START ((yy_start - 1) / 2)#define YYSTATE YY_START/* 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 yyrestart( yyin )#define YY_END_OF_BUFFER_CHAR 0/* Size of default input buffer. */#define YY_BUF_SIZE 16384typedef struct yy_buffer_state *YY_BUFFER_STATE;extern int yyleng;extern FILE *yyin, *yyout;#define EOB_ACT_CONTINUE_SCAN 0#define EOB_ACT_END_OF_FILE 1#define EOB_ACT_LAST_MATCH 2/* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator).  This * avoids problems with code like: * * 	if ( condition_holds ) *		yyless( 5 ); *	else *		do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. *//* Return all but the first 'n' matched characters back to the input stream. */#define yyless(n) \	do \		{ \		/* Undo effects of setting up yytext. */ \		*yy_cp = yy_hold_char; \		YY_RESTORE_YY_MORE_OFFSET \		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \		YY_DO_BEFORE_ACTION; /* set up yytext again */ \		} \	while ( 0 )#define unput(c) yyunput( c, yytext_ptr )/* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */typedef unsigned int yy_size_t;struct yy_buffer_state	{	FILE *yy_input_file;	char *yy_ch_buf;		/* input buffer */	char *yy_buf_pos;		/* current position in input buffer */	/* Size of input buffer in bytes, not including room for EOB	 * characters.	 */	yy_size_t yy_buf_size;	/* Number of characters read into yy_ch_buf, not including EOB	 * characters.	 */	int yy_n_chars;	/* Whether we "own" the buffer - i.e., we know we created it,	 * and can realloc() it to grow it, and should free() it to	 * delete it.	 */	int yy_is_our_buffer;	/* Whether this is an "interactive" input source; if so, and	 * if we're using stdio for input, then we want to use getc()	 * instead of fread(), to make sure we stop fetching input after	 * each newline.	 */	int yy_is_interactive;	/* Whether we're considered to be at the beginning of a line.	 * If so, '^' rules will be active on the next match, otherwise	 * not.	 */	int yy_at_bol;	/* Whether to try to fill the input buffer when we reach the	 * end of it.	 */	int yy_fill_buffer;	int yy_buffer_status;#define YY_BUFFER_NEW 0#define YY_BUFFER_NORMAL 1	/* When an EOF's been seen but there's still some text to process	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we	 * shouldn't try reading from the input source any more.  We might	 * still have a bunch of tokens to match, though, because of	 * possible backing-up.	 *	 * When we actually see the EOF, we change the status to "new"	 * (via yyrestart()), so that the user can continue scanning by	 * just pointing yyin at a new input file.	 */#define YY_BUFFER_EOF_PENDING 2	};static YY_BUFFER_STATE yy_current_buffer = 0;/* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */#define YY_CURRENT_BUFFER yy_current_buffer/* yy_hold_char holds the character lost when yytext is formed. */static char yy_hold_char;static int yy_n_chars;		/* number of characters read into yy_ch_buf */int yyleng;/* Points to current character in buffer. */static char *yy_c_buf_p = (char *) 0;static int yy_init = 1;		/* whether we need to initialize */static int yy_start = 0;	/* start state number *//* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin.  A bit of a hack ... */static int yy_did_buffer_switch_on_eof;void yyrestart YY_PROTO(( FILE *input_file ));void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));void yy_load_buffer_state YY_PROTO(( void ));YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));static void *yy_flex_alloc YY_PROTO(( yy_size_t ));static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));static void yy_flex_free YY_PROTO(( void * ));#define yy_new_buffer yy_create_buffer#define yy_set_interactive(is_interactive) \	{ \	if ( ! yy_current_buffer ) \		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \	yy_current_buffer->yy_is_interactive = is_interactive; \	}#define yy_set_bol(at_bol) \	{ \	if ( ! yy_current_buffer ) \		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \	yy_current_buffer->yy_at_bol = at_bol; \	}#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)typedef unsigned char YY_CHAR;FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;typedef int yy_state_type;extern char *yytext;#define yytext_ptr yytextstatic yy_state_type yy_get_previous_state YY_PROTO(( void ));static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));static int yy_get_next_buffer YY_PROTO(( void ));static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));/* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */#define YY_DO_BEFORE_ACTION \	yytext_ptr = yy_bp; \	yyleng = (int) (yy_cp - yy_bp); \	yy_hold_char = *yy_cp; \	*yy_cp = '\0'; \	yy_c_buf_p = yy_cp;#define YY_NUM_RULES 114#define YY_END_OF_BUFFER 115static yyconst short int yy_accept[552] =    {   0,        0,    0,    0,    0,    0,    0,    0,    0,  115,  113,      111,  110,    4,    6,  113,  106,    3,  113,    1,    1,      108,  107,  113,  113,  113,  113,  113,  113,  113,  113,      113,  113,  113,  113,  113,  113,  113,  113,  113,  113,      113,  109,   17,   18,   10,  114,  114,    7,    8,  111,        0,    3,    1,    3,    9,    2,    0,    0,    0,    0,        0,    0,    0,    0,  112,    0,    0,    0,    0,    0,        0,    0,    0,   40,   89,    0,    0,    0,    0,    0,        0,  104,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,   17,   16,   14,   15,   11,   13,       12,    2,    5,    0,    0,    0,    0,    0,   25,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,   41,    0,    0,    0,    0,        0,    0,    0,    0,    0,    0,   53,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,   92,        0,    0,    0,    0,    0,    0,    0,    0,   72,    0,        0,  105,    0,    0,    0,    0,    0,   26,    0,    0,        0,    0,    0,    0,    0,   29,    0,   34,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,   46,   84,       47,    0,    0,    0,   55,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,   93,    0,    0,    0,    0,       66,    0,    0,    0,    0,    0,   71,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,   85,    0,    0,    0,    0,   38,    0,    0,    0,        0,    0,    0,    0,    0,    0,   51,   52,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,   59,        0,    0,    0,    0,   91,    0,   64,    0,   67,    0,        0,    0,    0,    0,   94,    0,   20,    0,   23,    0,        0,    0,    0,    0,    0,    0,    0,    0,   35,    0,       37,    0,    0,    0,    0,   44,    0,    0,    0,    0,        0,    0,   56,    0,    0,    0,    0,    0,    0,   90,        0,   60,    0,    0,    0,    0,    0,   65,    0,   68,        0,    0,   73,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,   96,   95,    0,    0,    0,        0,    0,    0,    0,   74,    0,    0,    0,    0,    0,        0,   24,    0,    0,    0,    0,    0,    0,    0,    0,        0,   39,   42,    0,    0,    0,    0,    0,    0,   54,        0,    0,    0,    0,    0,   81,    0,    0,    0,   87,        0,    0,    0,   69,    0,   98,   97,    0,    0,    0,       22,   86,   27,   78,    0,    0,   88,    0,    0,    0,        0,    0,    0,    0,   48,   49,   50,    0,   80,    0,       79,   82,    0,    0,    0,    0,   75,    0,    0,  101,        0,    0,  102,    0,    0,    0,    0,   33,    0,    0,        0,    0,    0,  103,   83,   57,    0,    0,    0,    0,       77,    0,    0,    0,   76,    0,    0,    0,    0,  100,       99,    0,    0,    0,   61,   62,   63,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        0,   21,    0,    0,    0,   32,    0,    0,    0,    0,       70,    0,    0,    0,    0,    0,   43,   45,    0,    0,       28,   30,    0,    0,    0,    0,    0,    0,    0,    0,       31,    0,   58,    0,    0,    0,    0,    0,   36,   19,        0    } ;static yyconst int yy_ec[256] =    {   0,        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,        1,    1,    2,    1,    1,    1,    1,    1,    1,    1,        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,        1,    2,    1,    4,    5,    1,    1,    1,    1,    1,        1,    6,    7,    8,    7,    9,   10,   11,   12,   13,       14,   14,   15,   14,   14,   14,   16,   17,   18,    1,       19,    1,    1,    1,   20,   20,   20,   20,   20,   20,        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,        1,   21,    1,    1,   22,    1,   23,   24,   25,   26,       27,   28,   29,   30,   31,   32,   33,   34,   35,   36,       37,   38,    1,   39,   40,   41,   42,   43,   44,   45,       46,   47,    1,    1,    1,   48,    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 yyconst int yy_meta[49] =    {   0,        1,    1,    2,    2,    1,    1,    3,    1,    3,    1,        4,    4,    4,    4,    4,    4,    1,    1,    1,    5,        2,    1,    5,    5,    5,    5,    5,    5,    1,    1,        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,        1,    1,    1,    1,    1,    1,    1,    1    } ;static yyconst short int yy_base[559] =    {   0,        0,    0,   46,   48,    0,    0,  625,  624,  626,  629,      623,  629,  629,  629,   46,  629,   45,  618,   55,   59,      629,  629,   20,   42,   60,  596,   53,  588,  598,   57,      579,  582,   70,   44,   73,   82,   89,   60,   90,  579,      590,  629,    0,  629,  629,   95,  629,  629,  629,  614,       78,  126,  134,  140,  629,  146,    0,  581,  575,   62,      576,  599,   38,  570,  629,  579,  583,  137,   86,  585,      568,  583,  565,  565,  629,  580,  579,  556,  565,   63,      138,  629,  564,   93,  563,  132,  142,  570,  557,  560,      548,  144,  560,  553,  544,  555,  150,  553,  553,  549,      561,  539,  553,  543,    0,  629,  629,  629,  629,  629,      629,  175,    0,  545,  565,  547,  553,  553,  629,  549,      535,  548,  536,  546,  541,  548,  547,  544,  537,  528,      527,  541,  530,  523,  540,  629,  532,  534,  537,  521,      535,  519,  528,  523,  531,  525,  103,   99,  517,  509,      523,  519,  505,  509,  507,  510,  517,  515,  502,  629,      144,  513,  514,  514,  522,  511,  508,  507,  629,  499,      491,  629,  487,  518,  154,  490,  495,  629,  500,  500,      503,  479,  498,  480,  475,  629,  495,  629,  482,  484,      490,  486,  483,  479,  475,  468,  472,  466,  629,  629,      629,  158,  171,  475,  629,  481,  480,  163,  480,  478,      465,  477,  474,  454,  473,  177,  458,  452,  473,  473,      629,  456,  468,  482,  462,  454,  629,  463,  462,  460,      476,  446,  459,  461,  443,  443,  454,  453,  452,  455,      443,  629,  449,  440,  447,  447,  629,  431,  438,  447,      430,  422,  428,  443,  442,  424,  629,  629,  429,  426,      435,  424,  432,  435,  430,  422,  432,  417,  425,  629,      426,   95,  428,  419,  629,  427,  629,  414,  629,  420,      435,  411,  402,  417,  170,  400,  419,  409,  629,  398,      407,  409,  402,  396,  408,  392,  391,  406,  629,  392,      629,  406,  397,  398,  395,  629,  394,  388,  394,  391,      394,  397,  629,  393,  377,  383,  382,  392,  379,  629,      391,  629,  381,  374,  385,  362,  370,  629,  373,  152,      369,  364,  629,  170,  381,  369,  376,  354,  373,  352,      364,  374,  373,  368,  367,  371,  355,  368,  361,  358,      361,  346,  345,  352,  357,  336,  348,  357,  353,  349,      336,  354,  330,  340,  351,  629,  629,  340,  345,  329,      347,  343,  355,  330,  629,  335,  328,  335,  329,  335,      334,  629,  333,  313,  312,  317,  322,  329,  169,  328,      324,  629,  629,  330,  324,  323,  309,  308,  320,  629,      312,  300,  307,  316,  296,  629,  314,  312,  317,  629,      304,  291,  309,  629,  297,  629,  629,  307,  295,  289,      629,  629,  629,  629,  304,  307,  629,  179,  302,  301,      300,  180,  304,  303,  629,  629,  629,  297,  629,  297,      629,  629,  283,  280,  282,  279,  629,  275,  277,  629,      293,  290,  292,  267,  273,  274,  271,  629,  271,  277,      270,  280,  279,  629,  629,  629,  277,  199,  276,  277,      629,  272,  263,  273,  629,  275,  268,  265,  256,  629,      629,  267,  266,  253,  629,  629,  629,  254,  263,  263,      261,  253,  247,  262,  247,  249,  248,  259,  254,  255,      251,  243,  242,  252,  240,  244,  249,  248,  226,  242,      237,  629,  244,  239,  230,  629,  225,  217,  216,  222,      629,  219,  213,  224,  222,  233,  629,  629,  224,  214,      629,  629,  226,  217,  210,  209,  210,  213,  210,  177,      629,  184,  629,  186,  167,  147,   99,   43,  629,  629,      629,  218,  223,  228,  231,  235,  240,  242    } ;static yyconst short int yy_def[559] =    {   0,      551,    1,  552,  552,  553,  553,  554,  554,  551,  551,

⌨️ 快捷键说明

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