📄 parser_tab.c
字号:
/* A Bison parser, made from parser.y with Bison version GNU Bison version 1.24
*/
#define YYBISON 1 /* Identify Bison output. */
#define YYLSP_NEEDED
#define T_Void 258
#define T_Bool 259
#define T_Int 260
#define T_Double 261
#define T_String 262
#define T_Class 263
#define T_LessEqual 264
#define T_GreaterEqual 265
#define T_Equal 266
#define T_NotEqual 267
#define T_And 268
#define T_Or 269
#define T_Null 270
#define T_Extends 271
#define T_This 272
#define T_While 273
#define T_For 274
#define T_If 275
#define T_Else 276
#define T_Return 277
#define T_Break 278
#define T_Identifier 279
#define T_StringConstant 280
#define T_IntConstant 281
#define T_DoubleConstant 282
#define T_BoolConstant 283
#define T_New 284
#define T_NewArray 285
#define T_Print 286
#define T_ReadInteger 287
#define T_ReadLine 288
#define T_UnaryMinus 289
#define T_Lower_Than_Else 290
#line 8 "parser.y"
#include "scanner.h" // for yylex
#include <stdio.h>
#include <stdlib.h>
#include "utility.h"
#include "errors.h"
#include "declaration.h"
#include "type.h"
#include "scope.h"
#include "semantic.h"
#include "codegen.h"
/* Global variables (for shame!)
* -----------------------------
* Having one or two globally accessible variables turns out to be handy
* since we don't have a way to pass parameters into yyparse(), so we
* allow ourselves the liberty of global access to our scope stack and
* code generator, which are needed everywhere.
*/
ScopeStack *scopes;
CodeGenerator *cg;
//存放被调用函数的链表
DeclList *FunUsedList;
int numerr=0;
#line 47 "parser.y"
typedef union {
int integerConstant;
bool boolConstant;
const char *stringConstant;
double doubleConstant;
char identifier[128];
Type *type;
Declaration *decl;
DeclList *declList;
char *label;
} YYSTYPE;
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#include <stdio.h>
#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif
#define YYFINAL 177
#define YYFLAG -32768
#define YYNTBASE 54
#define YYTRANSLATE(x) ((unsigned)(x) <= 290 ? yytranslate[x] : 97)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 42, 2, 2, 2, 40, 2, 2, 51,
46, 38, 36, 52, 37, 44, 39, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 47, 34,
53, 35, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
43, 2, 48, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 49, 2, 50, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 41, 45
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 2, 5, 6, 8, 10, 12, 14, 17, 20,
22, 24, 26, 28, 30, 33, 37, 38, 46, 49,
50, 53, 54, 56, 58, 60, 67, 69, 70, 74,
76, 77, 85, 86, 91, 94, 95, 97, 100, 102,
104, 106, 109, 111, 114, 116, 120, 122, 123, 126,
127, 130, 135, 141, 143, 145, 147, 151, 155, 159,
163, 167, 171, 175, 179, 183, 187, 191, 195, 199,
203, 206, 209, 213, 217, 219, 224, 231, 233, 235,
237, 239, 241, 243, 244, 248, 250, 252, 253, 254,
262, 263, 264, 265, 278, 281, 282, 283, 292, 295,
296, 299, 301
};
static const short yyrhs[] = { 55,
0, 55, 56, 0, 0, 60, 0, 68, 0, 65,
0, 57, 0, 58, 47, 0, 59, 24, 0, 5,
0, 3, 0, 4, 0, 7, 0, 6, 0, 8,
24, 0, 59, 43, 48, 0, 0, 8, 24, 62,
61, 49, 63, 50, 0, 16, 24, 0, 0, 63,
64, 0, 0, 57, 0, 68, 0, 65, 0, 59,
24, 51, 66, 46, 47, 0, 67, 0, 0, 67,
52, 58, 0, 58, 0, 0, 59, 24, 51, 66,
46, 69, 70, 0, 0, 49, 71, 72, 50, 0,
72, 73, 0, 0, 57, 0, 74, 47, 0, 91,
0, 83, 0, 86, 0, 95, 47, 0, 70, 0,
96, 47, 0, 90, 0, 76, 53, 78, 0, 78,
0, 0, 78, 44, 0, 0, 75, 24, 0, 78,
43, 78, 48, 0, 75, 24, 51, 80, 46, 0,
76, 0, 77, 0, 79, 0, 78, 36, 78, 0,
78, 37, 78, 0, 78, 39, 78, 0, 78, 38,
78, 0, 78, 40, 78, 0, 78, 11, 78, 0,
78, 12, 78, 0, 78, 34, 78, 0, 78, 35,
78, 0, 78, 9, 78, 0, 78, 10, 78, 0,
78, 13, 78, 0, 78, 14, 78, 0, 51, 78,
46, 0, 37, 78, 0, 42, 78, 0, 32, 51,
46, 0, 33, 51, 46, 0, 17, 0, 29, 51,
24, 46, 0, 30, 51, 78, 52, 59, 46, 0,
26, 0, 28, 0, 27, 0, 25, 0, 15, 0,
81, 0, 0, 81, 52, 78, 0, 78, 0, 78,
0, 0, 0, 18, 84, 51, 82, 46, 85, 73,
0, 0, 0, 0, 19, 51, 74, 47, 87, 82,
47, 88, 74, 89, 46, 73, 0, 23, 47, 0,
0, 0, 20, 51, 82, 46, 92, 73, 93, 94,
0, 21, 73, 0, 0, 22, 78, 0, 22, 0,
31, 51, 81, 46, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
112, 168, 170, 174, 175, 176, 177, 180, 212, 221,
223, 225, 227, 229, 231, 233, 237, 292, 340, 342,
346, 348, 352, 354, 356, 360, 389, 391, 395, 397,
404, 479, 493, 497, 501, 502, 505, 507, 508, 509,
510, 511, 512, 513, 514, 517, 546, 551, 555, 560,
564, 569, 576, 583, 594, 598, 599, 601, 603, 605,
607, 609, 631, 661, 665, 667, 674, 681, 683, 685,
687, 693, 699, 703, 707, 711, 720, 750, 752, 754,
756, 758, 762, 764, 768, 770, 774, 778, 787, 793,
803, 813, 820, 826, 834, 841, 847, 853, 858, 859,
862, 870, 878
};
static const char * const yytname[] = { "$","error","$undefined.","T_Void",
"T_Bool","T_Int","T_Double","T_String","T_Class","T_LessEqual","T_GreaterEqual",
"T_Equal","T_NotEqual","T_And","T_Or","T_Null","T_Extends","T_This","T_While",
"T_For","T_If","T_Else","T_Return","T_Break","T_Identifier","T_StringConstant",
"T_IntConstant","T_DoubleConstant","T_BoolConstant","T_New","T_NewArray","T_Print",
"T_ReadInteger","T_ReadLine","'<'","'>'","'+'","'-'","'*'","'/'","'%'","T_UnaryMinus",
"'!'","'['","'.'","T_Lower_Than_Else","')'","';'","']'","'{'","'}'","'('","','",
"'='","Program","DeclList","Decl","VariableDecl","Variable","Type","ClassDefn",
"@1","OptExtends","FieldList","Field","FunctionDecl","Formals","VariableList",
"FunctionDefn","@2","StmtBlock","@3","StmtList","Stmt","SimpleStmt","OptReceiver",
"LValue","Call","Expr","Constant","Actuals","ExprList","BoolExpr","WhileStmt",
"@4","@5","ForStmt","@6","@7","@8","BreakStmt","IfStmt","@9","@10","OptElse",
"ReturnStmt","PrintStmt",""
};
#endif
static const short yyr1[] = { 0,
54, 55, 55, 56, 56, 56, 56, 57, 58, 59,
59, 59, 59, 59, 59, 59, 61, 60, 62, 62,
63, 63, 64, 64, 64, 65, 66, 66, 67, 67,
69, 68, 71, 70, 72, 72, 73, 73, 73, 73,
73, 73, 73, 73, 73, 74, 74, 74, 75, 75,
76, 76, 77, 78, 78, 78, 78, 78, 78, 78,
78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
78, 78, 78, 78, 78, 78, 78, 79, 79, 79,
79, 79, 80, 80, 81, 81, 82, 84, 85, 83,
87, 88, 89, 86, 90, 92, 93, 91, 94, 94,
95, 95, 96
};
static const short yyr2[] = { 0,
1, 2, 0, 1, 1, 1, 1, 2, 2, 1,
1, 1, 1, 1, 2, 3, 0, 7, 2, 0,
2, 0, 1, 1, 1, 6, 1, 0, 3, 1,
0, 7, 0, 4, 2, 0, 1, 2, 1, 1,
1, 2, 1, 2, 1, 3, 1, 0, 2, 0,
2, 4, 5, 1, 1, 1, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 3, 3, 1, 4, 6, 1, 1, 1,
1, 1, 1, 0, 3, 1, 1, 0, 0, 7,
0, 0, 0, 12, 2, 0, 0, 8, 2, 0,
2, 1, 4
};
static const short yydefact[] = { 3,
1, 11, 12, 10, 14, 13, 0, 2, 7, 0,
0, 4, 6, 5, 15, 8, 9, 0, 0, 17,
28, 16, 19, 0, 0, 30, 0, 0, 27, 22,
15, 9, 31, 0, 0, 26, 0, 29, 18, 23,
21, 25, 24, 33, 32, 36, 48, 82, 75, 88,
0, 0, 50, 0, 81, 78, 80, 79, 0, 0,
0, 0, 0, 50, 50, 34, 50, 37, 43, 35,
0, 0, 54, 55, 47, 56, 40, 41, 45, 39,
0, 0, 0, 48, 50, 54, 101, 95, 0, 50,
50, 0, 0, 71, 72, 0, 38, 51, 50, 50,
50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
50, 50, 50, 49, 42, 44, 50, 0, 87, 0,
0, 0, 86, 0, 73, 74, 70, 50, 46, 66,
67, 62, 63, 68, 69, 64, 65, 57, 58, 60,
59, 61, 0, 0, 91, 96, 76, 0, 103, 50,
0, 83, 52, 89, 50, 48, 0, 85, 53, 48,
0, 97, 77, 90, 92, 100, 48, 48, 98, 93,
99, 0, 48, 94, 0, 0, 0
};
static const short yydefgoto[] = { 175,
1, 8, 68, 10, 27, 12, 24, 20, 35, 41,
13, 28, 29, 14, 37, 69, 46, 47, 70, 71,
72, 86, 74, 75, 76, 151, 124, 120, 77, 83,
160, 78, 155, 167, 172, 79, 80, 156, 166, 169,
81, 82
};
static const short yypact[] = {-32768,
83,-32768,-32768,-32768,-32768,-32768, -15,-32768,-32768, -34,
-18,-32768,-32768,-32768, -6,-32768, -23, -16, 6,-32768,
112,-32768,-32768, -4, 22,-32768, -17, 1, 12,-32768,
-32768,-32768, 19, 112, 15,-32768, 28,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768, 126,-32768,-32768,-32768,
-3, 30, 245, 35,-32768,-32768,-32768,-32768, 32, 33,
41, 50, 53, 329, 329,-32768, 329,-32768,-32768,-32768,
60, 82, 55,-32768, 363,-32768,-32768,-32768,-32768,-32768,
62, 65, 72, 273, 329,-32768, 363,-32768, 89, 329,
329, 78, 79, -7, -7, 215,-32768, 75, 329, 329,
329, 329, 329, 329, 329, 329, 329, 329, 329, 329,
329, 329, 329,-32768,-32768,-32768, 329, 81, 363, 90,
91, 59, 363, -19,-32768,-32768,-32768, 301, 363, 432,
432, 410, 410, 421, 374, 432, 432, 36, 36, -7,
-7, -7, 200, 92,-32768,-32768,-32768, 112,-32768, 329,
93, 88,-32768,-32768, 329, 166, -35, 363,-32768, 166,
95,-32768,-32768,-32768,-32768, 114, 273, 166,-32768,-32768,
-32768, 115, 166,-32768, 160, 162,-32768
};
static const short yypgoto[] = {-32768,
-32768,-32768, 4, 10, -1,-32768,-32768,-32768,-32768,-32768,
129,-32768,-32768, 130,-32768, 141,-32768,-32768, -144, -82,
-32768, -46,-32768, -50,-32768,-32768, 38, -113,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768
};
#define YYLAST 476
static const short yytable[] = { 11,
73, 118, 87, 144, 9, 17, 32, 18, 15, 19,
163, 162, 16, 94, 95, 164, 96, 2, 3, 4,
5, 6, 25, 171, 18, 18, 149, 21, 174, 23,
26, 22, 150, 11, 119, 113, 114, 73, 40, 122,
123, 161, -20, 38, 30, 31, 33, 84, 129, 130,
131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 34, 39, 36, 119, 100, 101, 102,
103, 104, 105, 110, 111, 112, 44, 123, 113, 114,
85, 88, 89, 90, 170, 2, 3, 4, 5, 6,
7, 91, 106, 107, 108, 109, 110, 111, 112, 158,
92, 113, 114, 93, 119, 98, 97, 99, 115, 73,
148, 116, 121, 73, 2, 3, 4, 5, 6, 25,
73, 73, 117, 125, 126, 128, 73, 145, 2, 3,
4, 5, 6, 25, 168, 146, 147, 154, 159, 150,
48, 165, 49, 50, 51, 52, 157, 53, 54, -50,
55, 56, 57, 58, 59, 60, 61, 62, 63, 176,
173, 177, 64, 42, 43, 152, 0, 65, 2, 3,
4, 5, 6, 25, 44, 66, 67, 45, 0, 0,
48, 0, 49, 50, 51, 52, 0, 53, 54, -50,
55, 56, 57, 58, 59, 60, 61, 62, 63, 0,
0, 0, 64, 0, 0, 0, 0, 65, 100, 101,
102, 103, 104, 105, 44, 0, 67, 0, 0, 0,
0, 0, 0, 100, 101, 102, 103, 104, 105, 0,
0, 0, 0, 106, 107, 108, 109, 110, 111, 112,
0, 0, 113, 114, 0, 0, 0, 153, 106, 107,
108, 109, 110, 111, 112, 0, 0, 113, 114, 48,
127, 49, 0, 0, 0, 0, 0, 0, 0, 55,
56, 57, 58, 59, 60, 0, 62, 63, 0, 0,
0, 64, 0, 0, 0, 0, 65, 48, 0, 49,
0, -102, 0, 0, 0, 67, -50, 55, 56, 57,
58, 59, 60, 0, 62, 63, 0, 0, 0, 64,
0, 0, 0, 0, 65, 48, 0, 49, 0, 0,
0, 0, 0, 67, 0, 55, 56, 57, 58, 59,
60, 0, 62, 63, 0, 0, 0, 64, 0, 0,
0, 0, 65, 48, 0, 49, -84, 0, 0, 0,
0, 67, 0, 55, 56, 57, 58, 59, 60, 0,
62, 63, 0, 0, 0, 64, 0, 0, 0, 0,
65, 100, 101, 102, 103, 104, 105, 0, 0, 67,
0, 0, 100, 101, 102, 103, 104, 0, 0, 0,
0, 0, 0, 0, 0, 0, 106, 107, 108, 109,
110, 111, 112, 0, 0, 113, 114, 106, 107, 108,
109, 110, 111, 112, 0, 0, 113, 114, 100, 101,
-32768,-32768, 0, 0, 0, 0, 0, 0, 0, 100,
101, 102, 103, 0, 0, 0, 0, 0, 0, 0,
-32768,-32768, 0, 106, 107, 108, 109, 110, 111, 112,
0, 0, 113, 114, 106, 107, 108, 109, 110, 111,
112, 0, 0, 113, 114,-32768,-32768, 108, 109, 110,
111, 112, 0, 0, 113, 114
};
static const short yycheck[] = { 1,
47, 84, 53, 117, 1, 24, 24, 43, 24, 16,
46, 156, 47, 64, 65, 160, 67, 3, 4, 5,
6, 7, 8, 168, 43, 43, 46, 51, 173, 24,
21, 48, 52, 35, 85, 43, 44, 84, 35, 90,
91, 155, 49, 34, 49, 24, 46, 51, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 52, 50, 47, 117, 9, 10, 11,
12, 13, 14, 38, 39, 40, 49, 128, 43, 44,
51, 47, 51, 51, 167, 3, 4, 5, 6, 7,
8, 51, 34, 35, 36, 37, 38, 39, 40, 150,
51, 43, 44, 51, 155, 24, 47, 53, 47, 156,
52, 47, 24, 160, 3, 4, 5, 6, 7, 8,
167, 168, 51, 46, 46, 51, 173, 47, 3, 4,
5, 6, 7, 8, 21, 46, 46, 46, 46, 52,
15, 47, 17, 18, 19, 20, 148, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 0,
46, 0, 37, 35, 35, 128, -1, 42, 3, 4,
5, 6, 7, 8, 49, 50, 51, 37, -1, -1,
15, -1, 17, 18, 19, 20, -1, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, -1,
-1, -1, 37, -1, -1, -1, -1, 42, 9, 10,
11, 12, 13, 14, 49, -1, 51, -1, -1, -1,
-1, -1, -1, 9, 10, 11, 12, 13, 14, -1,
-1, -1, -1, 34, 35, 36, 37, 38, 39, 40,
-1, -1, 43, 44, -1, -1, -1, 48, 34, 35,
36, 37, 38, 39, 40, -1, -1, 43, 44, 15,
46, 17, -1, -1, -1, -1, -1, -1, -1, 25,
26, 27, 28, 29, 30, -1, 32, 33, -1, -1,
-1, 37, -1, -1, -1, -1, 42, 15, -1, 17,
-1, 47, -1, -1, -1, 51, 24, 25, 26, 27,
28, 29, 30, -1, 32, 33, -1, -1, -1, 37,
-1, -1, -1, -1, 42, 15, -1, 17, -1, -1,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -