home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / LIB / bison.simple < prev    next >
Text File  |  2009-11-06  |  12KB  |  476 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 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. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  23. #include <alloca.h>
  24. #endif
  25.  
  26. /* This is the parser code that is written into each bison parser
  27.   when the %semantic_parser declaration is not specified in the grammar.
  28.   It was written by Richard Stallman by simplifying the hairy parser
  29.   used when %semantic_parser is specified.  */
  30.  
  31. /* Note: there must be only one dollar sign in this file.
  32.    It is replaced by the list of actions, each action
  33.    as one case of the switch.  */
  34.  
  35. #define yyerrok        (yyerrstatus = 0)
  36. #define yyclearin    (yychar = YYEMPTY)
  37. #define YYEMPTY        -2
  38. #define YYEOF        0
  39. #define YYFAIL        goto yyerrlab;
  40. #define YYACCEPT    return(0)
  41. #define YYABORT     return(1)
  42. #define YYERROR        goto yyerrlab
  43.  
  44. #define YYTERROR    1
  45.  
  46. #ifndef YYIMPURE
  47. #define YYLEX        yylex()
  48. #endif
  49.  
  50. #ifndef YYPURE
  51. #define YYLEX        yylex(&yylval, &yylloc)
  52. #endif
  53.  
  54. /* If nonreentrant, generate the variables here */
  55.  
  56. #ifndef YYIMPURE
  57.  
  58. int    yychar;            /*  the lookahead symbol        */
  59. YYSTYPE    yylval;            /*  the semantic value of the        */
  60.                 /*  lookahead symbol            */
  61.  
  62. YYLTYPE yylloc;            /*  location data for the lookahead    */
  63.                 /*  symbol                */
  64.  
  65. int yynerrs;            /*  number of parse errors so far       */
  66. #endif  /* YYIMPURE */
  67.  
  68. #if YYDEBUG != 0
  69. int yydebug;            /*  nonzero means print parse trace    */
  70. /* Since this is uninitialized, it does not stop multiple parsers
  71.    from coexisting.  */
  72. #endif
  73.  
  74. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  75.  
  76. #ifndef    YYMAXDEPTH
  77. #define YYMAXDEPTH 200
  78. #endif
  79.  
  80. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  81.     (effective only if the built-in stack extension method is used).  */
  82.  
  83. #ifndef YYMAXLIMIT
  84. #define YYMAXLIMIT 10000
  85. #endif
  86.  
  87.  
  88. #line 175 "bison.simple"
  89. int
  90. yyparse()
  91. {
  92.   register int yystate;
  93.   register int yyn;
  94.   register short *yyssp;
  95.   register YYSTYPE *yyvsp;
  96.   YYLTYPE *yylsp;
  97.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  98.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  99.  
  100.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  101.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  102.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  103.  
  104.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  105.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  106.   YYLTYPE *yyls = yylsa;
  107.  
  108.   int yymaxdepth = YYMAXDEPTH;
  109.  
  110. #ifndef YYPURE
  111.   int yychar;
  112.   YYSTYPE yylval;
  113.   YYLTYPE yylloc;
  114.   int yynerrs;
  115. #endif
  116.  
  117.   YYSTYPE yyval;        /*  the variable used to return        */
  118.                 /*  semantic values from the action    */
  119.                 /*  routines                */
  120.  
  121.   int yylen;
  122.  
  123. #if YYDEBUG != 0
  124.   if (yydebug)
  125.     fprintf(stderr, "Starting parse\n");
  126. #endif
  127.  
  128.   yystate = 0;
  129.   yyerrstatus = 0;
  130.   yynerrs = 0;
  131.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  132.  
  133.   /* Initialize stack pointers.
  134.      Waste one element of value and location stack
  135.      so that they stay on the same level as the state stack.  */
  136.  
  137.   yyssp = yyss - 1;
  138.   yyvsp = yyvs;
  139.   yylsp = yyls;
  140.  
  141. /* Push a new state, which is found in  yystate  .  */
  142. /* In all cases, when you get here, the value and location stacks
  143.    have just been pushed. so pushing a state here evens the stacks.  */
  144. yynewstate:
  145.  
  146.   *++yyssp = yystate;
  147.  
  148.   if (yyssp >= yyss + yymaxdepth - 1)
  149.     {
  150.       /* Give user a chance to reallocate the stack */
  151.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  152.       YYSTYPE *yyvs1 = yyvs;
  153.       YYLTYPE *yyls1 = yyls;
  154.       short *yyss1 = yyss;
  155.  
  156.       /* Get the current used size of the three stacks, in elements.  */
  157.       int size = yyssp - yyss + 1;
  158.  
  159. #ifdef yyoverflow
  160.       /* Each stack pointer address is followed by the size of
  161.      the data in use in that stack, in bytes.  */
  162.       yyoverflow("parser stack overflow",
  163.          &yyss1, size * sizeof (*yyssp),
  164.          &yyvs1, size * sizeof (*yyvsp),
  165.          &yyls1, size * sizeof (*yylsp),
  166.          &yymaxdepth);
  167.  
  168.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  169. #else /* no yyoverflow */
  170.       /* Extend the stack our own way.  */
  171.       if (yymaxdepth >= YYMAXLIMIT)
  172.     yyerror("parser stack overflow");
  173.       yymaxdepth *= 2;
  174.       if (yymaxdepth > YYMAXLIMIT)
  175.     yymaxdepth = YYMAXLIMIT;
  176.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  177.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  178.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  179.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  180. #ifdef YYLSP_NEEDED
  181.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  182.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  183. #endif
  184. #endif /* no yyoverflow */
  185.  
  186.       yyssp = yyss + size - 1;
  187.       yyvsp = yyvs + size - 1;
  188. #ifdef YYLSP_NEEDED
  189.       yylsp = yyls + size - 1;
  190. #endif
  191.  
  192. #if YYDEBUG != 0
  193.       if (yydebug)
  194.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  195. #endif
  196.  
  197.       if (yyssp >= yyss + yymaxdepth - 1)
  198.     YYABORT;
  199.     }
  200.  
  201. #if YYDEBUG != 0
  202.   if (yydebug)
  203.     fprintf(stderr, "Entering state %d\n", yystate);
  204. #endif
  205.  
  206. /* Do appropriate processing given the current state.  */
  207. /* Read a lookahead token if we need one and don't already have one.  */
  208. yyresume:
  209.  
  210.   /* First try to decide what to do without reference to lookahead token.  */
  211.  
  212.   yyn = yypact[yystate];
  213.   if (yyn == YYFLAG)
  214.     goto yydefault;
  215.  
  216.   /* Not known => get a lookahead token if don't already have one.  */
  217.  
  218.   /* yychar is either YYEMPTY or YYEOF
  219.      or a valid token in external form.  */
  220.  
  221.   if (yychar == YYEMPTY)
  222.     {
  223. #if YYDEBUG != 0
  224.       if (yydebug)
  225.     fprintf(stderr, "Reading a token: ");
  226. #endif
  227.       yychar = YYLEX;
  228.     }
  229.  
  230.   /* Convert token to internal form (in yychar1) for indexing tables with */
  231.  
  232.   if (yychar <= 0)        /* This means end of input. */
  233.     {
  234.       yychar1 = 0;
  235.       yychar = YYEOF;        /* Don't call YYLEX any more */
  236.  
  237. #if YYDEBUG != 0
  238.       if (yydebug)
  239.     fprintf(stderr, "Now at end of input.\n");
  240. #endif
  241.     }
  242.   else
  243.     {
  244.       yychar1 = YYTRANSLATE(yychar);
  245.  
  246. #if YYDEBUG != 0
  247.       if (yydebug)
  248.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  249. #endif
  250.     }
  251.  
  252.   yyn += yychar1;
  253.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  254.     goto yydefault;
  255.  
  256.   yyn = yytable[yyn];
  257.  
  258.   /* yyn is what to do for this token type in this state.
  259.      Negative => reduce, -yyn is rule number.
  260.      Positive => shift, yyn is new state.
  261.        New state is final state => don't bother to shift,
  262.        just return success.
  263.      0, or most negative number => error.  */
  264.  
  265.   if (yyn < 0)
  266.     {
  267.       if (yyn == YYFLAG)
  268.     goto yyerrlab;
  269.       yyn = -yyn;
  270.       goto yyreduce;
  271.     }
  272.   else if (yyn == 0)
  273.     goto yyerrlab;
  274.  
  275.   if (yyn == YYFINAL)
  276.     YYACCEPT;
  277.  
  278.   /* Shift the lookahead token.  */
  279.  
  280. #if YYDEBUG != 0
  281.   if (yydebug)
  282.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  283. #endif
  284.  
  285.   /* Discard the token being shifted unless it is eof.  */
  286.   if (yychar != YYEOF)
  287.     yychar = YYEMPTY;
  288.  
  289.   *++yyvsp = yylval;
  290. #ifdef YYLSP_NEEDED
  291.   *++yylsp = yylloc;
  292. #endif
  293.  
  294.   /* count tokens shifted since error; after three, turn off error status.  */
  295.   if (yyerrstatus) yyerrstatus--;
  296.  
  297.   yystate = yyn;
  298.   goto yynewstate;
  299.  
  300. /* Do the default action for the current state.  */
  301. yydefault:
  302.  
  303.   yyn = yydefact[yystate];
  304.   if (yyn == 0)
  305.     goto yyerrlab;
  306.  
  307. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  308. yyreduce:
  309.   yylen = yyr2[yyn];
  310.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  311.  
  312. #if YYDEBUG != 0
  313.   if (yydebug)
  314.     {
  315.       if (yylen == 1)
  316.     fprintf (stderr, "Reducing 1 value via line %d, ",
  317.          yyrline[yyn]);
  318.       else
  319.     fprintf (stderr, "Reducing %d values via line %d, ",
  320.          yylen, yyrline[yyn]);
  321.     }
  322. #endif
  323.  
  324. $   /* the action file gets copied in in place of this dollarsign */
  325. #line 412 "bison.simple"
  326.  
  327.   yyvsp -= yylen;
  328.   yyssp -= yylen;
  329. #ifdef YYLSP_NEEDED
  330.   yylsp -= yylen;
  331. #endif
  332.  
  333. #if YYDEBUG != 0
  334.   if (yydebug)
  335.     {
  336.       short *ssp1 = yyss - 1;
  337.       fprintf (stderr, "state stack now");
  338.       while (ssp1 != yyssp)
  339.     fprintf (stderr, " %d", *++ssp1);
  340.       fprintf (stderr, "\n");
  341.     }
  342. #endif
  343.  
  344.   *++yyvsp = yyval;
  345.  
  346. #ifdef YYLSP_NEEDED
  347.   yylsp++;
  348.   if (yylen == 0)
  349.     {
  350.       yylsp->first_line = yylloc.first_line;
  351.       yylsp->first_column = yylloc.first_column;
  352.       yylsp->last_line = (yylsp-1)->last_line;
  353.       yylsp->last_column = (yylsp-1)->last_column;
  354.       yylsp->text = 0;
  355.     }
  356.   else
  357.     {
  358.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  359.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  360.     }
  361. #endif
  362.  
  363.   /* Now "shift" the result of the reduction.
  364.      Determine what state that goes to,
  365.      based on the state we popped back to
  366.      and the rule number reduced by.  */
  367.  
  368.   yyn = yyr1[yyn];
  369.  
  370.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  371.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  372.     yystate = yytable[yystate];
  373.   else
  374.     yystate = yydefgoto[yyn - YYNTBASE];
  375.  
  376.   goto yynewstate;
  377.  
  378. yyerrlab:   /* here on detecting error */
  379.  
  380.   if (! yyerrstatus)
  381.     /* If not already recovering from an error, report this error.  */
  382.     {
  383.       ++yynerrs;
  384.       yyerror("parse error");
  385.     }
  386.  
  387.   if (yyerrstatus == 3)
  388.     {
  389.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  390.  
  391.       /* return failure if at end of input */
  392.       if (yychar == YYEOF)
  393.     YYABORT;
  394.  
  395. #if YYDEBUG != 0
  396.       if (yydebug)
  397.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  398. #endif
  399.  
  400.       yychar = YYEMPTY;
  401.     }
  402.  
  403.   /* Else will try to reuse lookahead token
  404.      after shifting the error token.  */
  405.  
  406.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  407.  
  408.   goto yyerrhandle;
  409.  
  410. yyerrdefault:  /* current state does not do anything special for the error token. */
  411.  
  412. #if 0
  413.   /* This is wrong; only states that explicitly want error tokens
  414.      should shift them.  */
  415.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  416.   if (yyn) goto yydefault;
  417. #endif
  418.  
  419. yyerrpop:   /* pop the current state because it cannot handle the error token */
  420.  
  421.   if (yyssp == yyss) YYABORT;
  422.   yyvsp--;
  423.   yystate = *--yyssp;
  424. #ifdef YYLSP_NEEDED
  425.   yylsp--;
  426. #endif
  427.  
  428. #if YYDEBUG != 0
  429.   if (yydebug)
  430.     {
  431.       short *ssp1 = yyss - 1;
  432.       fprintf (stderr, "Error: state stack now");
  433.       while (ssp1 != yyssp)
  434.     fprintf (stderr, " %d", *++ssp1);
  435.       fprintf (stderr, "\n");
  436.     }
  437. #endif
  438.  
  439. yyerrhandle:
  440.  
  441.   yyn = yypact[yystate];
  442.   if (yyn == YYFLAG)
  443.     goto yyerrdefault;
  444.  
  445.   yyn += YYTERROR;
  446.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  447.     goto yyerrdefault;
  448.  
  449.   yyn = yytable[yyn];
  450.   if (yyn < 0)
  451.     {
  452.       if (yyn == YYFLAG)
  453.     goto yyerrpop;
  454.       yyn = -yyn;
  455.       goto yyreduce;
  456.     }
  457.   else if (yyn == 0)
  458.     goto yyerrpop;
  459.  
  460.   if (yyn == YYFINAL)
  461.     YYACCEPT;
  462.  
  463. #if YYDEBUG != 0
  464.   if (yydebug)
  465.     fprintf(stderr, "Shifting error token, ");
  466. #endif
  467.  
  468.   *++yyvsp = yylval;
  469. #ifdef YYLSP_NEEDED
  470.   *++yylsp = yylloc;
  471. #endif
  472.  
  473.   yystate = yyn;
  474.   goto yynewstate;
  475. }
  476.