-
Notifications
You must be signed in to change notification settings - Fork 4
/
push.skel
477 lines (469 loc) · 12.1 KB
/
push.skel
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
%% banner
/*
** "@(#)push.skel, based on byacc 1.8 (Berkeley) 01/20/91";
*/
#define YYBTYACC 1
%% header
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
/* #ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif */
int yydebug;
static struct yyparsestate {
struct yyparsestate *save;
int state;
int errflag;
short *ssp;
YYSTYPE *vsp;
YYSTYPE val;
short *ss;
YYSTYPE *vs;
int lexeme;
unsigned short stacksize;
short ctry;
} *yypstate=0, *yypath=0;
#define yyerrflag (yypstate->errflag)
#define yyssp (yypstate->ssp)
#define yyvsp (yypstate->vsp)
#define yyval (yypstate->val)
#define yyss (yypstate->ss)
#define yyvs (yypstate->vs)
#define yystacksize (yypstate->stacksize)
static YYSTYPE *yylvals=0, *yylvp=0, *yylve=0, *yylvlim=0;
static short *yylexemes=0, *yylexp=0;
#define YYLEX (yylvp<yylve ? yylval=*yylvp++, *yylexp++ : \
yytrial ? (yylvp==yylvlim ? yyexpand() : 0), *yylexp = yylex(), \
*yylvp++ = yylval, yylve++, *yylexp++ \
: yylex())
extern int yylex(), yyparse();
#define yytrial (yypstate->save)
#ifndef __cplusplus
#define YYSCOPY(t, f, s) memcpy(t, f, (s)*sizeof(YYSTYPE))
#define YYMORESTACK do { int p = yyssp - yyss; \
yystacksize += 16; \
yyss = (short *)realloc(yyss, yystacksize * sizeof(short)); \
yyvs = (YYSTYPE *)realloc(yyvs, yystacksize * sizeof(YYSTYPE)); \
yyssp = yyss + p; \
yyvsp = yyvs + p; \
} while (0)
#else /* C++ */
#define YYSCOPY(to, from, size) do { int _i; \
for (_i = (size)-1; _i >= 0; _i--) \
(to)[_i] = (from)[_i]; \
} while(0)
#define YYMORESTACK do { int p = yyssp - yyss; \
short *tss = yyss; YYSTYPE *tvs = yyvs; \
yyss = new short[yystacksize + 16]; \
yyvs = new YYSTYPE[yystacksize + 16]; \
memcpy(yyss, tss, yystacksize * sizeof(short)); \
YYSCOPY(yyvs, tvs, yystacksize); \
yystacksize += 16; \
delete[] tss; \
delete[] tvs; \
yyssp = yyss + p; \
yyvsp = yyvs + p; \
} while (0)
#endif /* C++ */
%% body
#ifndef YYNEWSTATE
#ifdef __oldc
static struct yyparsestate *YYNEWSTATE(size)
int size;
#else
static struct yyparsestate *YYNEWSTATE(int size)
#endif /* __oldc */
{
struct yyparsestate *p;
#ifndef __cplusplus
p = (struct yyparsestate *)malloc(sizeof(struct yyparsestate));
p->stacksize = size+4;
p->ss = (short *)malloc((size+4)*sizeof(short));
p->vs = (YYSTYPE *)malloc((size+4)*sizeof(YYSTYPE));
#else /* C++ */
p = new yyparsestate;
p->stacksize = size+4;
p->ss = new short[size + 4];
p->vs = new YYSTYPE[size + 4];
#endif /* C++ */
return p;
}
#endif /* YYNEWSTATE */
#ifndef YYFREESTATE
#ifndef __cplusplus
#define YYFREESTATE(p) (free((p)->ss), free((p)->vs), free(p))
#else /* C++ */
#define YYFREESTATE(p) (delete[] (p)->ss, delete[] (p)->vs, delete (p))
#endif /* C++ */
#endif /* YYFREESTATE */
static int yyexpand()
{
int p = yylvp-yylvals;
int s = yylvlim-yylvals;
s += 16;
#ifndef __cplusplus
yylvals = (YYSTYPE *)realloc(yylvals, s*sizeof(YYSTYPE));
yylexemes = (short *)realloc(yylexemes, s*sizeof(short));
#else /* C++ */
{ short *tl = yylexemes; YYSTYPE *tv = yylvals;
yylvals = new YYSTYPE[s];
yylexemes = new short[s];
memcpy(yylexemes, tl, (s-16)*sizeof(short));
YYSCOPY(yylvals, tv, s-16);
delete[] tl;
delete[] tv; }
#endif /* C++ */
yylvp = yylve = yylvals + p;
yylvlim = yylvals + s;
yylexp = yylexemes + p;
return 0;
}
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
#define YYVALID do { if (yytrial) goto yyvalid; } while(0)
#ifdef __cplusplus
extern "C" char *getenv(const char *);
#else
extern char *getenv();
#endif
int yyparse(int yychar, YYSTYPE yylval)
{
int yym, yyn, yystate, yynewerrflag;
#if YYDEBUG
char *yys;
#endif
if (yychar < 0) yychar = 0;
if (!yypstate) {
/* initialize the parser state */
yypstate = YYNEWSTATE(12);
yypath = 0;
yytrial = 0;
yyerrflag = 0;
yylvp = yylve = yylvals;
yylexp = yylexemes;
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yypstate->state = 0; }
yystate = yypstate->state;
#if YYDEBUG
if (yydebug) {
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, input %d (%s)", yystate,
yychar, yys);
#ifdef YYDBPR
printf("<");
YYDBPR(yylval);
printf(">");
#endif
printf("\n"); }
#endif
if (yystate == YYFINAL && yychar == 0)
goto yyaccept;
if (yytrial) {
if (yylvp == yylvlim) yyexpand();
*yylvp++ = yylval;
yylve++;
*yylexp++ = yychar; }
yyloop:
if ((yyn = yydefred[yystate])) goto yyreduce;
if (yychar < 0) {
if (yylvp < yylve) {
yylval = *yylvp++;
yychar = *yylexp++; }
else {
yypstate->state = yystate;
return 0; }
#if YYDEBUG
if (yydebug) {
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, reading %d (%s)", yystate,
yychar, yys);
#ifdef YYDBPR
printf("<");
YYDBPR(yylval);
printf(">");
#endif
printf("\n"); }
#endif
}
if ((yyn = yycindex[yystate]) &&
(yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE &&
yycheck[yyn] == yychar) {
int ctry;
struct yyparsestate *save;
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, conflict%s\n", yystate,
yypath ? ", following successful trial parse" :
yytrial ? "" : ", starting trial parse");
#endif
if (yypath) {
save = yypath;
yypath = save->save;
ctry = save->ctry;
if (save->state != yystate) goto yyabort;
YYFREESTATE(save); }
else {
save = YYNEWSTATE(yyssp - yyss);
save->save = yypstate->save;
save->state = yystate;
save->errflag = yypstate->errflag;
save->ssp = save->ss + (yyssp - yyss);
save->vsp = save->vs + (yyvsp - yyvs);
memcpy(save->ss, yyss, (yyssp - yyss + 1)*sizeof(short));
YYSCOPY(save->vs, yyvs, yyssp - yyss + 1);
ctry = yytable[yyn];
if (yyctable[ctry] == -1) {
#if YYDEBUG
if (yydebug && yychar >= 0)
printf("yydebug: backtracking 1 token\n");
#endif
ctry++; }
save->ctry = ctry;
if (!yytrial) {
if (!yylexemes) {
#ifndef __cplusplus
yylexemes = (short *)malloc(16*sizeof(short));
yylvals = (YYSTYPE *)malloc(16*sizeof(YYSTYPE));
#else /* C++ */
yylexemes = new short[16];
yylvals = new YYSTYPE[16];
#endif /* C++ */
yylvlim = yylvals + 16; }
if (yylvp == yylve) {
yylvp = yylve = yylvals;
yylexp = yylexemes;
if (yychar >= 0) {
*yylve++ = yylval;
*yylexp = yychar;
yychar = -1; } } }
if (yychar >= 0) {
yylvp--, yylexp--;
yychar = -1; }
save->lexeme = yylvp - yylvals;
yypstate->save = save; }
if (yytable[yyn] == ctry) {
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, shifting to state %d\n",
yystate, yyctable[ctry]);
#endif
if (yychar < 0)
yylvp++, yylexp++;
yychar = -1;
if (yyerrflag > 0) --yyerrflag;
yystate = yyctable[ctry];
goto yyshift; }
else {
yyn = yyctable[ctry];
goto yyreduce; } }
if ((yyn = yysindex[yystate]) &&
(yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE &&
yycheck[yyn] == yychar) {
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, shifting to state %d\n",
yystate, yytable[yyn]);
#endif
yychar = (-1);
if (yyerrflag > 0) --yyerrflag;
yystate = yytable[yyn];
yyshift:
if (yyssp >= yyss + yystacksize - 1)
YYMORESTACK;
*++yyssp = yystate;
*++yyvsp = yylval;
goto yyloop; }
if ((yyn = yyrindex[yystate]) &&
(yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE &&
yycheck[yyn] == yychar) {
yyn = yytable[yyn];
goto yyreduce; }
if (yyerrflag) goto yyinrecovery;
yynewerrflag = 1;
goto yyerrhandler;
yyerrlab:
yynewerrflag = 0;
yyerrhandler:
while (yytrial) { int ctry; struct yyparsestate *save;
#if YYDEBUG
if (yydebug)
printf("yydebug: error in state %d, %s state %d, %d tokens\n",
yystate, "backtracking to", yypstate->save->state,
(int)(yylvp - yylvals - yypstate->save->lexeme));
#endif
save = yypstate->save;
yylvp = yylvals + save->lexeme;
yylexp = yylexemes + save->lexeme;
yychar = -1;
yyssp = yyss + (save->ssp - save->ss);
yyvsp = yyvs + (save->vsp - save->vs);
memcpy(yyss, save->ss, (yyssp - yyss + 1) * sizeof(short));
YYSCOPY(yyvs, save->vs, yyvsp - yyvs + 1);
ctry = ++save->ctry;
yystate = save->state;
if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
yypstate->save = save->save;
YYFREESTATE(save);
#if YYDEBUG
if (yydebug && !yytrial)
printf("yydebug: trial parse failed, entering error mode\n");
#endif
yynewerrflag = 1; }
if (yynewerrflag)
yyerror("syntax error");
yyinrecovery:
if (yyerrflag < 3) {
yyerrflag = 3;
for (;;) {
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) {
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, error recovery %s state %d\n",
*yyssp, "shifting to", yytable[yyn]);
#endif
yystate = yytable[yyn];
goto yyshift; }
else {
#if YYDEBUG
if (yydebug)
printf("yydebug: error recovery discarding state %d\n",
*yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp; } } }
else {
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug) {
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, error recovery discards token %d (%s)\n",
yystate, yychar, yys); }
#endif
yychar = (-1);
goto yyloop; }
yyreduce:
yym = yylen[yyn];
#if YYDEBUG
if (yydebug) {
printf("yydebug: state %d, reducing by rule %d (%s)",
yystate, yyn, yyrule[yyn]);
#ifdef YYDBPR
if (yym) {
int i;
printf("<");
for (i=yym; i>0; i--) {
if (i!=yym) printf(", ");
YYDBPR(yyvsp[1-i]); }
printf(">"); }
#endif
printf("\n"); }
#endif
if (yyssp + 1 - yym >= yyss + yystacksize)
YYMORESTACK;
yyval = yyvsp[1-yym];
switch (yyn) {
%% trailer
}
#if YYDEBUG && defined(YYDBPR)
if (yydebug) {
printf("yydebug: after reduction, result is ");
YYDBPR(yyval);
printf("\n"); }
#endif
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0) {
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, %s from state 0 to state %d\n",
"shifting", YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar == 0) goto yyaccept;
goto yyloop; }
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, %s from state %d to state %d\n",
"shifting", *yyssp, yystate);
#endif
if (yyssp >= yyss + yystacksize - 1)
YYMORESTACK;
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyvalid:
if (yypath)
goto yyabort;
while (yypstate->save) {
struct yyparsestate *save = yypstate->save;
yypstate->save = save->save;
save->save = yypath;
yypath = save; }
#if YYDEBUG
if (yydebug)
printf("yydebug: trial successful, %s state %d, %d tokens\n",
"backtracking to", yypath->state,
(int)(yylvp - yylvals - yypath->lexeme));
#endif
yychar = -1;
yyssp = yyss + (yypath->ssp - yypath->ss);
yyvsp = yyvs + (yypath->vsp - yypath->vs);
memcpy(yyss, yypath->ss, (yyssp - yyss + 1) * sizeof(short));
YYSCOPY(yyvs, yypath->vs, yyvsp - yyvs + 1);
yylvp = yylvals + yypath->lexeme;
yylexp = yylexemes + yypath->lexeme;
yystate = yypath->state;
goto yyloop;
yyabort:
while (yypstate) {
struct yyparsestate *save = yypstate;
yypstate = save->save;
YYFREESTATE(save); }
while (yypath) {
struct yyparsestate *save = yypath;
yypath = save->save;
YYFREESTATE(save); }
return -1;
yyaccept:
if (yytrial) goto yyvalid;
while (yypstate) {
struct yyparsestate *save = yypstate;
yypstate = save->save;
YYFREESTATE(save); }
while (yypath) {
struct yyparsestate *save = yypath;
yypath = save->save;
YYFREESTATE(save); }
return 1;
}