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

📄 y_tab.c

📁 lua解释器早期1.0版本
💻 C
📖 第 1 页 / 共 3 页
字号:
    23,    24,    15,    16,    16,    25,    28,    25,    29,    25,    25,    25,    25,    27,    27,    27,    32,    33,    22,    34,    35,    34,     2,    26,     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,    36,     3,     3,     3,     3,     3,     3,     3,     3,    38,     3,    39,     3,    37,    37,    41,    30,    40,     4,     4,     5,    42,     5,    20,    20,    43,    43,    13,    13,     7,     7,     8,     8,     9,     9,    45,    44,    10,    10,    46,    11,    48,    11,    47,     6,     6,    12,    49,    12,    50,    12,    31,    31,    51,    52,    51,    18 };int yyr2[]={     0,     0,     1,     9,     4,     4,     1,     1,    19,     0,     6,     1,     4,     0,     2,    17,     1,    17,     1,    13,     7,     3,     4,     0,     4,    15,     1,     1,     9,     0,     1,     9,     1,     3,     7,     7,     7,     7,     7,     7,     7,     7,     7,     7,     7,     7,     5,     5,     1,     9,     9,     3,     3,     3,     3,     3,     5,     1,    11,     1,    11,     1,     2,     1,    11,     3,     1,     3,     3,     1,     9,     0,     2,     3,     7,     1,     3,     7,     7,     1,     3,     3,     7,     1,     9,     1,     3,     1,     5,     1,     9,     3,     3,     7,     3,     1,    11,     1,     9,     5,     9,     1,     1,     6,     3 };int yychk[]={ -1000,    -1,   -14,   -17,   -18,   270,   273,   -15,   -24,   271,   -16,    59,   -25,   258,   262,   264,    -6,   -30,   268,   -12,   -40,   271,   -19,   -26,    -3,    40,    43,    45,    64,   -12,   269,   272,   257,   -30,   274,   -28,   -29,    61,    44,   -31,   271,   -49,   -50,   -41,    40,   259,    61,    60,    62,   277,   278,   279,    43,    45,    42,    47,   280,   275,   276,    -3,   -26,   -26,   -26,   -36,    40,   -26,   -26,   -22,   -32,    -5,    -3,   -12,    44,   -51,    61,    91,    46,    40,   -20,   -43,   271,    -2,   -26,   -26,   -26,   -26,   -26,   -26,   -26,   -26,   -26,   -26,   -26,    -2,    -2,    41,   -13,   271,   -37,   -26,   263,   265,   -23,    44,   271,   -52,   -26,   271,    -4,    -5,    41,    44,   -22,   -38,   -39,    -7,   123,    91,    41,    -2,   -26,   -15,   -33,   -42,   -51,   -26,    93,    41,   -21,   271,    -2,   -26,   -26,    -8,    -9,   -44,   271,   -10,   -11,   -46,   -22,    -2,   -16,   -34,   -35,    -3,   -22,   -27,   260,   261,   125,    44,   -45,    93,    44,   -47,   -26,    -2,   267,   266,   266,   -22,   -26,   -44,    61,   -48,   266,    -4,   259,   -26,   -47,   -16,    -2,   -22,    -2,   -27 };int yydef[]={     1,    -2,    11,     4,     5,     0,   104,    13,     0,     6,     3,    14,    12,     0,    16,    18,     0,    21,     0,    -2,    63,    94,     0,     0,    33,     0,     0,     0,    48,    -2,    52,    53,    54,    55,     0,     0,    26,     0,     0,    22,   101,     0,     0,     0,    71,    32,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,    32,    32,    33,     0,    46,    47,    75,    61,    56,     0,     0,     9,    20,    -2,    -2,     0,    99,   102,     0,     0,    66,     0,    72,    73,    26,    35,    36,    37,    38,    39,    40,    41,    42,    43,    44,    45,    57,    59,    34,     0,    76,     0,    62,    32,     0,    -2,    69,   101,     0,     0,    98,     0,    67,     7,     0,    32,     0,     0,    49,    79,    -2,    50,    26,    32,    13,    -2,     0,   100,   103,    96,    64,    26,    74,    23,    58,    60,     0,    80,    81,    83,     0,    86,     0,    32,    19,    10,    28,     0,    -2,     0,     0,    26,     0,    77,     0,     0,    78,    89,    88,    91,     0,    66,     8,    15,    24,     0,    82,     0,     0,    17,    13,    32,    84,    90,    31,    26,    32,    23,    25 };typedef struct { char *t_name; int t_val; } yytoktype;#ifndef YYDEBUG#	define YYDEBUG	0	/* don't allow debugging */#endif#if YYDEBUGyytoktype yytoks[] ={	"NIL",	257,	"IF",	258,	"THEN",	259,	"ELSE",	260,	"ELSEIF",	261,	"WHILE",	262,	"DO",	263,	"REPEAT",	264,	"UNTIL",	265,	"END",	266,	"RETURN",	267,	"LOCAL",	268,	"NUMBER",	269,	"FUNCTION",	270,	"NAME",	271,	"STRING",	272,	"DEBUG",	273,	"NOT",	274,	"AND",	275,	"OR",	276,	"=",	61,	"NE",	277,	">",	62,	"<",	60,	"LE",	278,	"GE",	279,	"CONC",	280,	"+",	43,	"-",	45,	"*",	42,	"/",	47,	"%",	37,	"UNARY",	281,	"-unknown-",	-1	/* ends search */};char * yyreds[] ={	"-no such reduction-",	"functionlist : /* empty */",	"functionlist : functionlist",	"functionlist : functionlist stat sc",	"functionlist : functionlist function",	"functionlist : functionlist setdebug",	"function : FUNCTION NAME",	"function : FUNCTION NAME '(' parlist ')'",	"function : FUNCTION NAME '(' parlist ')' block END",	"statlist : /* empty */",	"statlist : statlist stat sc",	"stat : /* empty */",	"stat : stat1",	"sc : /* empty */",	"sc : ';'",	"stat1 : IF expr1 THEN PrepJump block PrepJump elsepart END",	"stat1 : WHILE",	"stat1 : WHILE expr1 DO PrepJump block PrepJump END",	"stat1 : REPEAT",	"stat1 : REPEAT block UNTIL expr1 PrepJump",	"stat1 : varlist1 '=' exprlist1",	"stat1 : functioncall",	"stat1 : LOCAL declist",	"elsepart : /* empty */",	"elsepart : ELSE block",	"elsepart : ELSEIF expr1 THEN PrepJump block PrepJump elsepart",	"block : /* empty */",	"block : statlist",	"block : statlist ret",	"ret : /* empty */",	"ret : /* empty */",	"ret : RETURN exprlist sc",	"PrepJump : /* empty */",	"expr1 : expr",	"expr : '(' expr ')'",	"expr : expr1 '=' expr1",	"expr : expr1 '<' expr1",	"expr : expr1 '>' expr1",	"expr : expr1 NE expr1",	"expr : expr1 LE expr1",	"expr : expr1 GE expr1",	"expr : expr1 '+' expr1",	"expr : expr1 '-' expr1",	"expr : expr1 '*' expr1",	"expr : expr1 '/' expr1",	"expr : expr1 CONC expr1",	"expr : '+' expr1",	"expr : '-' expr1",	"expr : '@'",	"expr : '@' objectname fieldlist",	"expr : '@' '(' dimension ')'",	"expr : var",	"expr : NUMBER",	"expr : STRING",	"expr : NIL",	"expr : functioncall",	"expr : NOT expr1",	"expr : expr1 AND PrepJump",	"expr : expr1 AND PrepJump expr1",	"expr : expr1 OR PrepJump",	"expr : expr1 OR PrepJump expr1",	"dimension : /* empty */",	"dimension : expr1",	"functioncall : functionvalue",	"functioncall : functionvalue '(' exprlist ')'",	"functionvalue : var",	"exprlist : /* empty */",	"exprlist : exprlist1",	"exprlist1 : expr",	"exprlist1 : exprlist1 ','",	"exprlist1 : exprlist1 ',' expr",	"parlist : /* empty */",	"parlist : parlist1",	"parlist1 : NAME",	"parlist1 : parlist1 ',' NAME",	"objectname : /* empty */",	"objectname : NAME",	"fieldlist : '{' ffieldlist '}'",	"fieldlist : '[' lfieldlist ']'",	"ffieldlist : /* empty */",	"ffieldlist : ffieldlist1",	"ffieldlist1 : ffield",	"ffieldlist1 : ffieldlist1 ',' ffield",	"ffield : NAME",	"ffield : NAME '=' expr1",	"lfieldlist : /* empty */",	"lfieldlist : lfieldlist1",	"lfieldlist1 : /* empty */",	"lfieldlist1 : lfield",	"lfieldlist1 : lfieldlist1 ','",	"lfieldlist1 : lfieldlist1 ',' lfield",	"lfield : expr1",	"varlist1 : var",	"varlist1 : varlist1 ',' var",	"var : NAME",	"var : var",	"var : var '[' expr1 ']'",	"var : var",	"var : var '.' NAME",	"declist : NAME init",	"declist : declist ',' NAME init",	"init : /* empty */",	"init : '='",	"init : '=' expr1",	"setdebug : DEBUG",};#endif /* YYDEBUG */#line 1 "/usr/lib/yaccpar"/*	@(#)yaccpar 1.10 89/04/04 SMI; from S5R3 1.10	*//*** Skeleton parser driver for yacc output*//*** yacc user known macros and defines*/#define YYERROR		goto yyerrlab#define YYACCEPT	{ free(yys); free(yyv); return(0); }#define YYABORT		{ free(yys); free(yyv); return(1); }#define YYBACKUP( newtoken, newvalue )\{\	if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\	{\		yyerror( "syntax error - cannot backup" );\		goto yyerrlab;\	}\	yychar = newtoken;\	yystate = *yyps;\	yylval = newvalue;\	goto yynewstate;\}#define YYRECOVERING()	(!!yyerrflag)#ifndef YYDEBUG#	define YYDEBUG	1	/* make debugging available */#endif/*** user known globals*/int yydebug;			/* set to 1 to get debugging *//*** driver internal defines*/#define YYFLAG		(-1000)/*** static variables used by the parser*/static YYSTYPE *yyv;			/* value stack */static int *yys;			/* state stack */static YYSTYPE *yypv;			/* top of value stack */static int *yyps;			/* top of state stack */static int yystate;			/* current state */static int yytmp;			/* extra var (lasts between blocks) */int yynerrs;			/* number of errors */int yyerrflag;			/* error recovery flag */int yychar;			/* current input token number *//*** yyparse - return 0 if worked, 1 if syntax error not recovered from*/intyyparse(){	register YYSTYPE *yypvt;	/* top of value stack for $vars */	unsigned yymaxdepth = YYMAXDEPTH;	/*	** Initialize externals - yyparse may be called more than once	*/	yyv = (YYSTYPE*)malloc(yymaxdepth*sizeof(YYSTYPE));	yys = (int*)malloc(yymaxdepth*sizeof(int));	if (!yyv || !yys)	{		yyerror( "out of memory" );		return(1);	}	yypv = &yyv[-1];	yyps = &yys[-1];	yystate = 0;	yytmp = 0;	yynerrs = 0;	yyerrflag = 0;	yychar = -1;	goto yystack;	{		register YYSTYPE *yy_pv;	/* top of value stack */		register int *yy_ps;		/* top of state stack */		register int yy_state;		/* current state */		register int  yy_n;		/* internal state number info */		/*		** get globals into registers.		** branch to here only if YYBACKUP was called.		*/	yynewstate:		yy_pv = yypv;		yy_ps = yyps;		yy_state = yystate;		goto yy_newstate;		/*		** get globals into registers.		** either we just started, or we just finished a reduction		*/	yystack:		yy_pv = yypv;		yy_ps = yyps;		yy_state = yystate;		/*		** top of for (;;) loop while no reductions done		*/	yy_stack:		/*		** put a state and value onto the stacks		*/#if YYDEBUG		/*		** if debugging, look up token value in list of value vs.		** name pairs.  0 and negative (-1) are special values.		** Note: linear search is used since time is not a real		** consideration while debugging.		*/		if ( yydebug )		{			register int yy_i;			(void)printf( "State %d, token ", yy_state );			if ( yychar == 0 )				(void)printf( "end-of-file\n" );			else if ( yychar < 0 )				(void)printf( "-none-\n" );			else			{				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;					yy_i++ )				{					if ( yytoks[yy_i].t_val == yychar )						break;				}				(void)printf( "%s\n", yytoks[yy_i].t_name );			}		}#endif /* YYDEBUG */		if ( ++yy_ps >= &yys[ yymaxdepth ] )	/* room on stack? */		{			/*			** reallocate and recover.  Note that pointers			** have to be reset, or bad things will happen			*/			int yyps_index = (yy_ps - yys);			int yypv_index = (yy_pv - yyv);			int yypvt_index = (yypvt - yyv);			yymaxdepth += YYMAXDEPTH;			yyv = (YYSTYPE*)realloc((char*)yyv,				yymaxdepth * sizeof(YYSTYPE));			yys = (int*)realloc((char*)yys,				yymaxdepth * sizeof(int));			if (!yyv || !yys)			{				yyerror( "yacc stack overflow" );				return(1);			}			yy_ps = yys + yyps_index;			yy_pv = yyv + yypv_index;			yypvt = yyv + yypvt_index;		}		*yy_ps = yy_state;		*++yy_pv = yyval;		/*		** we have a new state - find out what to do		*/	yy_newstate:		if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )			goto yydefault;		/* simple state */#if YYDEBUG		/*		** if debugging, need to mark whether new token grabbed		*/		yytmp = yychar < 0;#endif		if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )			yychar = 0;		/* reached EOF */#if YYDEBUG		if ( yydebug && yytmp )		{			register int yy_i;			(void)printf( "Received token " );			if ( yychar == 0 )				(void)printf( "end-of-file\n" );			else if ( yychar < 0 )				(void)printf( "-none-\n" );			else			{				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;					yy_i++ )				{					if ( yytoks[yy_i].t_val == yychar )						break;				}				(void)printf( "%s\n", yytoks[yy_i].t_name );			}		}#endif /* YYDEBUG */		if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )			goto yydefault;		if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )	/*valid shift*/		{			yychar = -1;			yyval = yylval;			yy_state = yy_n;			if ( yyerrflag > 0 )				yyerrflag--;			goto yy_stack;		}	yydefault:		if ( ( yy_n = yydef[ yy_state ] ) == -2 )		{#if YYDEBUG			yytmp = yychar < 0;#endif			if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) )				yychar = 0;		/* reached EOF */#if YYDEBUG			if ( yydebug && yytmp )			{				register int yy_i;				(void)printf( "Received token " );				if ( yychar == 0 )					(void)printf( "end-of-file\n" );				else if ( yychar < 0 )					(void)printf( "-none-\n" );				else				{					for ( yy_i = 0;						yytoks[yy_i].t_val >= 0;						yy_i++ )					{						if ( yytoks[yy_i].t_val							== yychar )						{							break;						}					}					(void)printf( "%s\n", yytoks[yy_i].t_name );				}			}#endif /* YYDEBUG */			/*			** look through exception table			*/			{				register int *yyxi = yyexca;				while ( ( *yyxi != -1 ) ||					( yyxi[1] != yy_state ) )				{					yyxi += 2;				}				while ( ( *(yyxi += 2) >= 0 ) &&					( *yyxi != yychar ) )					;				if ( ( yy_n = yyxi[1] ) < 0 )					YYACCEPT;			}		}		/*		** check for syntax error		*/		if ( yy_n == 0 )	/* have an error */		{			/* no worry about speed here! */			switch ( yyerrflag )			{			case 0:		/* new error */				yyerror( "syntax error" );				goto skip_init;			yyerrlab:				/*				** get globals into registers.				** we have a user generated syntax type error				*/				yy_pv = yypv;				yy_ps = yyps;				yy_state = yystate;				yynerrs++;			skip_init:			case 1:			case 2:		/* incompletely recovered error */					/* try again... */				yyerrflag = 3;				/*				** find state where "error" is a legal				** shift action				*/				while ( yy_ps >= yys )				{					yy_n = yypact[ *yy_ps ] + YYERRCODE;					if ( yy_n >= 0 && yy_n < YYLAST &&						yychk[yyact[yy_n]] == YYERRCODE)					{						/*						** simulate shift of "error"						*/						yy_state = yyact[ yy_n ];						goto yy_stack;					}					/*					** current state has no shift on					** "error", pop stack					*/#if YYDEBUG#	define _POP_ "Error recovery pops state %d, uncovers state %d\n"					if ( yydebug )						(void)printf( _POP_, *yy_ps,							yy_ps[-1] );#	undef _POP_#endif					yy_ps--;					yy_pv--;				}				/*				** there is no state on stack with "error" as				** a valid shift.  give up.

⌨️ 快捷键说明

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