bison.simple.save 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
  2. #line 3 "bison.simple"
  3. /* Skeleton output parser for bison,
  4. Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 1, or (at your option)
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  16. #ifndef alloca
  17. #ifdef __GNUC__
  18. #define alloca __builtin_alloca
  19. #else /* not GNU C. */
  20. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc)
  21. #include <alloca.h>
  22. #else /* not sparc */
  23. #if defined (MSDOS) && !defined (__TURBOC__)
  24. #include <malloc.h>
  25. #else /* not MSDOS, or __TURBOC__ */
  26. #if defined(_AIX)
  27. #include <malloc.h>
  28. #pragma alloca
  29. #endif /* not _AIX */
  30. #endif /* not MSDOS, or __TURBOC__ */
  31. #endif /* not sparc. */
  32. #endif /* not GNU C. */
  33. #endif /* alloca not defined. */
  34. /* This is the parser code that is written into each bison parser
  35. when the %semantic_parser declaration is not specified in the grammar.
  36. It was written by Richard Stallman by simplifying the hairy parser
  37. used when %semantic_parser is specified. */
  38. /* Note: there must be only one dollar sign in this file.
  39. It is replaced by the list of actions, each action
  40. as one case of the switch. */
  41. #define yyerrok (yyerrstatus = 0)
  42. #define yyclearin (yychar = YYEMPTY)
  43. #define YYEMPTY -2
  44. #define YYEOF 0
  45. #define YYACCEPT return(0)
  46. #define YYABORT return(1)
  47. #define YYERROR goto yyerrlab1
  48. /* Like YYERROR except do call yyerror.
  49. This remains here temporarily to ease the
  50. transition to the new meaning of YYERROR, for GCC.
  51. Once GCC version 2 has supplanted version 1, this can go. */
  52. #define YYFAIL goto yyerrlab
  53. #define YYRECOVERING() (!!yyerrstatus)
  54. #define YYBACKUP(token, value) \
  55. do \
  56. if (yychar == YYEMPTY && yylen == 1) \
  57. { yychar = (token), yylval = (value); \
  58. yychar1 = YYTRANSLATE (yychar); \
  59. YYPOPSTACK; \
  60. goto yybackup; \
  61. } \
  62. else \
  63. { yyerror ("syntax error: cannot back up"); YYERROR; } \
  64. while (0)
  65. #define YYTERROR 1
  66. #define YYERRCODE 256
  67. #ifndef YYPURE
  68. #define YYLEX yylex()
  69. #endif
  70. #ifdef YYPURE
  71. #ifdef YYLSP_NEEDED
  72. #define YYLEX yylex(&yylval, &yylloc)
  73. #else
  74. #define YYLEX yylex(&yylval)
  75. #endif
  76. #endif
  77. /* If nonreentrant, generate the variables here */
  78. #ifndef YYPURE
  79. int yychar; /* the lookahead symbol */
  80. YYSTYPE yylval; /* the semantic value of the */
  81. /* lookahead symbol */
  82. #ifdef YYLSP_NEEDED
  83. YYLTYPE yylloc; /* location data for the lookahead */
  84. /* symbol */
  85. #endif
  86. int yynerrs; /* number of parse errors so far */
  87. #endif /* not YYPURE */
  88. #if YYDEBUG != 0
  89. int yydebug; /* nonzero means print parse trace */
  90. /* Since this is uninitialized, it does not stop multiple parsers
  91. from coexisting. */
  92. #endif
  93. /* YYINITDEPTH indicates the initial size of the parser's stacks */
  94. #ifndef YYINITDEPTH
  95. #define YYINITDEPTH 200
  96. #endif
  97. /* YYMAXDEPTH is the maximum size the stacks can grow to
  98. (effective only if the built-in stack extension method is used). */
  99. #if YYMAXDEPTH == 0
  100. #undef YYMAXDEPTH
  101. #endif
  102. #ifndef YYMAXDEPTH
  103. #define YYMAXDEPTH 10000
  104. #endif
  105. #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
  106. #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
  107. #else /* not GNU C or C++ */
  108. #ifndef __cplusplus
  109. /* This is the most reliable way to avoid incompatibilities
  110. in available built-in functions on various systems. */
  111. static void
  112. __yy_bcopy (from, to, count)
  113. char *from;
  114. char *to;
  115. int count;
  116. {
  117. register char *f = from;
  118. register char *t = to;
  119. register int i = count;
  120. while (i-- > 0)
  121. *t++ = *f++;
  122. }
  123. #else /* __cplusplus */
  124. /* This is the most reliable way to avoid incompatibilities
  125. in available built-in functions on various systems. */
  126. static void
  127. __yy_bcopy (char *from, char *to, int count)
  128. {
  129. register char *f = from;
  130. register char *t = to;
  131. register int i = count;
  132. while (i-- > 0)
  133. *t++ = *f++;
  134. }
  135. #endif
  136. #endif
  137. #line 169 "bison.simple"
  138. int
  139. yyparse()
  140. {
  141. register int yystate;
  142. register int yyn;
  143. register short *yyssp;
  144. register YYSTYPE *yyvsp;
  145. int yyerrstatus; /* number of tokens to shift before error messages enabled */
  146. int yychar1; /* lookahead token as an internal (translated) token number */
  147. short yyssa[YYINITDEPTH]; /* the state stack */
  148. YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
  149. short *yyss = yyssa; /* refer to the stacks thru separate pointers */
  150. YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
  151. #ifdef YYLSP_NEEDED
  152. YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
  153. YYLTYPE *yyls = yylsa;
  154. YYLTYPE *yylsp;
  155. #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
  156. #else
  157. #define YYPOPSTACK (yyvsp--, yyssp--)
  158. #endif
  159. int yystacksize = YYINITDEPTH;
  160. #ifdef YYPURE
  161. int yychar;
  162. YYSTYPE yylval;
  163. int yynerrs;
  164. #ifdef YYLSP_NEEDED
  165. YYLTYPE yylloc;
  166. #endif
  167. #endif
  168. YYSTYPE yyval; /* the variable used to return */
  169. /* semantic values from the action */
  170. /* routines */
  171. int yylen;
  172. #if YYDEBUG != 0
  173. if (yydebug)
  174. fprintf(stderr, "Starting parse\n");
  175. #endif
  176. yystate = 0;
  177. yyerrstatus = 0;
  178. yynerrs = 0;
  179. yychar = YYEMPTY; /* Cause a token to be read. */
  180. /* Initialize stack pointers.
  181. Waste one element of value and location stack
  182. so that they stay on the same level as the state stack.
  183. The wasted elements are never initialized. */
  184. yyssp = yyss - 1;
  185. yyvsp = yyvs;
  186. #ifdef YYLSP_NEEDED
  187. yylsp = yyls;
  188. #endif
  189. /* Push a new state, which is found in yystate . */
  190. /* In all cases, when you get here, the value and location stacks
  191. have just been pushed. so pushing a state here evens the stacks. */
  192. yynewstate:
  193. *++yyssp = yystate;
  194. if (yyssp >= yyss + yystacksize - 1)
  195. {
  196. /* Give user a chance to reallocate the stack */
  197. /* Use copies of these so that the &'s don't force the real ones into memory. */
  198. YYSTYPE *yyvs1 = yyvs;
  199. short *yyss1 = yyss;
  200. #ifdef YYLSP_NEEDED
  201. YYLTYPE *yyls1 = yyls;
  202. #endif
  203. /* Get the current used size of the three stacks, in elements. */
  204. int size = yyssp - yyss + 1;
  205. #ifdef yyoverflow
  206. /* Each stack pointer address is followed by the size of
  207. the data in use in that stack, in bytes. */
  208. yyoverflow("parser stack overflow",
  209. &yyss1, size * sizeof (*yyssp),
  210. &yyvs1, size * sizeof (*yyvsp),
  211. #ifdef YYLSP_NEEDED
  212. &yyls1, size * sizeof (*yylsp),
  213. #endif
  214. &yystacksize);
  215. yyss = yyss1; yyvs = yyvs1;
  216. #ifdef YYLSP_NEEDED
  217. yyls = yyls1;
  218. #endif
  219. #else /* no yyoverflow */
  220. /* Extend the stack our own way. */
  221. if (yystacksize >= YYMAXDEPTH)
  222. {
  223. yyerror("parser stack overflow");
  224. return 2;
  225. }
  226. yystacksize *= 2;
  227. if (yystacksize > YYMAXDEPTH)
  228. yystacksize = YYMAXDEPTH;
  229. yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  230. __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  231. yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  232. __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  233. #ifdef YYLSP_NEEDED
  234. yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  235. __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  236. #endif
  237. #endif /* no yyoverflow */
  238. yyssp = yyss + size - 1;
  239. yyvsp = yyvs + size - 1;
  240. #ifdef YYLSP_NEEDED
  241. yylsp = yyls + size - 1;
  242. #endif
  243. #if YYDEBUG != 0
  244. if (yydebug)
  245. fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  246. #endif
  247. if (yyssp >= yyss + yystacksize - 1)
  248. YYABORT;
  249. }
  250. #if YYDEBUG != 0
  251. if (yydebug)
  252. fprintf(stderr, "Entering state %d\n", yystate);
  253. #endif
  254. goto yybackup;
  255. yybackup:
  256. /* Do appropriate processing given the current state. */
  257. /* Read a lookahead token if we need one and don't already have one. */
  258. /* yyresume: */
  259. /* First try to decide what to do without reference to lookahead token. */
  260. yyn = yypact[yystate];
  261. if (yyn == YYFLAG)
  262. goto yydefault;
  263. /* Not known => get a lookahead token if don't already have one. */
  264. /* yychar is either YYEMPTY or YYEOF
  265. or a valid token in external form. */
  266. if (yychar == YYEMPTY)
  267. {
  268. #if YYDEBUG != 0
  269. if (yydebug)
  270. fprintf(stderr, "Reading a token: ");
  271. #endif
  272. yychar = YYLEX;
  273. }
  274. /* Convert token to internal form (in yychar1) for indexing tables with */
  275. if (yychar <= 0) /* This means end of input. */
  276. {
  277. yychar1 = 0;
  278. yychar = YYEOF; /* Don't call YYLEX any more */
  279. #if YYDEBUG != 0
  280. if (yydebug)
  281. fprintf(stderr, "Now at end of input.\n");
  282. #endif
  283. }
  284. else
  285. {
  286. yychar1 = YYTRANSLATE(yychar);
  287. #if YYDEBUG != 0
  288. if (yydebug)
  289. {
  290. fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  291. /* Give the individual parser a way to print the precise meaning
  292. of a token, for further debugging info. */
  293. #ifdef YYPRINT
  294. YYPRINT (stderr, yychar, yylval);
  295. #endif
  296. fprintf (stderr, ")\n");
  297. }
  298. #endif
  299. }
  300. yyn += yychar1;
  301. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  302. goto yydefault;
  303. yyn = yytable[yyn];
  304. /* yyn is what to do for this token type in this state.
  305. Negative => reduce, -yyn is rule number.
  306. Positive => shift, yyn is new state.
  307. New state is final state => don't bother to shift,
  308. just return success.
  309. 0, or most negative number => error. */
  310. if (yyn < 0)
  311. {
  312. if (yyn == YYFLAG)
  313. goto yyerrlab;
  314. yyn = -yyn;
  315. goto yyreduce;
  316. }
  317. else if (yyn == 0)
  318. goto yyerrlab;
  319. if (yyn == YYFINAL)
  320. YYACCEPT;
  321. /* Shift the lookahead token. */
  322. #if YYDEBUG != 0
  323. if (yydebug)
  324. fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  325. #endif
  326. /* Discard the token being shifted unless it is eof. */
  327. if (yychar != YYEOF)
  328. yychar = YYEMPTY;
  329. *++yyvsp = yylval;
  330. #ifdef YYLSP_NEEDED
  331. *++yylsp = yylloc;
  332. #endif
  333. /* count tokens shifted since error; after three, turn off error status. */
  334. if (yyerrstatus) yyerrstatus--;
  335. yystate = yyn;
  336. goto yynewstate;
  337. /* Do the default action for the current state. */
  338. yydefault:
  339. yyn = yydefact[yystate];
  340. if (yyn == 0)
  341. goto yyerrlab;
  342. /* Do a reduction. yyn is the number of a rule to reduce with. */
  343. yyreduce:
  344. yylen = yyr2[yyn];
  345. yyval = yyvsp[1-yylen]; /* implement default value of the action */
  346. #if YYDEBUG != 0
  347. if (yydebug)
  348. {
  349. int i;
  350. fprintf (stderr, "Reducing via rule %d (line %d), ",
  351. yyn, yyrline[yyn]);
  352. /* Print the symbols being reduced, and their result. */
  353. for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  354. fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  355. fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  356. }
  357. #endif
  358. $ /* the action file gets copied in in place of this dollarsign */
  359. #line 442 "bison.simple"
  360. yyvsp -= yylen;
  361. yyssp -= yylen;
  362. #ifdef YYLSP_NEEDED
  363. yylsp -= yylen;
  364. #endif
  365. #if YYDEBUG != 0
  366. if (yydebug)
  367. {
  368. short *ssp1 = yyss - 1;
  369. fprintf (stderr, "state stack now");
  370. while (ssp1 != yyssp)
  371. fprintf (stderr, " %d", *++ssp1);
  372. fprintf (stderr, "\n");
  373. }
  374. #endif
  375. *++yyvsp = yyval;
  376. #ifdef YYLSP_NEEDED
  377. yylsp++;
  378. if (yylen == 0)
  379. {
  380. yylsp->first_line = yylloc.first_line;
  381. yylsp->first_column = yylloc.first_column;
  382. yylsp->last_line = (yylsp-1)->last_line;
  383. yylsp->last_column = (yylsp-1)->last_column;
  384. yylsp->text = 0;
  385. }
  386. else
  387. {
  388. yylsp->last_line = (yylsp+yylen-1)->last_line;
  389. yylsp->last_column = (yylsp+yylen-1)->last_column;
  390. }
  391. #endif
  392. /* Now "shift" the result of the reduction.
  393. Determine what state that goes to,
  394. based on the state we popped back to
  395. and the rule number reduced by. */
  396. yyn = yyr1[yyn];
  397. yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  398. if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  399. yystate = yytable[yystate];
  400. else
  401. yystate = yydefgoto[yyn - YYNTBASE];
  402. goto yynewstate;
  403. yyerrlab: /* here on detecting error */
  404. if (! yyerrstatus)
  405. /* If not already recovering from an error, report this error. */
  406. {
  407. ++yynerrs;
  408. #ifdef YYERROR_VERBOSE
  409. yyn = yypact[yystate];
  410. if (yyn > YYFLAG && yyn < YYLAST)
  411. {
  412. int size = 0;
  413. char *msg;
  414. int x, count;
  415. count = 0;
  416. for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  417. if (yycheck[x + yyn] == x)
  418. size += strlen(yytname[x]) + 15, count++;
  419. msg = (char *) malloc(size + 15);
  420. if (msg != 0)
  421. {
  422. strcpy(msg, "parse error");
  423. if (count < 5)
  424. {
  425. count = 0;
  426. for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  427. if (yycheck[x + yyn] == x)
  428. {
  429. strcat(msg, count == 0 ? ", expecting `" : " or `");
  430. strcat(msg, yytname[x]);
  431. strcat(msg, "'");
  432. count++;
  433. }
  434. }
  435. yyerror(msg);
  436. free(msg);
  437. }
  438. else
  439. yyerror ("parse error; also virtual memory exceeded");
  440. }
  441. else
  442. #endif /* YYERROR_VERBOSE */
  443. yyerror("parse error");
  444. }
  445. goto yyerrlab1;
  446. yyerrlab1: /* here on error raised explicitly by an action */
  447. if (yyerrstatus == 3)
  448. {
  449. /* if just tried and failed to reuse lookahead token after an error, discard it. */
  450. /* return failure if at end of input */
  451. if (yychar == YYEOF)
  452. YYABORT;
  453. #if YYDEBUG != 0
  454. if (yydebug)
  455. fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  456. #endif
  457. yychar = YYEMPTY;
  458. }
  459. /* Else will try to reuse lookahead token
  460. after shifting the error token. */
  461. yyerrstatus = 3; /* Each real token shifted decrements this */
  462. goto yyerrhandle;
  463. yyerrdefault: /* current state does not do anything special for the error token. */
  464. #if 0
  465. /* This is wrong; only states that explicitly want error tokens
  466. should shift them. */
  467. yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
  468. if (yyn) goto yydefault;
  469. #endif
  470. yyerrpop: /* pop the current state because it cannot handle the error token */
  471. if (yyssp == yyss) YYABORT;
  472. yyvsp--;
  473. yystate = *--yyssp;
  474. #ifdef YYLSP_NEEDED
  475. yylsp--;
  476. #endif
  477. #if YYDEBUG != 0
  478. if (yydebug)
  479. {
  480. short *ssp1 = yyss - 1;
  481. fprintf (stderr, "Error: state stack now");
  482. while (ssp1 != yyssp)
  483. fprintf (stderr, " %d", *++ssp1);
  484. fprintf (stderr, "\n");
  485. }
  486. #endif
  487. yyerrhandle:
  488. yyn = yypact[yystate];
  489. if (yyn == YYFLAG)
  490. goto yyerrdefault;
  491. yyn += YYTERROR;
  492. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  493. goto yyerrdefault;
  494. yyn = yytable[yyn];
  495. if (yyn < 0)
  496. {
  497. if (yyn == YYFLAG)
  498. goto yyerrpop;
  499. yyn = -yyn;
  500. goto yyreduce;
  501. }
  502. else if (yyn == 0)
  503. goto yyerrpop;
  504. if (yyn == YYFINAL)
  505. YYACCEPT;
  506. #if YYDEBUG != 0
  507. if (yydebug)
  508. fprintf(stderr, "Shifting error token, ");
  509. #endif
  510. *++yyvsp = yylval;
  511. #ifdef YYLSP_NEEDED
  512. *++yylsp = yylloc;
  513. #endif
  514. yystate = yyn;
  515. goto yynewstate;
  516. }