📄 pl3.tab.c
字号:
/* A Bison parser, made from pl3.y
by GNU bison 1.35. */
#define YYBISON 1 /* Identify Bison output. */
# define BEGINSYM 257
# define ENDSYM 258
# define CONST 259
# define VAR 260
# define PROCEDURE 261
# define REPEAT 262
# define UNTIL 263
# define WHILE 264
# define CALL 265
# define DO 266
# define READ 267
# define WRITE 268
# define COLEQ 269
# define ODD 270
# define LEGAL_ID 271
# define NUMBER 272
# define LE 273
# define RE 274
# define IF 275
# define THEN 276
# define ELSE 277
#line 1 "pl3.y"
#ifndef YYSTYPE
typedef union{
char *name;
int value;
int val;
} yystype;
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#line 7 "pl3.y"
void yyerror(char *str);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <memory.h>
#include "define.h"
extern int yylex();
extern int lineno;
yyltype my_yylloc;
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#define YYFINAL 141
#define YYFLAG -32768
#define YYNTBASE 38
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 277 ? yytranslate[x] : 76)
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
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, 2, 2, 37, 2, 2, 2, 2,
32, 33, 25, 22, 30, 23, 28, 26, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 34, 29,
35, 31, 36, 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, 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, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 24, 27
};
#if YYDEBUG
static const short yyprhs[] =
{
0, 0, 3, 4, 5, 13, 17, 18, 22, 24,
28, 32, 33, 35, 39, 41, 46, 50, 52, 54,
60, 61, 62, 66, 67, 74, 76, 80, 82, 83,
84, 85, 87, 89, 93, 102, 106, 110, 115, 120,
127, 133, 134, 140, 149, 156, 158, 162, 163, 167,
169, 174, 176, 180, 182, 186, 188, 192, 195, 199,
201, 203, 205, 207, 209, 211, 214, 218, 220, 222,
223, 225, 227, 229, 231, 233, 237, 239, 241
};
static const short yyrhs[] =
{
39, 28, 0, 0, 0, 56, 40, 42, 45, 50,
41, 59, 0, 5, 43, 29, 0, 0, 43, 30,
44, 0, 44, 0, 55, 31, 18, 0, 6, 46,
29, 0, 0, 47, 0, 46, 30, 47, 0, 55,
0, 55, 32, 48, 33, 0, 49, 34, 49, 0,
55, 0, 18, 0, 50, 7, 51, 39, 29, 0,
0, 0, 55, 52, 29, 0, 0, 55, 53, 32,
54, 33, 29, 0, 55, 0, 54, 30, 55, 0,
17, 0, 0, 0, 0, 60, 0, 61, 0, 64,
15, 70, 0, 21, 68, 24, 57, 60, 58, 27,
60, 0, 3, 62, 4, 0, 11, 55, 63, 0,
13, 32, 65, 33, 0, 14, 32, 67, 33, 0,
10, 56, 68, 57, 12, 60, 0, 8, 56, 59,
9, 68, 0, 0, 21, 68, 24, 57, 59, 0,
21, 68, 24, 57, 60, 58, 27, 61, 0, 10,
56, 68, 57, 12, 61, 0, 59, 0, 62, 29,
59, 0, 0, 32, 66, 33, 0, 55, 0, 55,
32, 70, 33, 0, 64, 0, 65, 30, 64, 0,
70, 0, 66, 30, 70, 0, 70, 0, 67, 30,
70, 0, 16, 70, 0, 70, 69, 70, 0, 31,
0, 35, 0, 36, 0, 37, 0, 19, 0, 20,
0, 71, 74, 0, 70, 72, 74, 0, 22, 0,
23, 0, 0, 22, 0, 23, 0, 25, 0, 26,
0, 75, 0, 74, 73, 75, 0, 64, 0, 18,
0, 32, 70, 33, 0
};
#endif
#if YYDEBUG
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
0, 33, 36, 36, 36, 41, 43, 45, 47, 49,
53, 55, 57, 59, 61, 63, 65, 68, 70, 73,
75, 77, 77, 79, 79, 81, 83, 85, 89, 92,
95, 99, 101, 103, 105, 106, 107, 108, 109, 110,
111, 112, 114, 116, 117, 120, 122, 125, 127, 130,
132, 134, 136, 139, 141, 144, 146, 149, 151, 153,
155, 156, 157, 158, 159, 162, 164, 167, 169, 170,
172, 174, 176, 178, 180, 182, 184, 186, 187
};
#endif
#if (YYDEBUG) || defined YYERROR_VERBOSE
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
"$", "error", "$undefined.", "BEGINSYM", "ENDSYM", "CONST", "VAR",
"PROCEDURE", "REPEAT", "UNTIL", "WHILE", "CALL", "DO", "READ", "WRITE",
"COLEQ", "ODD", "LEGAL_ID", "NUMBER", "LE", "RE", "IF", "'+'", "'-'",
"THEN", "'*'", "'/'", "ELSE", "'.'", "';'", "','", "'='", "'('", "')'",
"':'", "'<'", "'>'", "'#'", "program", "subprogram", "@1", "@2",
"const_dec", "const_dec_list", "const_def", "var_dec", "var_dec_list",
"var_def", "bound_pair", "array_bound", "procedure_dec",
"procedure_head", "@3", "@4", "para_list", "id", "tmp_cx", "tmp_jpc",
"tmp_else", "statement", "Cstmt", "Ostmt", "statement_list",
"arguments", "var_ref", "read_list", "expression_list", "write_list",
"cond", "relation_opr", "expression", "sign", "add_opr", "multi_opr",
"term", "factor", 0
};
#endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
0, 38, 40, 41, 39, 42, 42, 43, 43, 44,
45, 45, 46, 46, 47, 47, 48, 49, 49, 50,
50, 52, 51, 53, 51, 54, 54, 55, 56, 57,
58, 59, 59, 60, 60, 60, 60, 60, 60, 60,
60, 60, 61, 61, 61, 62, 62, 63, 63, 64,
64, 65, 65, 66, 66, 67, 67, 68, 68, 69,
69, 69, 69, 69, 69, 70, 70, 71, 71, 71,
72, 72, 73, 73, 74, 74, 75, 75, 75
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
0, 2, 0, 0, 7, 3, 0, 3, 1, 3,
3, 0, 1, 3, 1, 4, 3, 1, 1, 5,
0, 0, 3, 0, 6, 1, 3, 1, 0, 0,
0, 1, 1, 3, 8, 3, 3, 4, 4, 6,
5, 0, 5, 8, 6, 1, 3, 0, 3, 1,
4, 1, 3, 1, 3, 1, 3, 2, 3, 1,
1, 1, 1, 1, 1, 2, 3, 1, 1, 0,
1, 1, 1, 1, 1, 3, 1, 1, 3
};
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
doesn't specify something else to do. Zero means the default is an
error. */
static const short yydefact[] =
{
28, 0, 2, 1, 6, 0, 11, 27, 0, 8,
0, 0, 20, 5, 0, 0, 0, 12, 14, 3,
7, 9, 10, 0, 0, 0, 41, 13, 18, 0,
0, 17, 28, 21, 41, 28, 28, 0, 0, 0,
69, 49, 4, 31, 32, 0, 15, 0, 0, 0,
0, 45, 0, 41, 69, 47, 0, 69, 69, 67,
68, 0, 0, 0, 69, 69, 16, 19, 22, 0,
35, 41, 0, 29, 69, 36, 51, 0, 0, 55,
57, 29, 63, 64, 70, 71, 59, 60, 61, 62,
69, 0, 77, 69, 76, 65, 74, 0, 33, 0,
25, 46, 69, 0, 0, 53, 0, 37, 69, 38,
41, 58, 66, 0, 72, 73, 0, 50, 0, 0,
40, 41, 69, 48, 52, 56, 42, 31, 78, 75,
26, 24, 39, 44, 54, 0, 41, 34, 43, 0,
0, 0
};
static const short yydefgoto[] =
{
139, 1, 4, 26, 6, 8, 9, 12, 16, 17,
29, 30, 19, 32, 49, 50, 99, 41, 2, 103,
135, 42, 43, 44, 52, 75, 45, 77, 104, 78,
61, 90, 62, 63, 91, 116, 95, 96
};
static const short yypact[] =
{
-32768, -23,-32768,-32768, 12, 9, 85,-32768, 41,-32768,
21, 9,-32768,-32768, 9, 39, 52,-32768, 60, 86,
-32768,-32768,-32768, 9, 58, 9, 20,-32768,-32768, 64,
65,-32768,-32768, 66, 20,-32768,-32768, 9, 68, 69,
51, 70,-32768,-32768,-32768, 79,-32768, 58, 67, 74,
72,-32768, 0, 20, 51, 73, 9, 61, 61,-32768,
-32768, 71, 25, 18, 61, 61,-32768,-32768,-32768, 9,
-32768, 20, 97,-32768, 61,-32768,-32768, -17, -8, 63,
63,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
61, 18,-32768, 61,-32768, 62,-32768, 32, 63, 16,
-32768,-32768, 51, 95, 47, 63, 9,-32768, 61,-32768,
20, 63, 62, 46,-32768,-32768, 18,-32768, 9, 80,
-32768, 20, 61,-32768,-32768, 63,-32768, 81,-32768,-32768,
-32768,-32768,-32768,-32768, 63, 83, 20,-32768,-32768, 111,
112,-32768
};
static const short yypgoto[] =
{
-32768, 82,-32768,-32768,-32768,-32768, 101,-32768,-32768, 93,
-32768, 75,-32768,-32768,-32768,-32768,-32768, -5, 54, 36,
-32768, -32, -109, -70,-32768,-32768, -53,-32768,-32768,-32768,
-43,-32768, -50,-32768,-32768,-32768, 27, 3
};
#define YYLAST 122
static const short yytable[] =
{
10, 127, 51, 76, 70, 3, 18, 79, 80, 10,
94, 73, 132, 106, 97, 98, 107, 5, 18, 31,
33, 72, 108, 34, 105, 109, 7, 137, 35, 71,
36, 37, 55, 38, 39, 7, 92, 7, 94, 101,
111, 40, 31, 113, 82, 83, 118, 84, 85, 119,
93, 133, 15, 124, 84, 85, 86, 21, 125, 120,
87, 88, 89, 94, 100, 117, 138, 58, 84, 85,
13, 14, 134, 59, 60, 7, 28, 122, 126, 128,
123, 22, 23, 59, 60, 84, 85, 114, 115, 53,
54, 11, 24, 25, 65, 81, 67, 46, -23, 47,
56, 57, 64, 68, 69, 74, 102, 121, -30, 131,
136, 140, 141, 130, 48, 20, 27, 110, 112, 129,
0, 0, 66
};
static const short yycheck[] =
{
5, 110, 34, 56, 4, 28, 11, 57, 58, 14,
63, 54, 121, 30, 64, 65, 33, 5, 23, 24,
25, 53, 30, 3, 74, 33, 17, 136, 8, 29,
10, 11, 37, 13, 14, 17, 18, 17, 91, 71,
90, 21, 47, 93, 19, 20, 30, 22, 23, 33,
32, 121, 31, 106, 22, 23, 31, 18, 108, 102,
35, 36, 37, 116, 69, 33, 136, 16, 22, 23,
29, 30, 122, 22, 23, 17, 18, 30, 110, 33,
33, 29, 30, 22, 23, 22, 23, 25, 26, 35,
36, 6, 32, 7, 15, 24, 29, 33, 32, 34,
32, 32, 32, 29, 32, 32, 9, 12, 27, 29,
27, 0, 0, 118, 32, 14, 23, 81, 91, 116,
-1, -1, 47
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* This is the parser code that is written into each bison parser when
the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
/* The parser invokes alloca or malloc; define the necessary symbols. */
# if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
# else
# ifndef YYSTACK_USE_ALLOCA
# if defined (alloca) || defined (_ALLOCA_H)
# define YYSTACK_ALLOC alloca
# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
# define YYSTACK_ALLOC malloc
# define YYSTACK_FREE free
# endif
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
#if (! defined (yyoverflow) \
&& (! defined (__cplusplus) \
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
short yyss;
YYSTYPE yyvs;
# if YYLSP_NEEDED
YYLTYPE yyls;
# endif
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# if YYLSP_NEEDED
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAX)
# else
# define YYSTACK_BYTES(N) \
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAX)
# endif
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
register YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (0)
# endif
# endif
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ \
yyerror ("syntax error: cannot back up"); \
YYERROR; \
} \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
are run).
When YYLLOC_DEFAULT is run, CURRENT is set the location of the
first token. By default, to implement support for ranges, extend
its range to the last symbol. */
#ifndef YYLLOC_DEFAULT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -