flex.c

来自「很简单的编译器!不过最重要的是思想!」· C语言 代码 · 共 2,459 行 · 第 1/5 页

C
2,459
字号
      123,  138,  120,  124,  147,   64,  140,   65,  125,   71,
      151,   71,  152,   71,  148,  154,   65,   71,   71,   66,
       67,   71,  126,   71,  153,   71,  127,  155,   71,  128,
      129,   65,  157,   71,  159,  160,  130,   71,  158,  131,

       71,   71,  161,  156,   71,  163,   71,   71,   71,   71,
       71,   71,   71,   71,  166,  164,   71,   72,   71,  162,
       71,   71,   71,  165,  167,  175,  168,   71,  176,  179,
       71,  169,  172,  171,  170,   71,   71,   71,  173,  174,
      177,  178,   71,  182,  180,  181,  190,  189,  183,   71,
       71,  184,  185,  187,  201,   71,   71,   71,  196,   71,
      192,  188,  191,   71,  193,  198,  194,   71,  197,   71,
      204,   71,  195,  202,  205,   71,  203,   71,   71,   71,
       71,   71,  206,   71,  207,  199,  200,   71,  215,   71,
       71,   71,   71,  208,   71,   71,  218,  221,   71,   71,

      226,  216,   71,  219,   71,  217,   71,  209,  220,  210,
      222,  229,  223,  224,  227,  225,   71,  234,  228,  211,
      230,   71,  232,  231,   71,  212,  213,  233,  214,  235,
       71,  141,   66,  145,   71,  147,   71,  237,   71,   71,
       71,  142,  236,   71,   65,  148,   71,   71,   71,   71,
       71,  238,   71,   71,   71,   71,  245,   71,   71,   71,
       71,  248,  247,  240,  241,  239,  242,  243,  252,   71,
      244,  254,  253,  257,  256,  255,  261,   71,   71,   71,
      249,   71,  250,  258,   71,   71,  251,  260,   71,   71,
      259,   71,   71,   71,   71,  264,  265,   71,   71,   71,

       71,  267,  262,   71,   71,  268,  269,   71,   71,  263,
       71,   71,   71,  266,  272,  281,  276,  278,   71,  275,
      279,   71,   71,  305,  274,  270,  271,  289,  290,  277,
      280,   71,  282,  283,  283,  284,  283,  283,  285,  283,
      283,  283,  283,  283,  287,  283,  283,  283,  283,  283,
      283,  288,  291,   71,  293,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
      292,   71,   71,   71,   71,   71,  299,  300,   71,  302,
       71,  307,  309,  294,  298,   71,  301,   71,  296,  297,
      303,  314,  316,  306,  311,  304,  308,  312,   71,  315,

       71,  318,  313,  319,  310,  320,   71,   71,   71,   71,
       71,   71,   71,   71,  322,  321,   71,   71,   71,   71,
       71,   71,   71,  382,   71,  380,   71,   71,   71,   71,
      331,  336,   71,  327,  333,  374,   71,  330,  325,  324,
      326,  329,  332,  323,   71,   71,  337,  341,  335,  283,
      283,  284,  283,  283,  285,  283,  283,  283,  283,  283,
      340,  283,  283,  283,  283,  283,  283,   71,   71,   71,
       71,   71,   71,   71,  338,  339,   71,   71,   71,   71,
       71,   71,   71,   71,  342,  343,   71,   71,   71,   71,
      348,   71,   71,  352,   71,  345,  350,  354,   71,  349,

      347,  351,   71,  353,  361,   71,   71,   71,  360,  362,
      356,  359,   71,   71,  364,   71,  363,  368,   71,  369,
      365,   71,   71,   71,  377,   71,   71,  372,   71,  378,
      379,  373,  381,  371,  370,  375,  376,  367,  366,  385,
      386,   71,  358,  357,   71,  384,  383,   48,   48,   53,
       53,   57,   57,   61,   61,  143,  143,  286,  286,  283,
      283,   71,   71,  355,   71,   71,   71,   71,   71,   71,
       71,   71,   71,   71,   71,   71,  346,  344,   71,   71,
       71,   71,  284,  284,   71,   71,  334,   71,   71,   71,
       71,   71,  328,   71,   71,  317,   71,   71,   71,   71,

       71,   71,   71,   71,  295,   71,   71,   71,   71,   71,
       71,   71,  273,   71,   71,   71,   71,   71,   71,   71,
       71,   71,  246,   71,   71,   71,   71,  152,  152,  150,
      149,  148,  146,  144,  142,   71,   71,   71,   71,   60,
      150,  149,  148,  146,  144,   71,   70,   60,  387,    9,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387

    } ;

static yyconst short int yy_chk[794] =
    {   0,
        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,    2,    3,    3,    2,    4,    4,    5,
        5,    6,    6,    2,    7,    7,   15,    4,   24,    5,
       41,    6,    8,    8,   13,   13,   25,   15,   16,   16,
       18,   18,   45,   41,   27,   24,   26,   29,   61,   61,
       16,   23,   45,   62,   62,   24,   25,   25,   24,   26,
       25,   31,   40,   25,   28,   23,   23,   26,   27,   25,

       27,   27,  100,   26,   29,   32,   33,   23,   34,   31,
       27,   23,   23,   23,   35,   28,  100,   31,   32,   33,
       40,   28,   32,   40,   28,   34,   32,   33,   36,   43,
       37,   38,   32,   33,   44,   34,   42,   32,   47,   47,
       35,   36,   35,   37,   35,   36,   38,   37,   74,   42,
       47,   37,   38,   73,   43,   36,   64,   42,   36,   44,
       38,   43,   37,   38,   51,   66,   44,   64,   38,   39,
       65,   75,   65,   76,   51,   74,   66,   77,   79,   67,
       67,   78,   39,   80,   73,   82,   39,   75,   81,   39,
       39,   67,   77,   83,   78,   79,   39,   84,   77,   39,

       85,   87,   79,   76,   86,   81,   89,   88,   90,   91,
       92,   95,   93,   97,   84,   82,   96,  392,  386,   80,
       99,  102,  109,   83,   84,   91,   85,  103,   92,   96,
      104,   85,   88,   87,   86,  101,  105,  113,   89,   90,
       93,   95,  106,   99,   97,   97,  103,  102,   99,  107,
      108,   99,   99,  101,  109,  112,  111,  114,  106,  115,
      104,  101,  103,  116,  105,  107,  105,  117,  106,  119,
      113,  120,  105,  111,  114,  121,  112,  122,  123,  127,
      124,  125,  115,  128,  116,  108,  108,  126,  119,  129,
      131,  136,  132,  117,  118,  130,  122,  124,  134,  385,

      128,  120,  133,  122,  381,  121,  135,  118,  123,  118,
      124,  131,  125,  126,  129,  127,  137,  136,  130,  118,
      132,  138,  134,  133,  139,  118,  118,  135,  118,  137,
      140,  141,  145,  145,  154,  147,  156,  139,  158,  160,
      159,  141,  138,  163,  145,  147,  161,  165,  166,  167,
      168,  140,  170,  175,  174,  171,  163,  180,  179,  182,
      181,  166,  165,  156,  158,  154,  159,  160,  171,  183,
      161,  174,  171,  179,  175,  174,  182,  184,  185,  186,
      167,  187,  168,  179,  189,  192,  170,  181,  191,  193,
      180,  194,  200,  202,  205,  185,  186,  203,  204,  209,

      210,  189,  183,  206,  207,  191,  192,  234,  215,  184,
      214,  379,  212,  187,  194,  209,  203,  205,  213,  202,
      206,  378,  220,  234,  200,  193,  193,  214,  215,  204,
      207,  216,  210,  211,  211,  211,  211,  211,  211,  211,
      211,  211,  211,  211,  212,  211,  211,  211,  211,  211,
      211,  213,  216,  217,  220,  221,  223,  225,  226,  227,
      228,  229,  230,  233,  231,  235,  236,  238,  237,  240,
      217,  245,  248,  247,  249,  251,  227,  228,  250,  230,
      254,  236,  238,  221,  226,  255,  229,  256,  223,  225,
      231,  249,  251,  235,  245,  233,  237,  247,  258,  250,

      259,  254,  248,  255,  240,  256,  261,  262,  263,  265,
      264,  268,  269,  272,  259,  258,  280,  277,  282,  287,
      376,  276,  291,  374,  372,  369,  368,  364,  290,  360,
      272,  282,  359,  265,  277,  355,  354,  269,  263,  262,
      264,  268,  276,  261,  288,  289,  287,  291,  280,  286,
      286,  286,  286,  286,  286,  286,  286,  286,  286,  286,
      290,  286,  286,  286,  286,  286,  286,  292,  296,  300,
      302,  303,  305,  307,  288,  289,  312,  315,  309,  318,
      326,  331,  332,  336,  292,  296,  337,  335,  338,  339,
      303,  342,  349,  312,  343,  300,  307,  318,  353,  305,

      302,  309,  356,  315,  335,  362,  361,  383,  332,  336,
      326,  331,  363,  365,  338,  373,  337,  342,  375,  343,
      339,  377,  352,  384,  362,  351,  350,  349,  348,  363,
      365,  353,  373,  347,  345,  356,  361,  341,  340,  383,
      384,  333,  330,  329,  327,  377,  375,  388,  388,  389,
      389,  390,  390,  391,  391,  393,  393,  394,  394,  395,
      395,  325,  324,  323,  322,  321,  320,  319,  316,  314,
      313,  311,  310,  308,  306,  304,  301,  299,  298,  297,
      294,  293,  285,  283,  281,  279,  278,  275,  274,  271,
      270,  267,  266,  260,  257,  253,  252,  244,  243,  242,

      241,  239,  232,  224,  222,  219,  218,  208,  201,  199,
      198,  197,  196,  195,  190,  188,  178,  177,  176,  173,
      172,  169,  164,  162,  157,  155,  153,  152,  151,  150,
      149,  148,  146,  143,  142,  110,   98,   94,   72,   60,
       56,   54,   52,   49,   46,   30,   20,   11,    9,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387,  387,  387,  387,  387,  387,  387,  387,
      387,  387,  387

    } ;

static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;

/* The intent behind this definition is that it'll catch
 * any uses of REJECT which flex missed.
 */
#define REJECT reject_used_but_not_detected
static int yy_more_flag = 0;
static int yy_more_len = 0;
#define yymore() (yy_more_flag = 1)
#define YY_MORE_ADJ yy_more_len
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
#define INITIAL 0
/*
     YABASIC --- a tiny integrated Basic Compiler/Interpreter

     FLEX - part
     
     this Program is subject to the GNU General Public License;
     see the file yabasic.c for details.
*/

#include <string.h>
#undef WINDOWS

#include "bison.h"       /* get tokens from BISON */
#ifndef YABASIC_INCLUDED
#include "yabasic.h"     /* definitions of yabasic */
#endif

void switch_to_my_file(FILE *inputfile); /* switches input to given file */
#define RET 1

#define PRELNO 2

#define POSTLNO 3


/* Macros after this point can all be overridden by user definitions in
 * section 1.
 */

#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap YY_PROTO(( void ));
#else
extern int yywrap YY_PROTO(( void ));
#endif
#endif

#ifndef YY_NO_UNPUT
static void yyunput YY_PROTO(( int c, char *buf_ptr ));
#endif

#ifndef yytext_ptr
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
#endif

#ifdef YY_NEED_STRLEN
static int yy_flex_strlen YY_PROTO(( yyconst char * ));
#endif

#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput YY_PROTO(( void ));
#else
static int input YY_PROTO(( void ));
#endif
#endif

#if YY_STACK_USED
static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0;
#ifndef YY_NO_PUSH_STATE
static void yy_push_state YY_PROTO(( int new_state ));
#endif
#ifndef YY_NO_POP_STATE
static void yy_pop_state YY_PROTO(( void ));
#endif
#ifndef YY_NO_TOP_STATE
static int yy_top_state YY_PROTO(( void ));
#endif

#else
#define YY_NO_PUSH_STATE 1
#define YY_NO_POP_STATE 1
#define YY_NO_TOP_STATE 1
#endif

#ifdef YY_MALLOC_DECL
YY_MALLOC_DECL
#else
#if __STDC__
#ifndef __cplusplus
#include <stdlib.h>
#endif
#else
/* Just try to get by without declaring the routines.  This will fail
 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
 * or sizeof(void*) != sizeof(int).
 */
#endif
#endif

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

/* Copy whatever the last rule matched to the standard output. */

#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
 * we now use fwrite().
 */
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
#endif

/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 * is returned in "result".
 */
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
	if ( yy_current_buffer->yy_is_interactive ) \
		{ \
		int c = '*', n; \
		for ( n = 0; n < max_size && \
			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
			buf[n] = (char) c; \
		if ( c == '\n' ) \
			buf[n++] = (char) c; \
		if ( c == EOF && ferror( yyin ) ) \
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
		result = n; \
		} \
	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
		  && ferror( yyin ) ) \
		YY_FATAL_ERROR( "input in flex scanner failed" );
#endif

/* No semi-colon after return; correct usage is to write "yyterminate();" -
 * we don't want an extra ';' after the "return" because that will cause
 * some compilers to complain about unreachable statements.
 */
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif

/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif

/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif

/* Default declaration of generated scanner - a define so the user can
 * easily add parameters.
 */
#ifndef YY_DECL
#define YY_DECL int yylex YY_PROTO(( void ))
#endif

/* Code executed at the beginning of each rule, after yytext and yyleng
 * have been set up.
 */
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif

/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif

#define YY_RULE_SETUP \
	if ( yyleng > 0 ) \
		yy_current_buffer->yy_at_bol = \
				(yytext[yyleng - 1] == '\n'); \
	YY_USER_ACTION

YY_DECL
	{
	register yy_state_type yy_current_state;
	register char *yy_cp, *yy_bp;
	register int yy_act;



	if ( yy_init )
		{
		yy_init = 0;

#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_current_buffer =
				yy_create_buffer( yyin, YY_BUF_SIZE );

		yy_load_buffer_state();
		}

	while ( 1 )		/* loops until end-of-file is reached */
		{
		yy_more_len = 0;
		if ( yy_more_flag )
			{
			yy_more_len = yy_c_buf_p - yytext_ptr;
			yy_more_flag = 0;
			}
		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_current_state += YY_AT_BOL();
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 >= 388 )
					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] != 750 );

yy_find_action:
		yy_act = yy_accept[yy_current_state];
		if ( yy_act == 0 )
			{ /* have to back up */
			yy_cp = yy_last_accepting_cpos;
			yy_current_state = yy_last_accepting_state;
			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_RULE_SETUP
{BEGIN INITIAL;}     /* ignore whitespace */
	YY_BREAK
case 2:
YY_RULE_SETUP
{BEGIN INITIAL;} /* still ignore whitespace */
	YY_BREAK
case 3:
YY_RULE_SETUP
{BEGIN PRELNO;yyless(0);return tLABEL;}
	YY_BREAK
case 4:
YY_RULE_SETUP
{BEGIN PRELNO;yyless(0);return tLABEL;}
	YY_BREAK
case 5:
YY_RULE_SETUP
{}
	YY_BREAK
case 6:
YY_RULE_SETUP
{
  BEGIN POSTLNO;
  yylval.symbol=(char *)my_strdup(yytext);
  return tSYMBOL;
}
	YY_BREAK
case 7:
YY_RULE_SETUP
{BEGIN INITIAL; yylval.sep=0;return tSEP;}
	YY_BREAK
case 8:
YY_RULE_SETUP
{BEGIN INITIAL;yylval.sep=1;return tSEP;}
	YY_BREAK
case 9:
YY_RULE_SETUP
{BEGIN INITIAL;yylval.sep=1;return tSEP;}
	YY_BREAK
case 10:
YY_RULE_SETUP
{return yytext[0];}
	YY_BREAK
case 11:
YY_RULE_SETUP

⌨️ 快捷键说明

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