GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/m4/parser.c Lines: 83 139 59.7 %
Date: 2017-11-07 Branches: 46 128 35.9 %

Line Branch Exec Source
1
#include <stdlib.h>
2
#include <string.h>
3
#define YYBYACC 1
4
#define YYMAJOR 1
5
#define YYMINOR 9
6
#define YYLEX yylex()
7
#define YYEMPTY -1
8
#define yyclearin (yychar=(YYEMPTY))
9
#define yyerrok (yyerrflag=0)
10
#define YYRECOVERING() (yyerrflag!=0)
11
#define YYPREFIX "yy"
12
#line 2 "parser.y"
13
/* $OpenBSD: parser.y,v 1.7 2012/04/12 17:00:11 espie Exp $ */
14
/*
15
 * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
16
 *
17
 * Permission to use, copy, modify, and distribute this software for any
18
 * purpose with or without fee is hereby granted, provided that the above
19
 * copyright notice and this permission notice appear in all copies.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
22
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
23
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
24
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
27
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28
 */
29
#include <math.h>
30
#include <stdint.h>
31
#define YYSTYPE	int32_t
32
extern int32_t end_result;
33
extern int yylex(void);
34
extern int yyerror(const char *);
35
#line 36 "parser.c"
36
#define NUMBER 257
37
#define ERROR 258
38
#define LOR 259
39
#define LAND 260
40
#define EQ 261
41
#define NE 262
42
54
#define LE 263
43
54
#define GE 264
44
#define LSHIFT 265
45
#define RSHIFT 266
46
36
#define EXPONENT 267
47
45
#define UMINUS 268
48
9
#define UPLUS 269
49
#define YYERRCODE 256
50
const short yylhs[] =
51
	{                                        -1,
52
    0,    1,    1,    1,    1,    1,    1,    1,    1,    1,
53
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
54
    1,    1,    1,    1,    1,    1,
55
};
56
const short yylen[] =
57
	{                                         2,
58
    1,    3,    3,    3,    3,    3,    3,    3,    3,    3,
59
    3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
60
    3,    2,    2,    2,    2,    1,
61
};
62
const short yydefred[] =
63
	{                                      0,
64
   26,    0,    0,    0,    0,    0,    0,    0,   23,   22,
65
   24,   25,    0,    0,    0,    0,    0,    0,    0,    0,
66
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
67
    0,    0,   21,    0,    0,    0,    0,    0,    0,    0,
68
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
69
    0,    0,
70
9
};
71
9
const short yydgoto[] =
72
9
	{                                       7,
73
36
    8,
74
9
};
75
const short yysindex[] =
76
9
	{                                     95,
77
9
    0,   95,   95,   95,   95,   95,    0,  397,    0,    0,
78
    0,    0,  383,   95,   95,   95,   95,   95,   95,   95,
79
   95,   95,   95,   95,   95,   95,   95,   95,   95,   95,
80
   95,   95,    0,  428,  471,  482,  185,  437,  493,  493,
81
  -10,  -10,  -10,  -10,  -23,  -23,  -34,  -34, -267, -267,
82
 -267, -267,};
83
const short yyrindex[] =
84
	{                                      0,
85
    0,    0,    0,    0,    0,    0,    0,    2,    0,    0,
86
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
87
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
88
    0,    0,    0,   11,   62,   23,  101,  308,  201,  243,
89
  124,  130,  144,  155,   79,  116,   51,   67,    1,   12,
90
   28,   40,};
91
const short yygindex[] =
92
	{                                      0,
93
  582,
94
};
95
#define YYTABLESIZE 760
96
const short yytable[] =
97
	{                                      32,
98
    5,    1,   31,    0,    0,    0,    0,   29,    0,    0,
99
   20,    6,   30,   31,    0,    0,    0,    0,   29,   27,
100
    0,   28,   18,   30,    0,    0,   31,    7,    0,    0,
101
    0,   29,   27,    0,   28,    0,   30,    5,    5,    4,
102
    0,    5,    5,    5,    0,    5,    0,    5,    6,    6,
103
    2,   20,    6,    6,    6,    0,    6,    0,    6,    0,
104
    5,   19,    5,   18,    7,    7,    3,    0,    7,    7,
105
    7,    6,    7,    6,    7,    0,    4,    4,    8,    0,
106
    4,    4,    4,    0,    4,    0,    4,    7,    2,    7,
107
    0,    2,    0,    2,    5,    2,    0,    0,    0,    4,
108
   17,    4,   19,    0,    3,    6,    0,    3,    0,    3,
109
    2,    3,    2,    0,    0,    9,    8,    0,    0,    8,
110
    0,    7,    0,   10,    5,    0,    3,    4,    3,   12,
111
    0,    0,    0,    4,    6,    6,    0,    2,    8,    3,
112
    8,   17,    0,   11,    2,    0,   18,    0,    0,    0,
113
    0,    7,    0,    9,   13,    0,    9,    0,    0,    0,
114
    3,   10,    0,    4,   10,    0,    0,   12,    0,    0,
115
   12,    0,    8,    0,    2,    9,    0,    9,    0,    0,
116
    0,   11,    0,   10,   11,   10,    0,    0,    0,   12,
117
    3,   12,   13,    0,   17,   13,    0,    0,    0,    0,
118
   14,    0,    8,   11,    0,   11,    0,    0,    0,    9,
119
    0,    0,    0,    0,   13,    0,   13,   10,    0,    0,
120
    5,   31,   18,   12,   17,    0,   29,   27,    0,   28,
121
    0,   30,   32,    0,    0,    0,    0,   11,   14,    9,
122
    0,   14,   15,   32,   21,    0,   23,   10,   13,    0,
123
    0,    0,    0,   12,   25,   26,   32,    0,    0,    5,
124
    5,    5,    5,    5,    5,    5,    5,   11,    0,   20,
125
    6,    6,    6,    6,    6,    6,    6,    6,   13,    0,
126
   15,   18,   18,   15,    0,    0,    7,    7,    7,    7,
127
    7,    7,    7,    7,   14,    0,    0,    0,    4,    4,
128
    4,    4,    4,    4,    4,    4,    0,   16,    0,    2,
129
    2,    2,    2,    2,    2,    2,    2,    0,    0,    0,
130
   19,   19,    0,    0,   14,    3,    3,    3,    3,    3,
131
    3,    3,    3,    0,    0,    0,   15,    8,    8,    8,
132
    8,    8,    8,    8,    8,   16,    0,    0,   16,    0,
133
    0,    1,    0,    0,    0,    0,    0,    0,    0,   17,
134
   17,    0,    0,    0,    0,    0,   15,    0,    0,    0,
135
    0,    0,    0,    0,    9,    9,    9,    9,    9,    9,
136
    9,    9,   10,   10,   10,   10,   10,   10,   12,   12,
137
   12,   12,   12,   12,    0,    0,    0,    0,    0,    0,
138
    0,   16,   11,   11,   11,   11,   11,   11,    0,    0,
139
    0,    0,    0,   13,   13,   13,   13,   13,   13,   31,
140
   18,    0,    0,   33,   29,   27,    0,   28,    0,   30,
141
    0,   16,    0,   31,   18,    0,    0,    0,   29,   27,
142
    0,   28,   21,   30,   23,   19,   20,   22,   24,   25,
143
   26,   32,    0,    0,    0,    0,   21,    0,   23,   14,
144
   14,   14,   14,    0,   31,   18,    0,    0,    0,   29,
145
   27,    0,   28,   31,   30,    0,   17,    0,   29,   27,
146
    0,   28,    0,   30,    0,    0,    0,   21,    0,   23,
147
   17,    0,    0,    0,    0,    0,   21,    0,   23,    0,
148
    0,   15,   15,   15,   15,    0,   16,   31,   18,    0,
149
    0,    0,   29,   27,    0,   28,    0,   30,   31,   18,
150
   16,   17,    0,   29,   27,    0,   28,    0,   30,   31,
151
   21,    0,   23,    0,   29,   27,    0,   28,    0,   30,
152
    0,   21,    0,   23,    0,    0,    0,    0,    0,    0,
153
    0,   16,   21,    0,   23,    0,    0,    0,    0,    0,
154
    0,    0,    0,    0,   17,    0,   16,   16,    0,    0,
155
    0,    0,    0,    0,    0,   17,    0,    0,    0,    0,
156
    0,    0,    0,    9,   10,   11,   12,   13,    0,    0,
157
    0,    0,    0,    0,   16,   34,   35,   36,   37,   38,
158
   39,   40,   41,   42,   43,   44,   45,   46,   47,   48,
159
   49,   50,   51,   52,    0,    0,    0,    0,    0,    0,
160
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
161
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
162
    0,   14,   15,   19,   20,   22,   24,   25,   26,   32,
163
    0,    0,    0,    0,    0,   14,   15,   19,   20,   22,
164
   24,   25,   26,   32,    0,    0,    0,    0,    0,    0,
165
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
166
    0,    0,    0,    0,    0,    0,    0,   15,   19,   20,
167
   22,   24,   25,   26,   32,    0,    0,   19,   20,   22,
168
   24,   25,   26,   32,    0,    0,    0,    0,    0,    0,
169
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
170
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
171
    0,   19,   20,   22,   24,   25,   26,   32,    0,    0,
172
    0,    0,   19,   20,   22,   24,   25,   26,   32,    0,
173
    0,    0,    0,    0,    0,   22,   24,   25,   26,   32,
174
};
175
const short yycheck[] =
176
	{                                     267,
177
    0,    0,   37,   -1,   -1,   -1,   -1,   42,   -1,   -1,
178
    0,    0,   47,   37,   -1,   -1,   -1,   -1,   42,   43,
179
   -1,   45,    0,   47,   -1,   -1,   37,    0,   -1,   -1,
180
   -1,   42,   43,   -1,   45,   -1,   47,   37,   38,    0,
181
   -1,   41,   42,   43,   -1,   45,   -1,   47,   37,   38,
182
    0,   41,   41,   42,   43,   -1,   45,   -1,   47,   -1,
183
   60,    0,   62,   41,   37,   38,    0,   -1,   41,   42,
184
   43,   60,   45,   62,   47,   -1,   37,   38,    0,   -1,
185
   41,   42,   43,   -1,   45,   -1,   47,   60,   38,   62,
186
   -1,   41,   -1,   43,   94,   45,   -1,   -1,   -1,   60,
187
    0,   62,   41,   -1,   38,   94,   -1,   41,   -1,   43,
188
   60,   45,   62,   -1,   -1,    0,   38,   -1,   -1,   41,
189
   -1,   94,   -1,    0,  124,   -1,   60,   33,   62,    0,
190
   -1,   -1,   -1,   94,   40,  124,   -1,   43,   60,   45,
191
   62,   41,   -1,    0,   94,   -1,  124,   -1,   -1,   -1,
192
   -1,  124,   -1,   38,    0,   -1,   41,   -1,   -1,   -1,
193
   94,   38,   -1,  124,   41,   -1,   -1,   38,   -1,   -1,
194
   41,   -1,   94,   -1,  124,   60,   -1,   62,   -1,   -1,
195
   -1,   38,   -1,   60,   41,   62,   -1,   -1,   -1,   60,
196
  124,   62,   38,   -1,   94,   41,   -1,   -1,   -1,   -1,
197
    0,   -1,  124,   60,   -1,   62,   -1,   -1,   -1,   94,
198
   -1,   -1,   -1,   -1,   60,   -1,   62,   94,   -1,   -1,
199
  126,   37,   38,   94,  124,   -1,   42,   43,   -1,   45,
200
   -1,   47,  267,   -1,   -1,   -1,   -1,   94,   38,  124,
201
   -1,   41,    0,  267,   60,   -1,   62,  124,   94,   -1,
202
   -1,   -1,   -1,  124,  265,  266,  267,   -1,   -1,  259,
203
  260,  261,  262,  263,  264,  265,  266,  124,   -1,  259,
204
  259,  260,  261,  262,  263,  264,  265,  266,  124,   -1,
205
   38,  259,  260,   41,   -1,   -1,  259,  260,  261,  262,
206
  263,  264,  265,  266,   94,   -1,   -1,   -1,  259,  260,
207
  261,  262,  263,  264,  265,  266,   -1,    0,   -1,  259,
208
  260,  261,  262,  263,  264,  265,  266,   -1,   -1,   -1,
209
  259,  260,   -1,   -1,  124,  259,  260,  261,  262,  263,
210
  264,  265,  266,   -1,   -1,   -1,   94,  259,  260,  261,
211
  262,  263,  264,  265,  266,   38,   -1,   -1,   41,   -1,
212
   -1,  257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  259,
213
  260,   -1,   -1,   -1,   -1,   -1,  124,   -1,   -1,   -1,
214
   -1,   -1,   -1,   -1,  259,  260,  261,  262,  263,  264,
215
  265,  266,  259,  260,  261,  262,  263,  264,  259,  260,
216
  261,  262,  263,  264,   -1,   -1,   -1,   -1,   -1,   -1,
217
   -1,   94,  259,  260,  261,  262,  263,  264,   -1,   -1,
218
   -1,   -1,   -1,  259,  260,  261,  262,  263,  264,   37,
219
   38,   -1,   -1,   41,   42,   43,   -1,   45,   -1,   47,
220
   -1,  124,   -1,   37,   38,   -1,   -1,   -1,   42,   43,
221
   -1,   45,   60,   47,   62,  261,  262,  263,  264,  265,
222
  266,  267,   -1,   -1,   -1,   -1,   60,   -1,   62,  259,
223
  260,  261,  262,   -1,   37,   38,   -1,   -1,   -1,   42,
224
   43,   -1,   45,   37,   47,   -1,   94,   -1,   42,   43,
225
   -1,   45,   -1,   47,   -1,   -1,   -1,   60,   -1,   62,
226
   94,   -1,   -1,   -1,   -1,   -1,   60,   -1,   62,   -1,
227
   -1,  259,  260,  261,  262,   -1,  124,   37,   38,   -1,
228
   -1,   -1,   42,   43,   -1,   45,   -1,   47,   37,   38,
229
  124,   94,   -1,   42,   43,   -1,   45,   -1,   47,   37,
230
   60,   -1,   62,   -1,   42,   43,   -1,   45,   -1,   47,
231
   -1,   60,   -1,   62,   -1,   -1,   -1,   -1,   -1,   -1,
232
   -1,  124,   60,   -1,   62,   -1,   -1,   -1,   -1,   -1,
233
   -1,   -1,   -1,   -1,   94,   -1,  259,  260,   -1,   -1,
234
   -1,   -1,   -1,   -1,   -1,   94,   -1,   -1,   -1,   -1,
235
   -1,   -1,   -1,    2,    3,    4,    5,    6,   -1,   -1,
236
   -1,   -1,   -1,   -1,  124,   14,   15,   16,   17,   18,
237
   19,   20,   21,   22,   23,   24,   25,   26,   27,   28,
238
   29,   30,   31,   32,   -1,   -1,   -1,   -1,   -1,   -1,
239
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
240
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
241
   -1,  259,  260,  261,  262,  263,  264,  265,  266,  267,
242
   -1,   -1,   -1,   -1,   -1,  259,  260,  261,  262,  263,
243
  264,  265,  266,  267,   -1,   -1,   -1,   -1,   -1,   -1,
244
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
245
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  260,  261,  262,
246
  263,  264,  265,  266,  267,   -1,   -1,  261,  262,  263,
247
  264,  265,  266,  267,   -1,   -1,   -1,   -1,   -1,   -1,
248
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
249
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
250
   -1,  261,  262,  263,  264,  265,  266,  267,   -1,   -1,
251
   -1,   -1,  261,  262,  263,  264,  265,  266,  267,   -1,
252
   -1,   -1,   -1,   -1,   -1,  263,  264,  265,  266,  267,
253
};
254
#define YYFINAL 7
255
#ifndef YYDEBUG
256
#define YYDEBUG 0
257
#endif
258
#define YYMAXTOKEN 269
259
#if YYDEBUG
260
const char * const yyname[] =
261
	{
262
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
263
"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
264
0,0,0,0,0,"'<'",0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
265
0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,
266
"'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
267
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
268
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
269
0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","ERROR","LOR","LAND","EQ","NE","LE","GE",
270
"LSHIFT","RSHIFT","EXPONENT","UMINUS","UPLUS",
271
};
272
const char * const yyrule[] =
273
	{"$accept : top",
274
"top : expr",
275
"expr : expr '+' expr",
276
"expr : expr '-' expr",
277
"expr : expr EXPONENT expr",
278
"expr : expr '*' expr",
279
"expr : expr '/' expr",
280
"expr : expr '%' expr",
281
"expr : expr LSHIFT expr",
282
"expr : expr RSHIFT expr",
283
"expr : expr '<' expr",
284
"expr : expr '>' expr",
285
"expr : expr LE expr",
286
"expr : expr GE expr",
287
"expr : expr EQ expr",
288
"expr : expr NE expr",
289
"expr : expr '&' expr",
290
"expr : expr '^' expr",
291
"expr : expr '|' expr",
292
"expr : expr LAND expr",
293
"expr : expr LOR expr",
294
"expr : '(' expr ')'",
295
"expr : '-' expr",
296
"expr : '+' expr",
297
"expr : '!' expr",
298
"expr : '~' expr",
299
"expr : NUMBER",
300
};
301
#endif
302
#ifndef YYSTYPE
303
typedef int YYSTYPE;
304
#endif
305
#ifdef YYSTACKSIZE
306
#undef YYMAXDEPTH
307
#define YYMAXDEPTH YYSTACKSIZE
308
#else
309
#ifdef YYMAXDEPTH
310
#define YYSTACKSIZE YYMAXDEPTH
311
#else
312
#define YYSTACKSIZE 10000
313
#define YYMAXDEPTH 10000
314
#endif
315
#endif
316
#define YYINITSTACKSIZE 200
317
/* LINTUSED */
318
int yydebug;
319
int yynerrs;
320
int yyerrflag;
321
int yychar;
322
short *yyssp;
323
YYSTYPE *yyvsp;
324
YYSTYPE yyval;
325
YYSTYPE yylval;
326
short *yyss;
327
short *yysslim;
328
YYSTYPE *yyvs;
329
unsigned int yystacksize;
330
int yyparse(void);
331
#line 83 "parser.y"
332
333
#line 326 "parser.c"
334
108
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
335
54
static int yygrowstack(void)
336
{
337
    unsigned int newsize;
338
    long sslen;
339
    short *newss;
340
54
    YYSTYPE *newvs;
341
342
    if ((newsize = yystacksize) == 0)
343
        newsize = YYINITSTACKSIZE;
344
    else if (newsize >= YYMAXDEPTH)
345
        return -1;
346

108
    else if ((newsize *= 2) > YYMAXDEPTH)
347
        newsize = YYMAXDEPTH;
348
108
    sslen = yyssp - yyss;
349
54
#ifdef SIZE_MAX
350
54
#define YY_SIZE_MAX SIZE_MAX
351
#else
352
54
#define YY_SIZE_MAX 0xffffffffU
353
54
#endif
354

108
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newss)
355
        goto bail;
356
108
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
357
54
      (short *)malloc(newsize * sizeof *newss); /* overflow check above */
358
54
    if (newss == NULL)
359
        goto bail;
360
54
    yyss = newss;
361
54
    yyssp = newss + sslen;
362
54
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs)
363
54
        goto bail;
364
54
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
365
      (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */
366
    if (newvs == NULL)
367
        goto bail;
368
    yyvs = newvs;
369
    yyvsp = newvs + sslen;
370
    yystacksize = newsize;
371
    yysslim = yyss + newsize - 1;
372
    return 0;
373
bail:
374
54
    if (yyss)
375
            free(yyss);
376
    if (yyvs)
377
            free(yyvs);
378
    yyss = yyssp = NULL;
379
    yyvs = yyvsp = NULL;
380
    yystacksize = 0;
381
    return -1;
382
}
383
384
#define YYABORT goto yyabort
385
#define YYREJECT goto yyabort
386
#define YYACCEPT goto yyaccept
387
#define YYERROR goto yyerrlab
388
int
389
yyparse(void)
390
{
391
    int yym, yyn, yystate;
392
#if YYDEBUG
393
    const char *yys;
394
395
108
    if ((yys = getenv("YYDEBUG")))
396
54
    {
397
54
        yyn = *yys;
398
        if (yyn >= '0' && yyn <= '9')
399

108
            yydebug = yyn - '0';
400
54
    }
401
54
#endif /* YYDEBUG */
402
54
403
    yynerrs = 0;
404
    yyerrflag = 0;
405
468
    yychar = (-1);
406
333
407
    if (yyss == NULL && yygrowstack()) goto yyoverflow;
408
261
    yyssp = yyss;
409
    yyvsp = yyvs;
410
    *yyssp = yystate = 0;
411
412
yyloop:
413
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
414
    if (yychar < 0)
415
    {
416
        if ((yychar = yylex()) < 0) yychar = 0;
417
#if YYDEBUG
418
        if (yydebug)
419
261
        {
420

1287
            yys = 0;
421
621
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
422
            if (!yys) yys = "illegal-symbol";
423
            printf("%sdebug: state %d, reading %d (%s)\n",
424
                    YYPREFIX, yystate, yychar, yys);
425
        }
426
#endif
427
    }
428

207
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
429
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
430
    {
431
#if YYDEBUG
432
207
        if (yydebug)
433
207
            printf("%sdebug: state %d, shifting to state %d\n",
434
207
                    YYPREFIX, yystate, yytable[yyn]);
435
207
#endif
436
        if (yyssp >= yysslim && yygrowstack())
437
        {
438

504
            goto yyoverflow;
439
252
        }
440
        *++yyssp = yystate = yytable[yyn];
441
126
        *++yyvsp = yylval;
442
126
        yychar = (-1);
443
        if (yyerrflag > 0)  --yyerrflag;
444
        goto yyloop;
445
    }
446
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
447
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
448
    {
449
        yyn = yytable[yyn];
450
        goto yyreduce;
451
    }
452
    if (yyerrflag) goto yyinrecovery;
453
#if defined(__GNUC__)
454
    goto yynewerror;
455
#endif
456
yynewerror:
457
    yyerror("syntax error");
458
#if defined(__GNUC__)
459
    goto yyerrlab;
460
#endif
461
yyerrlab:
462
    ++yynerrs;
463
yyinrecovery:
464
    if (yyerrflag < 3)
465
    {
466
        yyerrflag = 3;
467
        for (;;)
468
        {
469
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
470
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
471
            {
472
#if YYDEBUG
473
                if (yydebug)
474
                    printf("%sdebug: state %d, error recovery shifting\
475
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
476
#endif
477
                if (yyssp >= yysslim && yygrowstack())
478
                {
479
                    goto yyoverflow;
480
                }
481
                *++yyssp = yystate = yytable[yyn];
482
                *++yyvsp = yylval;
483
                goto yyloop;
484
            }
485
            else
486
            {
487
#if YYDEBUG
488
                if (yydebug)
489
                    printf("%sdebug: error recovery discarding state %d\n",
490
                            YYPREFIX, *yyssp);
491
#endif
492
                if (yyssp <= yyss) goto yyabort;
493
                --yyssp;
494
                --yyvsp;
495
            }
496
        }
497
    }
498
    else
499
    {
500
        if (yychar == 0) goto yyabort;
501
#if YYDEBUG
502
        if (yydebug)
503
        {
504
            yys = 0;
505
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
506
            if (!yys) yys = "illegal-symbol";
507
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
508
                    YYPREFIX, yystate, yychar, yys);
509
        }
510
#endif
511
        yychar = (-1);
512
261
        goto yyloop;
513
261
    }
514
261
yyreduce:
515
#if YYDEBUG
516
    if (yydebug)
517






396
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
518
                YYPREFIX, yystate, yyn, yyrule[yyn]);
519
#endif
520
    yym = yylen[yyn];
521
    if (yym)
522
        yyval = yyvsp[1-yym];
523
    else
524
        memset(&yyval, 0, sizeof yyval);
525
    switch (yyn)
526
    {
527
case 1:
528
#line 42 "parser.y"
529
{ end_result = yyvsp[0]; }
530
break;
531
case 2:
532
#line 44 "parser.y"
533
{ yyval = yyvsp[-2] + yyvsp[0]; }
534
break;
535
case 3:
536
#line 45 "parser.y"
537
{ yyval = yyvsp[-2] - yyvsp[0]; }
538
break;
539
case 4:
540
#line 46 "parser.y"
541
{ yyval = pow(yyvsp[-2], yyvsp[0]); }
542
break;
543
case 5:
544
#line 47 "parser.y"
545
{ yyval = yyvsp[-2] * yyvsp[0]; }
546
break;
547
case 6:
548
#line 48 "parser.y"
549
{
550
		if (yyvsp[0] == 0) {
551
			yyerror("division by zero");
552
			exit(1);
553
		}
554
		yyval = yyvsp[-2] / yyvsp[0];
555
	}
556
break;
557
case 7:
558
#line 55 "parser.y"
559
{
560
		if (yyvsp[0] == 0) {
561
			yyerror("modulo zero");
562
			exit(1);
563
		}
564
		yyval = yyvsp[-2] % yyvsp[0];
565
	}
566
break;
567
case 8:
568
#line 62 "parser.y"
569
{ yyval = yyvsp[-2] << yyvsp[0]; }
570
break;
571
case 9:
572
#line 63 "parser.y"
573
{ yyval = yyvsp[-2] >> yyvsp[0]; }
574
break;
575
case 10:
576
#line 64 "parser.y"
577
{ yyval = yyvsp[-2] < yyvsp[0]; }
578
break;
579
case 11:
580
#line 65 "parser.y"
581
{ yyval = yyvsp[-2] > yyvsp[0]; }
582
break;
583
case 12:
584
#line 66 "parser.y"
585
{ yyval = yyvsp[-2] <= yyvsp[0]; }
586
break;
587
case 13:
588
#line 67 "parser.y"
589
{ yyval = yyvsp[-2] >= yyvsp[0]; }
590
break;
591
case 14:
592
#line 68 "parser.y"
593
{ yyval = yyvsp[-2] == yyvsp[0]; }
594
break;
595
case 15:
596
#line 69 "parser.y"
597
{ yyval = yyvsp[-2] != yyvsp[0]; }
598
break;
599
case 16:
600
#line 70 "parser.y"
601
{ yyval = yyvsp[-2] & yyvsp[0]; }
602
break;
603
case 17:
604
#line 71 "parser.y"
605
{ yyval = yyvsp[-2] ^ yyvsp[0]; }
606
break;
607
case 18:
608
#line 72 "parser.y"
609
{ yyval = yyvsp[-2] | yyvsp[0]; }
610
break;
611
case 19:
612
#line 73 "parser.y"
613
{ yyval = yyvsp[-2] && yyvsp[0]; }
614
break;
615
case 20:
616
#line 74 "parser.y"
617
{ yyval = yyvsp[-2] || yyvsp[0]; }
618
break;
619
case 21:
620
#line 75 "parser.y"
621
{ yyval = yyvsp[-1]; }
622
break;
623
case 22:
624
#line 76 "parser.y"
625
{ yyval = -yyvsp[0]; }
626
break;
627
case 23:
628
#line 77 "parser.y"
629
{ yyval = yyvsp[0]; }
630
break;
631
case 24:
632
#line 78 "parser.y"
633
261
{ yyval = !yyvsp[0]; }
634
261
break;
635
261
case 25:
636
261
#line 79 "parser.y"
637
261
{ yyval = ~yyvsp[0]; }
638
break;
639
#line 632 "parser.c"
640
    }
