📄 parse.c
字号:
/****************************************************************************
* U N R E G I S T E R E D C O P Y
*
* You are on day 49 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/23/08
* Time: 20:50:56
*
* AYACC Version: 2.06
****************************************************************************/
#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"
/****************************************************************************
parse.y
ParserWizard generated YACC file.
BY:计算机科学与技术系 0610386 蒲凌君
Date: 2008年12月22日 星期一
****************************************************************************/
#define YYPARSER
#include "globals.h"
#include "util.h"
#include "scan.h"
#include "parse.h"
static char * savedFunName; //保存函数名
static char * savedIdName; //保存变量名
static int savedLineNo; //保存行号
static TreeNode * savedTree; //保存语法树的根结点
#line 61 "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 68 ".\\parse.y"
savedTree = yyattribute(1 - 1).ptree;
#line 187 "parse.c"
}
}
break;
case 1:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[3];
yyinitdebug(yya, 3);
#endif
{
#line 71 ".\\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 207 "parse.c"
}
}
break;
case 2:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 80 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 220 "parse.c"
}
}
break;
case 3:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 82 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 233 "parse.c"
}
}
break;
case 4:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 83 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 246 "parse.c"
}
}
break;
case 5:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 84 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 259 "parse.c"
}
}
break;
case 6:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 86 ".\\parse.y"
savedIdName = copyString(tokenString);
#line 272 "parse.c"
}
}
break;
case 7:
{
#line 88 ".\\parse.y"
savedFunName = savedIdName;
#line 280 "parse.c"
}
break;
case 8:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 91 ".\\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 301 "parse.c"
}
}
break;
case 9:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 103 ".\\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 322 "parse.c"
}
}
break;
case 10:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 112 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 335 "parse.c"
}
}
break;
case 11:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 114 ".\\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 357 "parse.c"
}
}
break;
case 12:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 125 ".\\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 375 "parse.c"
}
}
break;
case 13:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 132 ".\\parse.y"
yyval.type = Integer;
#line 388 "parse.c"
}
}
break;
case 14:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 133 ".\\parse.y"
yyval.type = Double;
#line 401 "parse.c"
}
}
break;
case 15:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 134 ".\\parse.y"
yyval.type = Char;
#line 414 "parse.c"
}
}
break;
case 16:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 135 ".\\parse.y"
yyval.type = Void;
#line 427 "parse.c"
}
}
break;
case 17:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[8];
yyinitdebug(yya, 8);
#endif
{
#line 138 ".\\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 445 "parse.c"
}
}
break;
case 18:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[7];
yyinitdebug(yya, 7);
#endif
{
#line 145 ".\\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 463 "parse.c"
}
}
break;
case 19:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[8];
yyinitdebug(yya, 8);
#endif
{
#line 153 ".\\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 481 "parse.c"
}
}
break;
case 20:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[7];
yyinitdebug(yya, 7);
#endif
{
#line 160 ".\\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 499 "parse.c"
}
}
break;
case 21:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 168 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 512 "parse.c"
}
}
break;
case 22:
{
#line 170 ".\\parse.y"
yyval.ptree = NULL;
#line 520 "parse.c"
}
break;
case 23:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 173 ".\\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 539 "parse.c"
}
}
break;
case 24:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 182 ".\\parse.y"
yyval.ptree = yyattribute(1 - 1).ptree;
#line 552 "parse.c"
}
}
break;
case 25:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 185 ".\\parse.y"
yyval.ptree = newDecNode(ParamK);
yyval.ptree -> type = yyattribute(1 - 1).type;
#line 567 "parse.c"
}
}
break;
case 26:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[3];
yyinitdebug(yya, 3);
#endif
{
#line 189 ".\\parse.y"
yyval.ptree = newDecNode(ParamK);
yyval.ptree -> type = yyattribute(1 - 2).type;
yyval.ptree -> attr.name = savedIdName;
#line 583 "parse.c"
}
}
break;
case 27:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[5];
yyinitdebug(yya, 5);
#endif
{
#line 195 ".\\parse.y"
yyval.ptree = newDecNode(CompK);
yyval.ptree -> child[0] = yyattribute(2 - 4).ptree;
yyval.ptree -> child[1] = yyattribute(3 - 4).ptree;
#line 599 "parse.c"
}
}
break;
case 28:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[3];
yyinitdebug(yya, 3);
#endif
{
#line 201 ".\\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 619 "parse.c"
}
}
break;
case 29:
{
#line 210 ".\\parse.y"
yyval.ptree = NULL;
#line 627 "parse.c"
}
break;
case 30:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[3];
yyinitdebug(yya, 3);
#endif
{
#line 213 ".\\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 646 "parse.c"
}
}
break;
case 31:
{
#line 222 ".\\parse.y"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -