push.skel 12 KB

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