bison.simple 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  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__)
  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. #ifdef AMIGA
  42. #define bzero(b, length) memset((b),'\0',(length))
  43. #define bcopy(b1, b2, length) memcpy((b1),(b2),(length))
  44. #define bcmp(b1, b2, length) memcmp((b1),(b2),(length))
  45. #include <stdlib.h>
  46. /* extern char *calloc();*/
  47. /* extern void done();*/
  48. /* extern char *program_name;*/
  49. char *
  50. mallocate(n)
  51. register unsigned n;
  52. {
  53. register char *block;
  54. /* Avoid uncertainty about what an arg of 0 will do. */
  55. if (n == 0)
  56. n = 1;
  57. block = calloc(n,1);
  58. if (block == NULL)
  59. {
  60. fprintf(stderr, "Bison: memory exhausted\n");
  61. /*done(1);*/ exit(1);
  62. }
  63. return (block);
  64. }
  65. /* This name is used by alloca.c. */
  66. char *
  67. xmalloc (n)
  68. unsigned int n;
  69. {
  70. return mallocate (n);
  71. }
  72. /*
  73. alloca -- (mostly) portable public-domain implementation -- D A Gwyn
  74. last edit: 86/05/30 rms
  75. include config.h, since on VMS it renames some symbols.
  76. Use xmalloc instead of malloc.
  77. This implementation of the PWB library alloca() function,
  78. which is used to allocate space off the run-time stack so
  79. that it is automatically reclaimed upon procedure exit,
  80. was inspired by discussions with J. Q. Johnson of Cornell.
  81. It should work under any C implementation that uses an
  82. actual procedure stack (as opposed to a linked list of
  83. frames). There are some preprocessor constants that can
  84. be defined when compiling for your specific system, for
  85. improved efficiency; however, the defaults should be okay.
  86. The general concept of this implementation is to keep
  87. track of all alloca()-allocated blocks, and reclaim any
  88. that are found to be deeper in the stack than the current
  89. invocation. This heuristic does not reclaim storage as
  90. soon as it becomes invalid, but it will do so eventually.
  91. As a special case, alloca(0) reclaims storage without
  92. allocating any. It is a good idea to use alloca(0) in
  93. your main control loop, etc. to force garbage collection.
  94. */
  95. #ifndef lint
  96. static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */
  97. #endif
  98. #ifdef emacs
  99. #include "config.h"
  100. #ifdef static
  101. /* actually, only want this if static is defined as ""
  102. -- this is for usg, in which emacs must undefine static
  103. in order to make unexec workable
  104. */
  105. #ifndef STACK_DIRECTION
  106. you
  107. lose
  108. -- must know STACK_DIRECTION at compile-time
  109. #endif /* STACK_DIRECTION undefined */
  110. #endif /* static */
  111. #endif /* emacs */
  112. #ifdef __STDC__
  113. typedef void *pointer; /* generic pointer type */
  114. #else
  115. typedef char *pointer; /* generic pointer type */
  116. #endif
  117. extern void free();
  118. /* extern pointer xmalloc();*/
  119. /*
  120. Define STACK_DIRECTION if you know the direction of stack
  121. growth for your system; otherwise it will be automatically
  122. deduced at run-time.
  123. STACK_DIRECTION > 0 => grows toward higher addresses
  124. STACK_DIRECTION < 0 => grows toward lower addresses
  125. STACK_DIRECTION = 0 => direction of growth unknown
  126. */
  127. #ifndef STACK_DIRECTION
  128. #define STACK_DIRECTION 0 /* direction unknown */
  129. #endif
  130. #if STACK_DIRECTION != 0
  131. #define STACK_DIR STACK_DIRECTION /* known at compile-time */
  132. #else /* STACK_DIRECTION == 0; need run-time code */
  133. static int stack_dir; /* 1 or -1 once known */
  134. #define STACK_DIR stack_dir
  135. static void
  136. find_stack_direction (/* void */)
  137. {
  138. static char *addr = NULL; /* address of first
  139. `dummy', once known */
  140. auto char dummy; /* to get stack address */
  141. if (addr == NULL)
  142. { /* initial entry */
  143. addr = &dummy;
  144. find_stack_direction (); /* recurse once */
  145. }
  146. else /* second entry */
  147. if (&dummy > addr)
  148. stack_dir = 1; /* stack grew upward */
  149. else
  150. stack_dir = -1; /* stack grew downward */
  151. }
  152. #endif /* STACK_DIRECTION == 0 */
  153. /*
  154. An "alloca header" is used to:
  155. (a) chain together all alloca()ed blocks;
  156. (b) keep track of stack depth.
  157. It is very important that sizeof(header) agree with malloc()
  158. alignment chunk size. The following default should work okay.
  159. */
  160. #ifndef ALIGN_SIZE
  161. #define ALIGN_SIZE sizeof(double)
  162. #endif
  163. typedef union hdr
  164. {
  165. char align[ALIGN_SIZE]; /* to force sizeof(header) */
  166. struct
  167. {
  168. union hdr *next; /* for chaining headers */
  169. char *deep; /* for stack depth measure */
  170. } h;
  171. } header;
  172. /*
  173. alloca( size ) returns a pointer to at least `size' bytes of
  174. storage which will be automatically reclaimed upon exit from
  175. the procedure that called alloca(). Originally, this space
  176. was supposed to be taken from the current stack frame of the
  177. caller, but that method cannot be made to work for some
  178. implementations of C, for example under Gould's UTX/32.
  179. */
  180. static header *last_alloca_header = NULL; /* -> last alloca header */
  181. pointer
  182. alloca (size) /* returns pointer to storage */
  183. unsigned size; /* # bytes to allocate */
  184. {
  185. auto char probe; /* probes stack depth: */
  186. register char *depth = &probe;
  187. #if STACK_DIRECTION == 0
  188. if (STACK_DIR == 0) /* unknown growth direction */
  189. find_stack_direction ();
  190. #endif
  191. /* Reclaim garbage, defined as all alloca()ed storage that
  192. was allocated from deeper in the stack than currently. */
  193. {
  194. register header *hp; /* traverses linked list */
  195. for (hp = last_alloca_header; hp != NULL;)
  196. if ((STACK_DIR > 0 && hp->h.deep > depth)
  197. || (STACK_DIR < 0 && hp->h.deep < depth))
  198. {
  199. register header *np = hp->h.next;
  200. free ((pointer) hp); /* collect garbage */
  201. hp = np; /* -> next header */
  202. }
  203. else
  204. break; /* rest are not deeper */
  205. last_alloca_header = hp; /* -> last valid storage */
  206. }
  207. if (size == 0)
  208. return NULL; /* no allocation required */
  209. /* Allocate combined header + user data storage. */
  210. {
  211. register pointer new = xmalloc (sizeof (header) + size);
  212. /* address of header */
  213. ((header *)new)->h.next = last_alloca_header;
  214. ((header *)new)->h.deep = depth;
  215. last_alloca_header = (header *)new;
  216. /* User storage begins just after header. */
  217. return (pointer)((char *)new + sizeof(header));
  218. }
  219. }
  220. #endif
  221. #define yyerrok (yyerrstatus = 0)
  222. #define yyclearin (yychar = YYEMPTY)
  223. #define YYEMPTY -2
  224. #define YYEOF 0
  225. #define YYACCEPT return(0)
  226. #define YYABORT return(1)
  227. #define YYERROR goto yyerrlab1
  228. /* Like YYERROR except do call yyerror.
  229. This remains here temporarily to ease the
  230. transition to the new meaning of YYERROR, for GCC.
  231. Once GCC version 2 has supplanted version 1, this can go. */
  232. #define YYFAIL goto yyerrlab
  233. #define YYRECOVERING() (!!yyerrstatus)
  234. #define YYBACKUP(token, value) \
  235. do \
  236. if (yychar == YYEMPTY && yylen == 1) \
  237. { yychar = (token), yylval = (value); \
  238. yychar1 = YYTRANSLATE (yychar); \
  239. YYPOPSTACK; \
  240. goto yybackup; \
  241. } \
  242. else \
  243. { yyerror ("syntax error: cannot back up"); YYERROR; } \
  244. while (0)
  245. #define YYTERROR 1
  246. #define YYERRCODE 256
  247. #ifndef YYPURE
  248. #define YYLEX yylex()
  249. #endif
  250. #ifdef YYPURE
  251. #ifdef YYLSP_NEEDED
  252. #define YYLEX yylex(&yylval, &yylloc)
  253. #else
  254. #define YYLEX yylex(&yylval)
  255. #endif
  256. #endif
  257. /* If nonreentrant, generate the variables here */
  258. #ifndef YYPURE
  259. int yychar; /* the lookahead symbol */
  260. YYSTYPE yylval; /* the semantic value of the */
  261. /* lookahead symbol */
  262. #ifdef YYLSP_NEEDED
  263. YYLTYPE yylloc; /* location data for the lookahead */
  264. /* symbol */
  265. #endif
  266. int yynerrs; /* number of parse errors so far */
  267. #endif /* not YYPURE */
  268. #if YYDEBUG != 0
  269. int yydebug; /* nonzero means print parse trace */
  270. /* Since this is uninitialized, it does not stop multiple parsers
  271. from coexisting. */
  272. #endif
  273. /* YYINITDEPTH indicates the initial size of the parser's stacks */
  274. #ifndef YYINITDEPTH
  275. #define YYINITDEPTH 200
  276. #endif
  277. /* YYMAXDEPTH is the maximum size the stacks can grow to
  278. (effective only if the built-in stack extension method is used). */
  279. #if YYMAXDEPTH == 0
  280. #undef YYMAXDEPTH
  281. #endif
  282. #ifndef YYMAXDEPTH
  283. #define YYMAXDEPTH 10000
  284. #endif
  285. #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
  286. #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
  287. #else /* not GNU C or C++ */
  288. #ifndef __cplusplus
  289. /* This is the most reliable way to avoid incompatibilities
  290. in available built-in functions on various systems. */
  291. static void
  292. __yy_bcopy (from, to, count)
  293. char *from;
  294. char *to;
  295. int count;
  296. {
  297. register char *f = from;
  298. register char *t = to;
  299. register int i = count;
  300. while (i-- > 0)
  301. *t++ = *f++;
  302. }
  303. #else /* __cplusplus */
  304. /* This is the most reliable way to avoid incompatibilities
  305. in available built-in functions on various systems. */
  306. static void
  307. __yy_bcopy (char *from, char *to, int count)
  308. {
  309. register char *f = from;
  310. register char *t = to;
  311. register int i = count;
  312. while (i-- > 0)
  313. *t++ = *f++;
  314. }
  315. #endif
  316. #endif
  317. #line 169 "bison.simple"
  318. int
  319. yyparse()
  320. {
  321. register int yystate;
  322. register int yyn;
  323. register short *yyssp;
  324. register YYSTYPE *yyvsp;
  325. int yyerrstatus; /* number of tokens to shift before error messages enabled */
  326. int yychar1; /* lookahead token as an internal (translated) token number */
  327. short yyssa[YYINITDEPTH]; /* the state stack */
  328. YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
  329. short *yyss = yyssa; /* refer to the stacks thru separate pointers */
  330. YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
  331. #ifdef YYLSP_NEEDED
  332. YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
  333. YYLTYPE *yyls = yylsa;
  334. YYLTYPE *yylsp;
  335. #define YYPOPSTACK (yyvsp--, yysp--, yylsp--)
  336. #else
  337. #define YYPOPSTACK (yyvsp--, yysp--)
  338. #endif
  339. int yystacksize = YYINITDEPTH;
  340. #ifdef YYPURE
  341. int yychar;
  342. YYSTYPE yylval;
  343. int yynerrs;
  344. #ifdef YYLSP_NEEDED
  345. YYLTYPE yylloc;
  346. #endif
  347. #endif
  348. YYSTYPE yyval; /* the variable used to return */
  349. /* semantic values from the action */
  350. /* routines */
  351. int yylen;
  352. #if YYDEBUG != 0
  353. if (yydebug)
  354. fprintf(stderr, "Starting parse\n");
  355. #endif
  356. yystate = 0;
  357. yyerrstatus = 0;
  358. yynerrs = 0;
  359. yychar = YYEMPTY; /* Cause a token to be read. */
  360. /* Initialize stack pointers.
  361. Waste one element of value and location stack
  362. so that they stay on the same level as the state stack. */
  363. yyssp = yyss - 1;
  364. yyvsp = yyvs;
  365. #ifdef YYLSP_NEEDED
  366. yylsp = yyls;
  367. #endif
  368. /* Push a new state, which is found in yystate . */
  369. /* In all cases, when you get here, the value and location stacks
  370. have just been pushed. so pushing a state here evens the stacks. */
  371. yynewstate:
  372. *++yyssp = yystate;
  373. if (yyssp >= yyss + yystacksize - 1)
  374. {
  375. /* Give user a chance to reallocate the stack */
  376. /* Use copies of these so that the &'s don't force the real ones into memory. */
  377. YYSTYPE *yyvs1 = yyvs;
  378. short *yyss1 = yyss;
  379. #ifdef YYLSP_NEEDED
  380. YYLTYPE *yyls1 = yyls;
  381. #endif
  382. /* Get the current used size of the three stacks, in elements. */
  383. int size = yyssp - yyss + 1;
  384. #ifdef yyoverflow
  385. /* Each stack pointer address is followed by the size of
  386. the data in use in that stack, in bytes. */
  387. yyoverflow("parser stack overflow",
  388. &yyss1, size * sizeof (*yyssp),
  389. &yyvs1, size * sizeof (*yyvsp),
  390. #ifdef YYLSP_NEEDED
  391. &yyls1, size * sizeof (*yylsp),
  392. #endif
  393. &yystacksize);
  394. yyss = yyss1; yyvs = yyvs1;
  395. #ifdef YYLSP_NEEDED
  396. yyls = yyls1;
  397. #endif
  398. #else /* no yyoverflow */
  399. /* Extend the stack our own way. */
  400. if (yystacksize >= YYMAXDEPTH)
  401. {
  402. yyerror("parser stack overflow");
  403. return 2;
  404. }
  405. yystacksize *= 2;
  406. if (yystacksize > YYMAXDEPTH)
  407. yystacksize = YYMAXDEPTH;
  408. yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  409. __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  410. yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  411. __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  412. #ifdef YYLSP_NEEDED
  413. yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  414. __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  415. #endif
  416. #endif /* no yyoverflow */
  417. yyssp = yyss + size - 1;
  418. yyvsp = yyvs + size - 1;
  419. #ifdef YYLSP_NEEDED
  420. yylsp = yyls + size - 1;
  421. #endif
  422. #if YYDEBUG != 0
  423. if (yydebug)
  424. fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  425. #endif
  426. if (yyssp >= yyss + yystacksize - 1)
  427. YYABORT;
  428. }
  429. #if YYDEBUG != 0
  430. if (yydebug)
  431. fprintf(stderr, "Entering state %d\n", yystate);
  432. #endif
  433. yybackup:
  434. /* Do appropriate processing given the current state. */
  435. /* Read a lookahead token if we need one and don't already have one. */
  436. /* yyresume: */
  437. /* First try to decide what to do without reference to lookahead token. */
  438. yyn = yypact[yystate];
  439. if (yyn == YYFLAG)
  440. goto yydefault;
  441. /* Not known => get a lookahead token if don't already have one. */
  442. /* yychar is either YYEMPTY or YYEOF
  443. or a valid token in external form. */
  444. if (yychar == YYEMPTY)
  445. {
  446. #if YYDEBUG != 0
  447. if (yydebug)
  448. fprintf(stderr, "Reading a token: ");
  449. #endif
  450. yychar = YYLEX;
  451. }
  452. /* Convert token to internal form (in yychar1) for indexing tables with */
  453. if (yychar <= 0) /* This means end of input. */
  454. {
  455. yychar1 = 0;
  456. yychar = YYEOF; /* Don't call YYLEX any more */
  457. #if YYDEBUG != 0
  458. if (yydebug)
  459. fprintf(stderr, "Now at end of input.\n");
  460. #endif
  461. }
  462. else
  463. {
  464. yychar1 = YYTRANSLATE(yychar);
  465. #if YYDEBUG != 0
  466. if (yydebug)
  467. {
  468. fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  469. /* Give the individual parser a way to print the precise meaning
  470. of a token, for further debugging info. */
  471. #ifdef YYPRINT
  472. YYPRINT (stderr, yychar, yylval);
  473. #endif
  474. fprintf (stderr, ")\n");
  475. }
  476. #endif
  477. }
  478. yyn += yychar1;
  479. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  480. goto yydefault;
  481. yyn = yytable[yyn];
  482. /* yyn is what to do for this token type in this state.
  483. Negative => reduce, -yyn is rule number.
  484. Positive => shift, yyn is new state.
  485. New state is final state => don't bother to shift,
  486. just return success.
  487. 0, or most negative number => error. */
  488. if (yyn < 0)
  489. {
  490. if (yyn == YYFLAG)
  491. goto yyerrlab;
  492. yyn = -yyn;
  493. goto yyreduce;
  494. }
  495. else if (yyn == 0)
  496. goto yyerrlab;
  497. if (yyn == YYFINAL)
  498. YYACCEPT;
  499. /* Shift the lookahead token. */
  500. #if YYDEBUG != 0
  501. if (yydebug)
  502. fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  503. #endif
  504. /* Discard the token being shifted unless it is eof. */
  505. if (yychar != YYEOF)
  506. yychar = YYEMPTY;
  507. *++yyvsp = yylval;
  508. #ifdef YYLSP_NEEDED
  509. *++yylsp = yylloc;
  510. #endif
  511. /* count tokens shifted since error; after three, turn off error status. */
  512. if (yyerrstatus) yyerrstatus--;
  513. yystate = yyn;
  514. goto yynewstate;
  515. /* Do the default action for the current state. */
  516. yydefault:
  517. yyn = yydefact[yystate];
  518. if (yyn == 0)
  519. goto yyerrlab;
  520. /* Do a reduction. yyn is the number of a rule to reduce with. */
  521. yyreduce:
  522. yylen = yyr2[yyn];
  523. yyval = yyvsp[1-yylen]; /* implement default value of the action */
  524. #if YYDEBUG != 0
  525. if (yydebug)
  526. {
  527. int i;
  528. fprintf (stderr, "Reducing via rule %d (line %d), ",
  529. yyn, yyrline[yyn]);
  530. /* Print the symboles being reduced, and their result. */
  531. for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  532. fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  533. fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  534. }
  535. #endif
  536. $ /* the action file gets copied in in place of this dollarsign */
  537. #line 440 "bison.simple"
  538. yyvsp -= yylen;
  539. yyssp -= yylen;
  540. #ifdef YYLSP_NEEDED
  541. yylsp -= yylen;
  542. #endif
  543. #if YYDEBUG != 0
  544. if (yydebug)
  545. {
  546. short *ssp1 = yyss - 1;
  547. fprintf (stderr, "state stack now");
  548. while (ssp1 != yyssp)
  549. fprintf (stderr, " %d", *++ssp1);
  550. fprintf (stderr, "\n");
  551. }
  552. #endif
  553. *++yyvsp = yyval;
  554. #ifdef YYLSP_NEEDED
  555. yylsp++;
  556. if (yylen == 0)
  557. {
  558. yylsp->first_line = yylloc.first_line;
  559. yylsp->first_column = yylloc.first_column;
  560. yylsp->last_line = (yylsp-1)->last_line;
  561. yylsp->last_column = (yylsp-1)->last_column;
  562. yylsp->text = 0;
  563. }
  564. else
  565. {
  566. yylsp->last_line = (yylsp+yylen-1)->last_line;
  567. yylsp->last_column = (yylsp+yylen-1)->last_column;
  568. }
  569. #endif
  570. /* Now "shift" the result of the reduction.
  571. Determine what state that goes to,
  572. based on the state we popped back to
  573. and the rule number reduced by. */
  574. yyn = yyr1[yyn];
  575. yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  576. if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  577. yystate = yytable[yystate];
  578. else
  579. yystate = yydefgoto[yyn - YYNTBASE];
  580. goto yynewstate;
  581. yyerrlab: /* here on detecting error */
  582. if (! yyerrstatus)
  583. /* If not already recovering from an error, report this error. */
  584. {
  585. ++yynerrs;
  586. #ifdef YYERROR_VERBOSE
  587. yyn = yypact[yystate];
  588. if (yyn > YYFLAG && yyn < YYLAST)
  589. {
  590. int size = 0;
  591. char *msg;
  592. int x, count;
  593. count = 0;
  594. for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  595. if (yycheck[x + yyn] == x)
  596. size += strlen(yytname[x]) + 15, count++;
  597. msg = (char *) xmalloc(size + 15);
  598. strcpy(msg, "parse error");
  599. if (count < 5)
  600. {
  601. count = 0;
  602. for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  603. if (yycheck[x + yyn] == x)
  604. {
  605. strcat(msg, count == 0 ? ", expecting `" : " or `");
  606. strcat(msg, yytname[x]);
  607. strcat(msg, "'");
  608. count++;
  609. }
  610. }
  611. yyerror(msg);
  612. free(msg);
  613. }
  614. else
  615. #endif /* YYERROR_VERBOSE */
  616. yyerror("parse error");
  617. }
  618. yyerrlab1: /* here on error raised explicitly by an action */
  619. if (yyerrstatus == 3)
  620. {
  621. /* if just tried and failed to reuse lookahead token after an error, discard it. */
  622. /* return failure if at end of input */
  623. if (yychar == YYEOF)
  624. YYABORT;
  625. #if YYDEBUG != 0
  626. if (yydebug)
  627. fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  628. #endif
  629. yychar = YYEMPTY;
  630. }
  631. /* Else will try to reuse lookahead token
  632. after shifting the error token. */
  633. yyerrstatus = 3; /* Each real token shifted decrements this */
  634. goto yyerrhandle;
  635. yyerrdefault: /* current state does not do anything special for the error token. */
  636. #if 0
  637. /* This is wrong; only states that explicitly want error tokens
  638. should shift them. */
  639. yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
  640. if (yyn) goto yydefault;
  641. #endif
  642. yyerrpop: /* pop the current state because it cannot handle the error token */
  643. if (yyssp == yyss) YYABORT;
  644. yyvsp--;
  645. yystate = *--yyssp;
  646. #ifdef YYLSP_NEEDED
  647. yylsp--;
  648. #endif
  649. #if YYDEBUG != 0
  650. if (yydebug)
  651. {
  652. short *ssp1 = yyss - 1;
  653. fprintf (stderr, "Error: state stack now");
  654. while (ssp1 != yyssp)
  655. fprintf (stderr, " %d", *++ssp1);
  656. fprintf (stderr, "\n");
  657. }
  658. #endif
  659. yyerrhandle:
  660. yyn = yypact[yystate];
  661. if (yyn == YYFLAG)
  662. goto yyerrdefault;
  663. yyn += YYTERROR;
  664. if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  665. goto yyerrdefault;
  666. yyn = yytable[yyn];
  667. if (yyn < 0)
  668. {
  669. if (yyn == YYFLAG)
  670. goto yyerrpop;
  671. yyn = -yyn;
  672. goto yyreduce;
  673. }
  674. else if (yyn == 0)
  675. goto yyerrpop;
  676. if (yyn == YYFINAL)
  677. YYACCEPT;
  678. #if YYDEBUG != 0
  679. if (yydebug)
  680. fprintf(stderr, "Shifting error token, ");
  681. #endif
  682. *++yyvsp = yylval;
  683. #ifdef YYLSP_NEEDED
  684. *++yylsp = yylloc;
  685. #endif
  686. yystate = yyn;
  687. goto yynewstate;
  688. }