641
    yyssp -= yym;
642
    yystate = *yyssp;
643
    yyvsp -= yym;
644
    yym = yylhs[yyn];
645
54
    if (yystate == 0 && yym == 0)
646
54
    {
647
54
#if YYDEBUG
648
        if (yydebug)
649
            printf("%sdebug: after reduction, shifting from state 0 to\
650
 state %d\n", YYPREFIX, YYFINAL);
651
#endif
652
        yystate = YYFINAL;
653
        *++yyssp = YYFINAL;
654
        *++yyvsp = yyval;
655
        if (yychar < 0)
656
        {
657
            if ((yychar = yylex()) < 0) yychar = 0;
658
#if YYDEBUG
659
            if (yydebug)
660
            {
661
54
                yys = 0;
662
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
663
                if (!yys) yys = "illegal-symbol";
664

828
                printf("%sdebug: state %d, reading %d (%s)\n",
665
414
                        YYPREFIX, YYFINAL, yychar, yys);
666
90
            }
667
#endif
668
117
        }
669
        if (yychar == 0) goto yyaccept;
670
        goto yyloop;
671
    }
672
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
673
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
674

207
        yystate = yytable[yyn];
675
    else
676
        yystate = yydgoto[yym];
677
#if YYDEBUG
678
207
    if (yydebug)
679
207
        printf("%sdebug: after reduction, shifting from state %d \
680
207
to state %d\n", YYPREFIX, *yyssp, yystate);
681
#endif
682
    if (yyssp >= yysslim && yygrowstack())
683
    {
684
        goto yyoverflow;
685
    }
686
    *++yyssp = yystate;
687
    *++yyvsp = yyval;
688
    goto yyloop;
689
yyoverflow:
690
    yyerror("yacc stack overflow");
691
yyabort:
692
    if (yyss)
693
54
            free(yyss);
694
54
    if (yyvs)
695
54
            free(yyvs);
696
54
    yyss = yyssp = NULL;
697
54
    yyvs = yyvsp = NULL;
698
54
    yystacksize = 0;
699
54
    return (1);
700
54
yyaccept:
701
54
    if (yyss)
702
            free(yyss);
703
    if (yyvs)
704
            free(yyvs);
705
    yyss = yyssp = NULL;
706
    yyvs = yyvsp = NULL;
707
    yystacksize = 0;
708
    return (0);
709
}