bison.simple 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. #line 2 "bison.simple"
  2. /* Skeleton output parser for bison,
  3. copyright (C) 1984 Bob Corbett and Richard Stallman
  4. NO WARRANTY
  5. BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  6. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
  7. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  8. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  9. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  10. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  11. FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
  12. AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
  13. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  14. CORRECTION.
  15. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  16. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  17. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  18. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  19. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  20. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  21. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  22. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  23. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  24. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  25. GENERAL PUBLIC LICENSE TO COPY
  26. 1. You may copy and distribute verbatim copies of this source file
  27. as you receive it, in any medium, provided that you conspicuously and
  28. appropriately publish on each copy a valid copyright notice "Copyright
  29. (C) 1985 Free Software Foundation, Inc."; and include following the
  30. copyright notice a verbatim copy of the above disclaimer of warranty
  31. and of this License. You may charge a distribution fee for the
  32. physical act of transferring a copy.
  33. 2. You may modify your copy or copies of this source file or
  34. any portion of it, and copy and distribute such modifications under
  35. the terms of Paragraph 1 above, provided that you also do the following:
  36. a) cause the modified files to carry prominent notices stating
  37. that you changed the files and the date of any change; and
  38. b) cause the whole of any work that you distribute or publish,
  39. that in whole or in part contains or is a derivative of this
  40. program or any part thereof, to be licensed at no charge to all
  41. third parties on terms identical to those contained in this
  42. License Agreement (except that you may choose to grant more extensive
  43. warranty protection to some or all third parties, at your option).
  44. c) You may charge a distribution fee for the physical act of
  45. transferring a copy, and you may at your option offer warranty
  46. protection in exchange for a fee.
  47. Mere aggregation of another unrelated program with this program (or its
  48. derivative) on a volume of a storage or distribution medium does not bring
  49. the other program under the scope of these terms.
  50. 3. You may copy and distribute this program (or a portion or derivative
  51. of it, under Paragraph 2) in object code or executable form under the terms
  52. of Paragraphs 1 and 2 above provided that you also do one of the following:
  53. a) accompany it with the complete corresponding machine-readable
  54. source code, which must be distributed under the terms of
  55. Paragraphs 1 and 2 above; or,
  56. b) accompany it with a written offer, valid for at least three
  57. years, to give any third party free (except for a nominal
  58. shipping charge) a complete machine-readable copy of the
  59. corresponding source code, to be distributed under the terms of
  60. Paragraphs 1 and 2 above; or,
  61. c) accompany it with the information you received as to where the
  62. corresponding source code may be obtained. (This alternative is
  63. allowed only for noncommercial distribution and only if you
  64. received the program in object code or executable form alone.)
  65. For an executable file, complete source code means all the source code for
  66. all modules it contains; but, as a special exception, it need not include
  67. source code for modules which are standard libraries that accompany the
  68. operating system on which the executable file runs.
  69. 4. You may not copy, sublicense, distribute or transfer this program
  70. except as expressly provided under this License Agreement. Any attempt
  71. otherwise to copy, sublicense, distribute or transfer this program is void and
  72. your rights to use the program under this License agreement shall be
  73. automatically terminated. However, parties who have received computer
  74. software programs from you with this License Agreement will not have
  75. their licenses terminated so long as such parties remain in full compliance.
  76. 5. If you wish to incorporate parts of this program into other free
  77. programs whose distribution conditions are different, write to the Free
  78. Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet
  79. worked out a simple rule that can be stated here, but we will often permit
  80. this. We will be guided by the two goals of preserving the free status of
  81. all derivatives of our free software and of promoting the sharing and reuse of
  82. software.
  83. In other words, you are welcome to use, share and improve this program.
  84. You are forbidden to forbid anyone else to use, share and improve
  85. what you give them. Help stamp out software-hoarding! */
  86. /* This is the parser code that is written into each bison parser
  87. when the %semantic_parser declaration is not specified in the grammar.
  88. It was written by Richard Stallman by simplifying the hairy parser
  89. used when %semantic_parser is specified. */
  90. /* Note: there must be only one dollar sign in this file.
  91. It is replaced by the list of actions, each action
  92. as one case of the switch. */
  93. #define yyerrok (yyerrstatus = 0)
  94. #define yyclearin (yychar = YYEMPTY)
  95. #define YYEMPTY -2
  96. #define YYEOF 0
  97. #define YYFAIL goto yyerrlab;
  98. #define YYTERROR 1
  99. #ifndef YYIMPURE
  100. #define YYLEX yylex()
  101. #endif
  102. #ifndef YYPURE
  103. #define YYLEX yylex(&yylval, &yylloc)
  104. #endif
  105. /* If nonreentrant, generate the variables here */
  106. #ifndef YYIMPURE
  107. int yychar; /* the lookahead symbol */
  108. YYSTYPE yylval; /* the semantic value of the */
  109. /* lookahead symbol */
  110. YYLTYPE yylloc; /* location data for the lookahead */
  111. /* symbol */
  112. int yynerr; /* number of parse errors so far */
  113. #ifdef YYDEBUG
  114. int yydebug = 0; /* nonzero means print parse trace */
  115. #endif
  116. #endif /* YYIMPURE */
  117. /* YYMAXDEPTH indicates the initial size of the parser's stacks */
  118. #ifndef YYMAXDEPTH
  119. #define YYMAXDEPTH 200
  120. #endif
  121. /* YYMAXLIMIT is the maximum size the stacks can grow to
  122. (effective only if the built-in stack extension method is used). */
  123. #ifndef YYMAXLIMIT
  124. #define YYMAXLIMIT 10000
  125. #endif
  126. #line 165 "bison.simple"
  127. int
  128. yyparse()
  129. {
  130. register int yystate;
  131. register int yyn;
  132. register short *yyssp;
  133. register YYSTYPE *yyvsp;
  134. YYLTYPE *yylsp;
  135. int yyerrstatus; /* number of tokens to shift before error messages enabled */
  136. int yychar1; /* lookahead token as an internal (translated) token number */
  137. short yyssa[YYMAXDEPTH]; /* the state stack */
  138. YYSTYPE yyvsa[YYMAXDEPTH]; /* the semantic value stack */
  139. YYLTYPE yylsa[YYMAXDEPTH]; /* the location stack */
  140. short *yyss = yyssa; /* refer to the stacks thru separate pointers */
  141. YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
  142. YYLTYPE *yyls = yylsa;
  143. int yymaxdepth = YYMAXDEPTH;
  144. #ifndef YYPURE
  145. int yychar;
  146. YYSTYPE yylval;
  147. YYLTYPE yylloc;
  148. #endif
  149. #ifdef YYDEBUG
  150. extern int yydebug;
  151. #endif
  152. YYSTYPE yyval; /* the variable used to return */
  153. /* semantic values from the action */
  154. /* routines */
  155. int yylen;
  156. #ifdef YYDEBUG
  157. if (yydebug)
  158. fprintf(stderr, "Starting parse\n");
  159. #endif
  160. yystate = 0;
  161. yyerrstatus = 0;
  162. yynerr = 0;
  163. yychar = YYEMPTY; /* Cause a token to be read. */
  164. /* Initialize stack pointers.
  165. Waste one element of value and location stack
  166. so that they stay on the same level as the state stack. */
  167. yyssp = yyss - 1;
  168. yyvsp = yyvs;
  169. yylsp = yyls;
  170. /* Push a new state, which is found in yystate . */
  171. /* In all cases, when you get here, the value and location stacks
  172. have just been pushed. so pushing a state here evens the stacks. */
  173. yynewstate:
  174. *++yyssp = yystate;
  175. if (yyssp >= yyss + yymaxdepth - 1)
  176. {
  177. /* Give user a chance to reallocate the stack */
  178. /* Use copies of these so that the &'s don't force the real ones into memory. */
  179. YYSTYPE *yyvs1 = yyvs;
  180. YYLTYPE *yyls1 = yyls;
  181. short *yyss1 = yyss;
  182. /* Get the current used size of the three stacks, in elements. */
  183. int size = yyssp - yyss + 1;
  184. #ifdef yyoverflow
  185. /* Each stack pointer address is followed by the size of
  186. the data in use in that stack, in bytes. */
  187. yyoverflow("parser stack overflow",
  188. &yyss1, size * sizeof (*yyssp),
  189. &yyvs1, size * sizeof (*yyvsp),
  190. &yyls1, size * sizeof (*yylsp),
  191. &yymaxdepth);
  192. yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  193. #else /* no yyoverflow */
  194. /* Extend the stack our own way. */
  195. if (yymaxdepth >= YYMAXLIMIT)
  196. yyerror("parser stack overflow");
  197. yymaxdepth *= 2;
  198. if (yymaxdepth > YYMAXLIMIT)
  199. yymaxdepth = YYMAXLIMIT;
  200. yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  201. bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  202. yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  203. bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  204. #ifdef YYLSP_NEEDED
  205. yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  206. bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  207. #endif
  208. #endif /* no yyoverflow */
  209. yyssp = yyss + size - 1;
  210. yyvsp = yyvs + size - 1;
  211. #ifdef YYLSP_NEEDED
  212. yylsp = yyls + size - 1;
  213. #endif
  214. #ifdef YYDEBUG
  215. if (yydebug)
  216. fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  217. #endif
  218. if (yyssp >= yyss + yymaxdepth - 1)
  219. YYERROR;
  220. }
  221. #ifdef YYDEBUG
  222. if (yydebug)
  223. fprintf(stderr, "Entering state %d\n", yystate);
  224. #endif
  225. /* Do appropriate processing given the current state. */
  226. /* Read a lookahead token if we need one and don't already have one. */
  227. yyresume:
  228. /* First try to decide what to do without reference to lookahead token. */
  229. yyn = yypact[yystate];
  230. if (yyn == YYFLAG)
  231. goto yydefault;
  232. /* Not known => get a lookahead token if don't already have one. */
  233. /* yychar is either YYEMPTY or YYEOF
  234. or a valid token in external form. */
  235. if (yychar == YYEMPTY)
  236. {
  237. #ifdef YYDEBUG
  238. if (yydebug)
  239. fprintf(stderr, "Reading a token: ");
  240. #endif
  241. yychar = YYLEX;
  242. }
  243. /* Convert token to internal form (in yychar1) for indexing tables with */
  244. if (yychar <= 0) /* This means end of input. */
  245. {
  246. yychar1 = 0;
  247. yychar = YYEOF; /* Don't call YYLEX any more */
  248. #ifdef YYDEBUG
  249. if (yydebug)
  250. fprintf(stderr, "Now at end of input.\n");
  251. #endif
  252. }
  253. else
  254. {
  255. yychar1 = YYTRANSLATE(yychar);
  256. #ifdef YYDEBUG
  257. if (yydebug)
  258. fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  259. #endif
  260. }
  261. yyn += yychar1;
  262. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  263. goto yydefault;
  264. yyn = yytable[yyn];
  265. /* yyn is what to do for this token type in this state.
  266. Negative => reduce, -yyn is rule number.
  267. Positive => shift, yyn is new state.
  268. New state is final state => don't bother to shift,
  269. just return success.
  270. 0, or most negative number => error. */
  271. if (yyn < 0)
  272. {
  273. if (yyn == YYFLAG)
  274. goto yyerrlab;
  275. yyn = -yyn;
  276. goto yyreduce;
  277. }
  278. else if (yyn == 0)
  279. goto yyerrlab;
  280. if (yyn == YYFINAL)
  281. YYACCEPT;
  282. /* Shift the lookahead token. */
  283. #ifdef YYDEBUG
  284. if (yydebug)
  285. fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  286. #endif
  287. /* Discard the token being shifted unless it is eof. */
  288. if (yychar != YYEOF)
  289. yychar = YYEMPTY;
  290. *++yyvsp = yylval;
  291. #ifdef YYLSP_NEEDED
  292. *++yylsp = yylloc;
  293. #endif
  294. /* count tokens shifted since error; after three, turn off error status. */
  295. if (yyerrstatus) yyerrstatus--;
  296. yystate = yyn;
  297. goto yynewstate;
  298. /* Do the default action for the current state. */
  299. yydefault:
  300. yyn = yydefact[yystate];
  301. if (yyn == 0)
  302. goto yyerrlab;
  303. /* Do a reduction. yyn is the number of a rule to reduce with. */
  304. yyreduce:
  305. yylen = yyr2[yyn];
  306. yyval = yyvsp[1-yylen]; /* implement default value of the action */
  307. #ifdef YYDEBUG
  308. if (yydebug)
  309. {
  310. if (yylen == 1)
  311. fprintf (stderr, "Reducing 1 value via line %d, ",
  312. yyrline[yyn]);
  313. else
  314. fprintf (stderr, "Reducing %d values via line %d, ",
  315. yylen, yyrline[yyn]);
  316. }
  317. #endif
  318. $ /* the action file gets copied in in place of this dollarsign */
  319. #line 303 "bison.simple"
  320. yyvsp -= yylen;
  321. yyssp -= yylen;
  322. #ifdef YYLSP_NEEDED
  323. yylsp -= yylen;
  324. #endif
  325. #ifdef YYDEBUG
  326. if (yydebug)
  327. {
  328. short *ssp1 = yyss - 1;
  329. fprintf (stderr, "state stack now", yyssp-yyss);
  330. while (ssp1 != yyssp)
  331. fprintf (stderr, " %d", *++ssp1);
  332. fprintf (stderr, "\n");
  333. }
  334. #endif
  335. *++yyvsp = yyval;
  336. #ifdef YYLSP_NEEDED
  337. yylsp++;
  338. if (yylen == 0)
  339. {
  340. yylsp->first_line = yylloc.first_line;
  341. yylsp->first_column = yylloc.first_column;
  342. yylsp->last_line = (yylsp-1)->last_line;
  343. yylsp->last_column = (yylsp-1)->last_column;
  344. yylsp->text = 0;
  345. }
  346. else
  347. {
  348. yylsp->last_line = (yylsp+yylen-1)->last_line;
  349. yylsp->last_column = (yylsp+yylen-1)->last_column;
  350. }
  351. #endif
  352. /* Now "shift" the result of the reduction.
  353. Determine what state that goes to,
  354. based on the state we popped back to
  355. and the rule number reduced by. */
  356. yyn = yyr1[yyn];
  357. yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  358. if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  359. yystate = yytable[yystate];
  360. else
  361. yystate = yydefgoto[yyn - YYNTBASE];
  362. goto yynewstate;
  363. yyerrlab: /* here on detecting error */
  364. if (! yyerrstatus)
  365. /* If not already recovering from an error, report this error. */
  366. {
  367. ++yynerr;
  368. yyerror("parse error");
  369. }
  370. if (yyerrstatus == 3)
  371. {
  372. /* if just tried and failed to reuse lookahead token after an error, discard it. */
  373. /* return failure if at end of input */
  374. if (yychar == YYEOF)
  375. YYERROR;
  376. #ifdef YYDEBUG
  377. if (yydebug)
  378. fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  379. #endif
  380. yychar = YYEMPTY;
  381. }
  382. /* Else will try to reuse lookahead token
  383. after shifting the error token. */
  384. yyerrstatus = 3; /* Each real token shifted decrements this */
  385. goto yyerrhandle;
  386. yyerrdefault: /* current state does not do anything special for the error token. */
  387. #if 0
  388. /* This is wrong; only states that explicitly want error tokens
  389. should shift them. */
  390. yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
  391. if (yyn) goto yydefault;
  392. #endif
  393. yyerrpop: /* pop the current state because it cannot handle the error token */
  394. if (yyssp == yyss) YYERROR;
  395. yyvsp--;
  396. yystate = *--yyssp;
  397. #ifdef YYLSP_NEEDED
  398. yylsp--;
  399. #endif
  400. #ifdef YYDEBUG
  401. if (yydebug)
  402. {
  403. short *ssp1 = yyss - 1;
  404. fprintf (stderr, "Error: state stack now", yyssp-yyss);
  405. while (ssp1 != yyssp)
  406. fprintf (stderr, " %d", *++ssp1);
  407. fprintf (stderr, "\n");
  408. }
  409. #endif
  410. yyerrhandle:
  411. yyn = yypact[yystate];
  412. if (yyn == YYFLAG)
  413. goto yyerrdefault;
  414. yyn += YYTERROR;
  415. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  416. goto yyerrdefault;
  417. yyn = yytable[yyn];
  418. if (yyn < 0)
  419. {
  420. if (yyn == YYFLAG)
  421. goto yyerrpop;
  422. yyn = -yyn;
  423. goto yyreduce;
  424. }
  425. else if (yyn == 0)
  426. goto yyerrpop;
  427. if (yyn == YYFINAL)
  428. YYACCEPT;
  429. #ifdef YYDEBUG
  430. if (yydebug)
  431. fprintf(stderr, "Shifting error token, ");
  432. #endif
  433. *++yyvsp = yylval;
  434. #ifdef YYLSP_NEEDED
  435. *++yylsp = yylloc;
  436. #endif
  437. yystate = yyn;
  438. goto yynewstate;
  439. }