home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / bisn119b / bison.sim < prev    next >
Text File  |  1993-07-29  |  16KB  |  641 lines

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