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

📄 parse.c

📁 大3编译原理课程设计 绝对符合老师要求 报告代码一应俱全 很详细 很靠谱
💻 C
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************
*                     U N R E G I S T E R E D   C O P Y
* 
* You are on day 12 of your 30 day trial period.
* 
* This file was produced by an UNREGISTERED COPY of Parser Generator. It is
* for evaluation purposes only. If you continue to use Parser Generator 30
* days after installation then you are required to purchase a license. For
* more information see the online help or go to the Bumble-Bee Software
* homepage at:
* 
* http://www.bumblebeesoftware.com
* 
* This notice must remain present in the file. It cannot be removed.
****************************************************************************/

/****************************************************************************
* parse.c
* C source file generated from parse.y.
* 
* Date: 12/20/08
* Time: 00:18:34
* 
* AYACC Version: 2.07
****************************************************************************/

#include <yypars.h>

/* namespaces */
#if defined(__cplusplus) && defined(YYSTDCPPLIB)
using namespace std;
#endif
#if defined(__cplusplus) && defined(YYNAMESPACE)
using namespace yl;
#endif

#define YYFASTPARSER

#line 1 ".\\parse.y"
 
#define YYPARSER /* distinguishes Yacc output from other code files */ 

#include "globals.h" 
#include "util.h" 
#include "scan.h" 
#include "parse.h" 


static char * savedFunName; /* for use in assignments */ 
static char * savedIdName; 
static int savedLineNo; /* ditto */ 
static TreeNode * savedTree; /* stores syntax tree for later return */ 


#line 56 "parse.c"
/* repeated because of possible precompiled header */
#include <yypars.h>

/* namespaces */
#if defined(__cplusplus) && defined(YYSTDCPPLIB)
using namespace std;
#endif
#if defined(__cplusplus) && defined(YYNAMESPACE)
using namespace yl;
#endif

#define YYFASTPARSER

#include ".\parse.h"

#ifndef YYSTYPE
#define YYSTYPE int
#endif
#ifndef YYSTACK_SIZE
#define YYSTACK_SIZE 100
#endif
#ifndef YYSTACK_MAX
#define YYSTACK_MAX 0
#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);
int YYNEAR YYDCDECL yystack_max = (YYSTACK_MAX);

/* 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 yyparseraction(int action)
#else
void YYCDECL yyparseraction(action)
int action;
#endif
{
	switch (action) {
	case 0:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 52 ".\\parse.y"
 savedTree = yyattribute(1 - 1).ptree;
#line 182 "parse.c"
			}
		}
		break;
	case 1:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 55 ".\\parse.y"
 TreeNode * t = yyattribute(1 - 2).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = yyattribute(2 - 2).ptree; 
yyval.ptree = yyattribute(1 - 2).ptree; } 
else yyval.ptree = yyattribute(2 - 2).ptree; 

#line 202 "parse.c"
			}
		}
		break;
	case 2:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 64 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 215 "parse.c"
			}
		}
		break;
	case 3:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 66 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 228 "parse.c"
			}
		}
		break;
	case 4:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 67 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 241 "parse.c"
			}
		}
		break;
	case 5:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 68 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 254 "parse.c"
			}
		}
		break;
	case 6:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 70 ".\\parse.y"
 savedIdName = copyString(tokenString); 
#line 267 "parse.c"
			}
		}
		break;
	case 7:
		{
#line 72 ".\\parse.y"
 savedFunName = savedIdName; 
#line 275 "parse.c"
		}
		break;
	case 8:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 75 ".\\parse.y"
 if(yyattribute(1 - 3).type == Void) 
; 
// err 
else 
{ 
yyval.ptree = newDecNode(VarK); 
yyval.ptree -> type = yyattribute(1 - 3).type; 
yyval.ptree -> child[0] = yyattribute(2 - 3).ptree; 
} 

#line 296 "parse.c"
			}
		}
		break;
	case 9:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 87 ".\\parse.y"
 
TreeNode * t = yyattribute(1 - 3).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = yyattribute(3 - 3).ptree; 
yyval.ptree = yyattribute(1 - 3).ptree; } 
else yyval.ptree = yyattribute(3 - 3).ptree; 

#line 317 "parse.c"
			}
		}
		break;
	case 10:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 96 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 330 "parse.c"
			}
		}
		break;
	case 11:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[6];
			yyinitdebug(yya, 6);
#endif
			{
#line 98 ".\\parse.y"
 
TreeNode * new_node = newStmtNode(AssignK); 
TreeNode * t = yyattribute(1 - 5).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = new_node; 
yyval.ptree = yyattribute(1 - 5).ptree; } 
else yyval.ptree = new_node; 

#line 352 "parse.c"
			}
		}
		break;
	case 12:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 109 ".\\parse.y"
 
yyval.ptree = newStmtNode(AssignK); 
yyval.ptree -> child[0] = newExpNode(IdK); 
yyval.ptree -> child[0] -> attr.name = savedIdName; 
yyval.ptree -> child[1] = yyattribute(3 - 3).ptree; 

#line 370 "parse.c"
			}
		}
		break;
	case 13:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 116 ".\\parse.y"
 yyval.type = Integer; 
#line 383 "parse.c"
			}
		}
		break;
	case 14:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 117 ".\\parse.y"
 yyval.type = Float; 
#line 396 "parse.c"
			}
		}
		break;
	case 15:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 118 ".\\parse.y"
 yyval.type = Char; 
#line 409 "parse.c"
			}
		}
		break;
	case 16:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 119 ".\\parse.y"
 yyval.type = Void; 
#line 422 "parse.c"
			}
		}
		break;
	case 17:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[8];
			yyinitdebug(yya, 8);
#endif
			{
#line 122 ".\\parse.y"
 yyval.ptree = newDecNode(FunDefK); 
yyval.ptree -> attr.name = savedFunName; 
yyval.ptree -> type = yyattribute(1 - 7).type; 
yyval.ptree -> child[0] = yyattribute(5 - 7).ptree; 
yyval.ptree -> child[1] = yyattribute(7 - 7).ptree; 

#line 440 "parse.c"
			}
		}
		break;
	case 18:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[7];
			yyinitdebug(yya, 7);
#endif
			{
#line 129 ".\\parse.y"
 yyval.ptree = newDecNode(FunDefK); 
yyval.ptree -> attr.name = savedFunName; 
yyval.ptree -> type = Void; 
yyval.ptree -> child[0] = yyattribute(4 - 6).ptree; 
yyval.ptree -> child[1] = yyattribute(6 - 6).ptree; 

#line 458 "parse.c"
			}
		}
		break;
	case 19:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[8];
			yyinitdebug(yya, 8);
#endif
			{
#line 137 ".\\parse.y"
 yyval.ptree = newDecNode(FunDecK); 
yyval.ptree -> attr.name = savedFunName; 
yyval.ptree -> type = yyattribute(1 - 7).type; 
yyval.ptree -> child[0] = yyattribute(5 - 7).ptree; 
yyval.ptree -> child[1] = NULL; 

#line 476 "parse.c"
			}
		}
		break;
	case 20:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[7];
			yyinitdebug(yya, 7);
#endif
			{
#line 144 ".\\parse.y"
 yyval.ptree = newDecNode(FunDecK); 
yyval.ptree -> attr.name = savedFunName; 
yyval.ptree -> type = Void; 
yyval.ptree -> child[0] = yyattribute(4 - 6).ptree; 
yyval.ptree -> child[1] = NULL; 

#line 494 "parse.c"
			}
		}
		break;
	case 21:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 152 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 507 "parse.c"
			}
		}
		break;
	case 22:
		{
#line 154 ".\\parse.y"
 yyval.ptree = NULL; 
#line 515 "parse.c"
		}
		break;
	case 23:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[4];
			yyinitdebug(yya, 4);
#endif
			{
#line 157 ".\\parse.y"
 TreeNode * t = yyattribute(1 - 3).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = yyattribute(3 - 3).ptree; 
yyval.ptree = yyattribute(1 - 3).ptree; } 
else yyval.ptree = yyattribute(3 - 3).ptree; 

#line 534 "parse.c"
			}
		}
		break;
	case 24:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 166 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 547 "parse.c"
			}
		}
		break;
	case 25:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 169 ".\\parse.y"
 yyval.ptree = newDecNode(ParamK); 
yyval.ptree -> type = yyattribute(1 - 1).type; 

#line 562 "parse.c"
			}
		}
		break;
	case 26:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 173 ".\\parse.y"
 yyval.ptree = newDecNode(ParamK); 
yyval.ptree -> type = yyattribute(1 - 2).type; 
yyval.ptree -> attr.name = savedIdName; 

#line 578 "parse.c"
			}
		}
		break;
	case 27:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[5];
			yyinitdebug(yya, 5);
#endif
			{
#line 178 ".\\parse.y"
 yyval.ptree = newDecNode(ParamK); 
yyval.ptree -> type = yyattribute(1 - 4).type; 
yyval.ptree -> attr.name = savedIdName; 

#line 594 "parse.c"
			}
		}
		break;
	case 28:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[6];
			yyinitdebug(yya, 6);
#endif
			{
#line 183 ".\\parse.y"
 yyval.ptree = newDecNode(ParamK); 
yyval.ptree -> type = yyattribute(1 - 5).type; 
yyval.ptree -> attr.name = savedIdName; 
yyval.ptree -> child[0] = yyattribute(4 - 5).ptree; 

#line 611 "parse.c"
			}
		}
		break;
	case 29:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[5];
			yyinitdebug(yya, 5);
#endif
			{
#line 190 ".\\parse.y"
 yyval.ptree = newDecNode(CompK); 
yyval.ptree -> child[0] = yyattribute(2 - 4).ptree; 
yyval.ptree -> child[1] = yyattribute(3 - 4).ptree; 

#line 627 "parse.c"
			}
		}
		break;
	case 30:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 196 ".\\parse.y"
 TreeNode * t = yyattribute(1 - 2).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = yyattribute(2 - 2).ptree; 
yyval.ptree = yyattribute(1 - 2).ptree; } 
else yyval.ptree = yyattribute(2 - 2).ptree; 

#line 647 "parse.c"
			}
		}
		break;
	case 31:
		{
#line 205 ".\\parse.y"
 yyval.ptree = NULL; 
#line 655 "parse.c"
		}
		break;
	case 32:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[3];
			yyinitdebug(yya, 3);
#endif
			{
#line 208 ".\\parse.y"
 TreeNode * t = yyattribute(1 - 2).ptree; 
if (t != NULL) 
{ while (t->sibling != NULL) 
t = t->sibling; 
t->sibling = yyattribute(2 - 2).ptree; 
yyval.ptree = yyattribute(1 - 2).ptree; } 
else yyval.ptree = yyattribute(2 - 2).ptree; 

#line 674 "parse.c"
			}
		}
		break;
	case 33:
		{
#line 217 ".\\parse.y"
 yyval.ptree = NULL; 
#line 682 "parse.c"
		}
		break;
	case 34:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 219 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 694 "parse.c"
			}
		}
		break;
	case 35:
		{
#ifdef YYDEBUG
			YYSTYPE YYFAR *yya[2];
			yyinitdebug(yya, 2);
#endif
			{
#line 220 ".\\parse.y"
 yyval.ptree = yyattribute(1 - 1).ptree; 
#line 707 "parse.c"
			}
		}
		break;

⌨️ 快捷键说明

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