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

📄 y_tab.c

📁 6个不同的词法语法分析程序源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
#include <yacc.h>

#define YYPARSEFAST
#line 2 "F:\\\261\340\322\353\\CCompiler\\parser.y"

#define YYPARSER /* distinguishes Yacc output from other code files */

#include "globals.h"
#include "util.h"
#include "scan.h"
#include "parse.h"
#include <stdlib.h>

#define YYSTYPE TreeNode *
static char * savedName; /* for use in assignments */
static int savedLineNo; /* ditto */
static TreeNode * savedTree; /* stores syntax tree for later return */


#line 21 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
/* repeated because of possible precompiled header */
#include <yacc.h>

#define YYPARSEFAST
#include "y_tab.h"

#ifndef YYSTYPE
#define YYSTYPE int
#endif
#ifndef YYSTACK_SIZE
#define YYSTACK_SIZE 100
#endif

/* (state) stack */
#if (YYSTACK_SIZE) != 0
static yystack_t YYNEAR yystack[(YYSTACK_SIZE)];
yystack_t YYFAR *YYNEAR YYDCDECL yysstackptr = yystack;
yystack_t YYFAR *YYNEAR YYDCDECL yystackptr = yystack;
#else
yystack_t YYFAR *YYNEAR YYDCDECL yysstackptr = NULL;
yystack_t YYFAR *YYNEAR YYDCDECL yystackptr = NULL;
#endif

/* attribute stack */
#if (YYSTACK_SIZE) != 0
static YYSTYPE YYNEAR yyattributestack[(YYSTACK_SIZE)];
#ifdef YYPROTOTYPE
void YYFAR *YYNEAR YYDCDECL yysattributestackptr = yyattributestack;
void YYFAR *YYNEAR YYDCDECL yyattributestackptr = yyattributestack;
#else
char YYFAR *YYNEAR YYDCDECL yysattributestackptr = (char YYFAR *) yyattributestack;
char YYFAR *YYNEAR YYDCDECL yyattributestackptr = (char YYFAR *) yyattributestack;
#endif
#else
#ifdef YYPROTOTYPE
void YYFAR *YYNEAR YYDCDECL yysattributestackptr = NULL;
void YYFAR *YYNEAR YYDCDECL yyattributestackptr = NULL;
#else
char YYFAR *YYNEAR YYDCDECL yysattributestackptr = NULL;
char YYFAR *YYNEAR YYDCDECL yyattributestackptr = NULL;
#endif
#endif

int YYNEAR YYDCDECL yysstack_size = (YYSTACK_SIZE);
int YYNEAR YYDCDECL yystack_size = (YYSTACK_SIZE);

/* attributes */
YYSTYPE YYNEAR yyval;
YYSTYPE YYNEAR yylval;
#ifdef YYPROTOTYPE
void YYFAR *YYNEAR YYDCDECL yyvalptr = &yyval;
void YYFAR *YYNEAR YYDCDECL yylvalptr = &yylval;
#else
char YYFAR *YYNEAR YYDCDECL yyvalptr = (char *) &yyval;
char YYFAR *YYNEAR YYDCDECL yylvalptr = (char *) &yylval;
#endif

size_t YYNEAR YYDCDECL yyattribute_size = sizeof(YYSTYPE);

/* yyattribute */
#ifdef YYDEBUG
#ifdef YYPROTOTYPE
static YYSTYPE YYFAR *yyattribute1(int index)
#else
static YYSTYPE YYFAR *yyattribute1(index)
int index;
#endif
{
	YYSTYPE YYFAR *p = &((YYSTYPE YYFAR *) yyattributestackptr)[yytop + index];
	return p;
}
#define yyattribute(index) (*yyattribute1(index))
#else
#define yyattribute(index) (((YYSTYPE YYFAR *) yyattributestackptr)[yytop + (index)])
#endif

#ifdef YYDEBUG
#ifdef YYPROTOTYPE
static void yyinitdebug(YYSTYPE YYFAR **p, int count)
#else
static void yyinitdebug(p, count)
YYSTYPE YYFAR **p;
int count;
#endif
{
	int i;
	yyassert(p != NULL);
	yyassert(count >= 1);

	for (i = 0; i < count; i++) {
		p[i] = &((YYSTYPE YYFAR *) yyattributestackptr)[yytop + i - (count - 1)];
	}
}
#endif

#ifdef YYPROTOTYPE
void YYCDECL yyparseaction(int action)
#else
void YYCDECL yyparseaction(action)
int action;
#endif
{
	switch (action) {
	case 0:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[7];
			yyinitdebug(yya, 7);
#endif
			{
#line 25 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 savedTree = yyattribute(5 - 6);
#line 134 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 1:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 28 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 YYSTYPE t = yyattribute(1 - 2);
                   if (t != NULL)
                   { while (t->sibling != NULL)
                        t = t->sibling;
                     t->sibling = yyattribute(2 - 2);
                     yyval = yyattribute(1 - 2); }
                     else yyval = yyattribute(2 - 2);
                 
#line 154 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 2:
		{
#line 36 "F:\\\261\340\322\353\\CCompiler\\parser.y"
yyval = NULL;
#line 162 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
		}
		break;
	case 3:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 38 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = yyattribute(1 - 1); 
#line 174 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 4:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 39 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = yyattribute(1 - 1); 
#line 187 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 5:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 40 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = yyattribute(1 - 1); 
#line 200 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 6:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 41 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = yyattribute(1 - 1); 
#line 213 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 7:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 42 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(BreakK); 
#line 226 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 8:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 43 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = NULL; 
#line 239 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 9:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[8];
			yyinitdebug(yya, 8);
#endif
			{
#line 46 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(IfK);
                   yyval->child[0] = yyattribute(3 - 7);
                   yyval->child[1] = yyattribute(6 - 7);
                 
#line 255 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 10:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[12];
			yyinitdebug(yya, 12);
#endif
			{
#line 51 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(IfK);
                   yyval->child[0] = yyattribute(3 - 11);
                   yyval->child[1] = yyattribute(6 - 11);
                   yyval->child[2] = yyattribute(10 - 11);
                 
#line 272 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 11:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[8];
			yyinitdebug(yya, 8);
#endif
			{
#line 58 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(WhileK);
                   yyval->child[0] = yyattribute(3 - 7);
                   yyval->child[1] = yyattribute(6 - 7);
                 
#line 288 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 12:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 64 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(ExK);
                   yyval->child[0] = yyattribute(1 - 2);
                 
#line 303 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 13:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 68 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newStmtNode(ExK);
                 
#line 317 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 14:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 72 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 YYSTYPE t = yyattribute(2 - 3);
			       while (t!= NULL){
			       		if(yyattribute(1 - 3)->kind.type == IntK)
			       			t->type = Integer;
			       		else if(yyattribute(1 - 3)->kind.type == FloatK)
			       			t->type = Float;
			       	    else if(yyattribute(1 - 3)->kind.type == CharK)
			       			t->type = Char;
			       		else t->type = Void;
			       		t = t->sibling;
			       	}
			       yyval = newStmtNode(DeclK);
			       yyval->child[0] = yyattribute(1 - 3);
			       yyval->child[1] = yyattribute(2 - 3);
			       
			     
#line 345 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 15:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 91 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 YYSTYPE t = yyattribute(1 - 3);
                  yyattribute(3 - 3)->attr.isDecl = TRUE;
                   if (t != NULL)
                   { while (t->sibling != NULL)
                        t = t->sibling;
                     t->sibling = yyattribute(3 - 3);
                     yyval = yyattribute(1 - 3); }
                     else yyval = yyattribute(3 - 3);
                 
#line 366 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 16:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 101 "F:\\\261\340\322\353\\CCompiler\\parser.y"
  yyval = yyattribute(1 - 1);
                   yyval->attr.isDecl = TRUE;
                
#line 381 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 17:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 145 "F:\\\261\340\322\353\\CCompiler\\parser.y"
  yyval = newTypeNode(IntK);
				
#line 395 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 18:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 148 "F:\\\261\340\322\353\\CCompiler\\parser.y"
  yyval = newTypeNode(FloatK);
				
#line 409 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 19:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 151 "F:\\\261\340\322\353\\CCompiler\\parser.y"
  yyval = newTypeNode(CharK);
				
#line 423 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 20:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 156 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = newExpNode(AssignK);
                   yyval->child[0] = yyattribute(1 - 3);
                   yyval->child[1] = yyattribute(3 - 3);

                 
#line 440 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 21:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 161 "F:\\\261\340\322\353\\CCompiler\\parser.y"
 yyval = yyattribute(1 - 1);
#line 453 "F:\\\261\340\322\353\\CCompiler\\y_tab.c"
			}
		}
		break;
	case 22:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{

⌨️ 快捷键说明

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