bison.simple 17 KB

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