📄 myparser.c
字号:
/****************************************************************************
* U N R E G I S T E R E D C O P Y
*
* You are on day 63 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.
****************************************************************************/
/****************************************************************************
* myparser.c
* C source file generated from myparser.y.
*
* Date: 01/03/08
* Time: 20:58:04
*
* 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 ".\\myparser.y"
/************************7****************************************************
myparser.y
ParserWizard generated YACC file.
Date: 2007年12月13日
****************************************************************************/
#include <stdio.h>
#include "mylexer.h"
#include "systab.h"
int total=0;
int label=0;
typedef struct treeNode
{
struct treeNode * child[3];
struct treeNode * sibling;
int lineno;
int val;
int count;
int nodekind;
int kind;
int op;
char name[255];
} TreeNode;
static TreeNode * savedTree;
FILE *out ;
#define IfK 10
#define AssignK 11
#define IDk 9
#define Constk 8
#define Exprk 7
#define Termk 6
#define Repk 12
#define Com 5
#define Vark 4
#define Typek 3
#define Prink 13
#define Inputk 14
#define StmtKind 1
#define ExprKind 2
#define IDk1 15
#define YYSTYPE TreeNode *
static void cGen( TreeNode * tree);
void genExp(TreeNode * root);
YYSTYPE newStmNode(int,int);
//YYSTYPE newIDNode(int kind,int count,char* string);
//YYSTYPE newNUMNode(int kind,int count,int val);
YYSTYPE newExprNode(int kind,int count);
#line 92 "myparser.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 ".\myparser.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[5];
yyinitdebug(yya, 5);
#endif
{
#line 83 ".\\myparser.y"
savedTree = yyattribute(4 - 4);
#line 220 "myparser.c"
}
}
break;
case 1:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 94 ".\\myparser.y"
++total;//printf("%d: Var Declaration \n",total);
yyval = newStmNode(Vark,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(2 - 3);
#line 238 "myparser.c"
}
}
break;
case 2:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 102 ".\\myparser.y"
yyval = yyattribute(1 - 1); fprintf(out," %s DWORD 0\n",yyval->name);
#line 251 "myparser.c"
}
}
break;
case 3:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 104 ".\\myparser.y"
YYSTYPE t = yyattribute(1 - 3);
if (t != NULL)
{
while (t->sibling != NULL)
t = t->sibling;
t->sibling = yyattribute(3 - 3);
yyval = yyattribute(1 - 3);
}
else yyval = yyattribute(3 - 3);
fprintf(out," %s DWORD 0\n",yyattribute(3 - 3)->name);
#line 275 "myparser.c"
}
}
break;
case 4:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[5];
yyinitdebug(yya, 5);
#endif
{
#line 120 ".\\myparser.y"
++total;//printf("%d: Assign Statement \n",total );
yyval = newStmNode(AssignK,total);
yyval->child[0] = yyattribute(1 - 4);
yyval->child[1] = yyattribute(3 - 4);
#line 292 "myparser.c"
}
}
break;
case 5:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 128 ".\\myparser.y"
++total;//printf("%d: If Statement \n",total);
yyval = newStmNode(IfK,total);
yyval->child[0] = yyattribute(3 - 5);
yyval->child[1] = yyattribute(5 - 5);
#line 309 "myparser.c"
}
}
break;
case 6:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 136 ".\\myparser.y"
++total;//printf("%d: If Statement \n",total);
yyval = newStmNode(Repk,total);
yyval->child[0] = yyattribute(3 - 5);
yyval->child[1] = yyattribute(5 - 5);
#line 327 "myparser.c"
}
}
break;
case 7:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 143 ".\\myparser.y"
++total;//printf("%d: If Statement \n",total);
yyval = newStmNode(Repk,total);
yyval->child[0] = yyattribute(3 - 5);
yyval->child[1] = yyattribute(5 - 5);
#line 345 "myparser.c"
}
}
break;
case 8:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 152 ".\\myparser.y"
++total;
yyval = newStmNode(Prink,total);
yyval->child[0]=yyattribute(3 - 5);
#line 362 "myparser.c"
}
}
break;
case 9:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[6];
yyinitdebug(yya, 6);
#endif
{
#line 160 ".\\myparser.y"
++total;
yyval = newStmNode(Inputk,total);
yyval->child[0]=yyattribute(3 - 5);
#line 379 "myparser.c"
}
}
break;
case 10:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 168 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 392 "myparser.c"
}
}
break;
case 11:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 169 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 405 "myparser.c"
}
}
break;
case 12:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 170 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 418 "myparser.c"
}
}
break;
case 13:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 171 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 431 "myparser.c"
}
}
break;
case 14:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 172 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 444 "myparser.c"
}
}
break;
case 15:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 173 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 457 "myparser.c"
}
}
break;
case 16:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 174 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 470 "myparser.c"
}
}
break;
case 17:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 177 ".\\myparser.y"
yyval = yyattribute(1 - 1);
#line 483 "myparser.c"
}
}
break;
case 18:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[3];
yyinitdebug(yya, 3);
#endif
{
#line 179 ".\\myparser.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 506 "myparser.c"
}
}
break;
case 19:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 195 ".\\myparser.y"
++total;
yyval=newStmNode(Com,total);
yyval->child[0]=yyattribute(2 - 3);
#line 523 "myparser.c"
}
}
break;
case 20:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 202 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(3 - 3);
// printf("*************\n");
yyval->op= AND;
#line 543 "myparser.c"
}
}
break;
case 21:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 211 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(3 - 3);
yyval->op = OR;
#line 562 "myparser.c"
}
}
break;
case 22:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[2];
yyinitdebug(yya, 2);
#endif
{
#line 218 ".\\myparser.y"
yyval=yyattribute(1 - 1);
#line 577 "myparser.c"
}
}
break;
case 23:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 222 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(3 - 3);
// printf("*************\n");
yyval->op= LT;
#line 597 "myparser.c"
}
}
break;
case 24:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 230 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(3 - 3);
// printf("*************\n");
yyval->op= EQ_OP;
#line 617 "myparser.c"
}
}
break;
case 25:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 239 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
yyval->child[1] = yyattribute(3 - 3);
// printf("*************\n");
yyval->op = GT;
#line 637 "myparser.c"
}
}
break;
case 26:
{
#ifdef YYDEBUG
YYSTYPE YYFAR *yya[4];
yyinitdebug(yya, 4);
#endif
{
#line 247 ".\\myparser.y"
++total;
yyval=newExprNode(Exprk,total);
yyval->child[0] = yyattribute(1 - 3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -