home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / binutils / arparse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  25.9 KB  |  966 lines

  1.  
  2. /*  A Bison parser, made from arparse.y with Bison version GNU Bison version 1.21
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    NEWLINE    258
  8. #define    VERBOSE    259
  9. #define    FILENAME    260
  10. #define    ADDLIB    261
  11. #define    LIST    262
  12. #define    ADDMOD    263
  13. #define    CLEAR    264
  14. #define    CREATE    265
  15. #define    DELETE    266
  16. #define    DIRECTORY    267
  17. #define    END    268
  18. #define    EXTRACT    269
  19. #define    FULLDIR    270
  20. #define    HELP    271
  21. #define    QUIT    272
  22. #define    REPLACE    273
  23. #define    SAVE    274
  24. #define    OPEN    275
  25.  
  26. #line 1 "arparse.y"
  27.  
  28. /* arparse.y - Stange script language parser */
  29.  
  30. /*   Copyright (C) 1992 Free Software Foundation, Inc.
  31.  
  32. This file is part of GNU Binutils.
  33.  
  34. This program is free software; you can redistribute it and/or modify
  35. it under the terms of the GNU General Public License as published by
  36. the Free Software Foundation; either version 2 of the License, or
  37. (at your option) any later version.
  38.  
  39. This program is distributed in the hope that it will be useful,
  40. but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42. GNU General Public License for more details.
  43.  
  44. You should have received a copy of the GNU General Public License
  45. along with this program; if not, write to the Free Software
  46. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  47.  
  48.  
  49. /* Contributed by Steve Chamberlain
  50.              sac@cygnus.com
  51.  
  52. */
  53. #define DONTDECLARE_MALLOC
  54. #include "bfd.h"
  55. #include <sysdep.h>
  56. #include "arsup.h"
  57. extern int verbose;
  58.  
  59. #line 34 "arparse.y"
  60. typedef union {
  61.   char *name;
  62. struct list *list ;
  63.  
  64. } YYSTYPE;
  65.  
  66. #ifndef YYLTYPE
  67. typedef
  68.   struct yyltype
  69.     {
  70.       int timestamp;
  71.       int first_line;
  72.       int first_column;
  73.       int last_line;
  74.       int last_column;
  75.       char *text;
  76.    }
  77.   yyltype;
  78.  
  79. #define YYLTYPE yyltype
  80. #endif
  81.  
  82. #include <stdio.h>
  83.  
  84. #ifndef __cplusplus
  85. #ifndef __STDC__
  86. #define const
  87. #endif
  88. #endif
  89.  
  90.  
  91.  
  92. #define    YYFINAL        53
  93. #define    YYFLAG        -32768
  94. #define    YYNTBASE    24
  95.  
  96. #define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 45)
  97.  
  98. static const char yytranslate[] = {     0,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,    21,
  103.     22,     2,     2,    23,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  111.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  112.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  113.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  114.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  115.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  116.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  117.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  118.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  119.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  120.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  121.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  122.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  123.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  124.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  125.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  126.     16,    17,    18,    19,    20
  127. };
  128.  
  129. #if YYDEBUG != 0
  130. static const short yyprhs[] = {     0,
  131.      0,     1,     4,     7,     8,    11,    13,    15,    17,    19,
  132.     21,    23,    25,    27,    29,    31,    33,    35,    37,    39,
  133.     41,    42,    45,    48,    50,    53,    56,    58,    60,    63,
  134.     66,    70,    75,    77,    78,    82,    83,    87,    88,    90,
  135.     91
  136. };
  137.  
  138. static const short yyrhs[] = {    -1,
  139.     25,    26,     0,    26,    27,     0,     0,    28,     3,     0,
  140.     36,     0,    37,     0,    44,     0,    39,     0,    38,     0,
  141.     31,     0,    33,     0,    35,     0,    29,     0,    30,     0,
  142.     32,     0,    34,     0,    13,     0,     1,     0,     5,     0,
  143.      0,    14,    42,     0,    18,    42,     0,     9,     0,    11,
  144.     42,     0,     8,    42,     0,     7,     0,    19,     0,    20,
  145.      5,     0,    10,     5,     0,     6,     5,    41,     0,    12,
  146.      5,    41,    40,     0,     5,     0,     0,    21,    42,    22,
  147.      0,     0,    42,    43,     5,     0,     0,    23,     0,     0,
  148.      4,     0
  149. };
  150.  
  151. #endif
  152.  
  153. #if YYDEBUG != 0
  154. static const short yyrline[] = { 0,
  155.     64,    66,    68,    70,    73,    76,    78,    79,    80,    81,
  156.     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
  157.     92,    96,   101,   106,   111,   115,   120,   125,   132,   137,
  158.    143,   147,   154,   157,   160,   163,   167,   174,   178,   180,
  159.    184
  160. };
  161.  
  162. static const char * const yytname[] = {   "$","error","$illegal.","NEWLINE",
  163. "VERBOSE","FILENAME","ADDLIB","LIST","ADDMOD","CLEAR","CREATE","DELETE","DIRECTORY",
  164. "END","EXTRACT","FULLDIR","HELP","QUIT","REPLACE","SAVE","OPEN","'('","')'",
  165. "','","start","@1","session","command_line","command","extract_command","replace_command",
  166. "clear_command","delete_command","addmod_command","list_command","save_command",
  167. "open_command","create_command","addlib_command","directory_command","optional_filename",
  168. "modulelist","modulename","optcomma","verbose_command",""
  169. };
  170. #endif
  171.  
  172. static const short yyr1[] = {     0,
  173.     25,    24,    26,    26,    27,    28,    28,    28,    28,    28,
  174.     28,    28,    28,    28,    28,    28,    28,    28,    28,    28,
  175.     28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
  176.     38,    39,    40,    40,    41,    41,    42,    42,    43,    43,
  177.     44
  178. };
  179.  
  180. static const short yyr2[] = {     0,
  181.      0,     2,     2,     0,     2,     1,     1,     1,     1,     1,
  182.      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  183.      0,     2,     2,     1,     2,     2,     1,     1,     2,     2,
  184.      3,     4,     1,     0,     3,     0,     3,     0,     1,     0,
  185.      1
  186. };
  187.  
  188. static const short yydefact[] = {     1,
  189.      4,     0,    19,    41,    20,     0,    27,    38,    24,     0,
  190.     38,     0,    18,    38,    38,    28,     0,     3,     0,    14,
  191.     15,    11,    16,    12,    17,    13,     6,     7,    10,     9,
  192.      8,    36,    26,    30,    25,    36,    22,    23,    29,     5,
  193.     38,    31,    39,     0,    34,    40,    37,    33,    32,    35,
  194.      0,     0,     0
  195. };
  196.  
  197. static const short yydefgoto[] = {    51,
  198.      1,     2,    18,    19,    20,    21,    22,    23,    24,    25,
  199.     26,    27,    28,    29,    30,    49,    42,    33,    44,    31
  200. };
  201.  
  202. static const short yypact[] = {-32768,
  203. -32768,     5,-32768,-32768,-32768,    -4,-32768,-32768,-32768,     2,
  204. -32768,    21,-32768,-32768,-32768,-32768,    22,-32768,    25,-32768,
  205. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  206. -32768,     8,    -3,-32768,    -3,     8,    -3,    -3,-32768,-32768,
  207. -32768,-32768,-32768,    26,    27,    -1,-32768,-32768,-32768,-32768,
  208.     33,    34,-32768
  209. };
  210.  
  211. static const short yypgoto[] = {-32768,
  212. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  213. -32768,-32768,-32768,-32768,-32768,-32768,     0,   -11,-32768,-32768
  214. };
  215.  
  216.  
  217. #define    YYLAST        36
  218.  
  219.  
  220. static const short yytable[] = {    35,
  221.     32,   -40,    37,    38,    -2,     3,    34,   -21,     4,     5,
  222.      6,     7,     8,     9,    10,    11,    12,    13,    14,    43,
  223.     50,    43,    15,    16,    17,    36,    39,    40,    41,    46,
  224.     47,    48,    52,    53,     0,    45
  225. };
  226.  
  227. static const short yycheck[] = {    11,
  228.      5,     5,    14,    15,     0,     1,     5,     3,     4,     5,
  229.      6,     7,     8,     9,    10,    11,    12,    13,    14,    23,
  230.     22,    23,    18,    19,    20,     5,     5,     3,    21,    41,
  231.      5,     5,     0,     0,    -1,    36
  232. };
  233. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  234. #line 3 "bison.simple"
  235.  
  236. /* Skeleton output parser for bison,
  237.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  238.  
  239.    This program is free software; you can redistribute it and/or modify
  240.    it under the terms of the GNU General Public License as published by
  241.    the Free Software Foundation; either version 1, or (at your option)
  242.    any later version.
  243.  
  244.    This program is distributed in the hope that it will be useful,
  245.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  246.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  247.    GNU General Public License for more details.
  248.  
  249.    You should have received a copy of the GNU General Public License
  250.    along with this program; if not, write to the Free Software
  251.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  252.  
  253.  
  254. #ifndef alloca
  255. #ifdef __GNUC__
  256. #define alloca __builtin_alloca
  257. #else /* not GNU C.  */
  258. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  259. #include <alloca.h>
  260. #else /* not sparc */
  261. #if defined (MSDOS) && !defined (__TURBOC__)
  262. #include <malloc.h>
  263. #else /* not MSDOS, or __TURBOC__ */
  264. #if defined(_AIX)
  265. #include <malloc.h>
  266.  #pragma alloca
  267. #endif /* not _AIX */
  268. #endif /* not MSDOS, or __TURBOC__ */
  269. #endif /* not sparc.  */
  270. #endif /* not GNU C.  */
  271. #endif /* alloca not defined.  */
  272.  
  273. /* This is the parser code that is written into each bison parser
  274.   when the %semantic_parser declaration is not specified in the grammar.
  275.   It was written by Richard Stallman by simplifying the hairy parser
  276.   used when %semantic_parser is specified.  */
  277.  
  278. /* Note: there must be only one dollar sign in this file.
  279.    It is replaced by the list of actions, each action
  280.    as one case of the switch.  */
  281.  
  282. #define yyerrok        (yyerrstatus = 0)
  283. #define yyclearin    (yychar = YYEMPTY)
  284. #define YYEMPTY        -2
  285. #define YYEOF        0
  286. #define YYACCEPT    return(0)
  287. #define YYABORT     return(1)
  288. #define YYERROR        goto yyerrlab1
  289. /* Like YYERROR except do call yyerror.
  290.    This remains here temporarily to ease the
  291.    transition to the new meaning of YYERROR, for GCC.
  292.    Once GCC version 2 has supplanted version 1, this can go.  */
  293. #define YYFAIL        goto yyerrlab
  294. #define YYRECOVERING()  (!!yyerrstatus)
  295. #define YYBACKUP(token, value) \
  296. do                                \
  297.   if (yychar == YYEMPTY && yylen == 1)                \
  298.     { yychar = (token), yylval = (value);            \
  299.       yychar1 = YYTRANSLATE (yychar);                \
  300.       YYPOPSTACK;                        \
  301.       goto yybackup;                        \
  302.     }                                \
  303.   else                                \
  304.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  305. while (0)
  306.  
  307. #define YYTERROR    1
  308. #define YYERRCODE    256
  309.  
  310. #ifndef YYPURE
  311. #define YYLEX        yylex()
  312. #endif
  313.  
  314. #ifdef YYPURE
  315. #ifdef YYLSP_NEEDED
  316. #define YYLEX        yylex(&yylval, &yylloc)
  317. #else
  318. #define YYLEX        yylex(&yylval)
  319. #endif
  320. #endif
  321.  
  322. /* If nonreentrant, generate the variables here */
  323.  
  324. #ifndef YYPURE
  325.  
  326. int    yychar;            /*  the lookahead symbol        */
  327. YYSTYPE    yylval;            /*  the semantic value of the        */
  328.                 /*  lookahead symbol            */
  329.  
  330. #ifdef YYLSP_NEEDED
  331. YYLTYPE yylloc;            /*  location data for the lookahead    */
  332.                 /*  symbol                */
  333. #endif
  334.  
  335. int yynerrs;            /*  number of parse errors so far       */
  336. #endif  /* not YYPURE */
  337.  
  338. #if YYDEBUG != 0
  339. int yydebug;            /*  nonzero means print parse trace    */
  340. /* Since this is uninitialized, it does not stop multiple parsers
  341.    from coexisting.  */
  342. #endif
  343.  
  344. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  345.  
  346. #ifndef    YYINITDEPTH
  347. #define YYINITDEPTH 200
  348. #endif
  349.  
  350. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  351.     (effective only if the built-in stack extension method is used).  */
  352.  
  353. #if YYMAXDEPTH == 0
  354. #undef YYMAXDEPTH
  355. #endif
  356.  
  357. #ifndef YYMAXDEPTH
  358. #define YYMAXDEPTH 10000
  359. #endif
  360.  
  361. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  362. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  363. #else                /* not GNU C or C++ */
  364. #ifndef __cplusplus
  365.  
  366. /* This is the most reliable way to avoid incompatibilities
  367.    in available built-in functions on various systems.  */
  368. static void
  369. __yy_bcopy (from, to, count)
  370.      char *from;
  371.      char *to;
  372.      int count;
  373. {
  374.   register char *f = from;
  375.   register char *t = to;
  376.   register int i = count;
  377.  
  378.   while (i-- > 0)
  379.     *t++ = *f++;
  380. }
  381.  
  382. #else /* __cplusplus */
  383.  
  384. /* This is the most reliable way to avoid incompatibilities
  385.    in available built-in functions on various systems.  */
  386. static void
  387. __yy_bcopy (char *from, char *to, int count)
  388. {
  389.   register char *f = from;
  390.   register char *t = to;
  391.   register int i = count;
  392.  
  393.   while (i-- > 0)
  394.     *t++ = *f++;
  395. }
  396.  
  397. #endif
  398. #endif
  399.  
  400. #line 169 "bison.simple"
  401. int
  402. yyparse()
  403. {
  404.   register int yystate;
  405.   register int yyn;
  406.   register short *yyssp;
  407.   register YYSTYPE *yyvsp;
  408.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  409.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  410.  
  411.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  412.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  413.  
  414.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  415.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  416.  
  417. #ifdef YYLSP_NEEDED
  418.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  419.   YYLTYPE *yyls = yylsa;
  420.   YYLTYPE *yylsp;
  421.  
  422. #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
  423. #else
  424. #define YYPOPSTACK   (yyvsp--, yysp--)
  425. #endif
  426.  
  427.   int yystacksize = YYINITDEPTH;
  428.  
  429. #ifdef YYPURE
  430.   int yychar;
  431.   YYSTYPE yylval;
  432.   int yynerrs;
  433. #ifdef YYLSP_NEEDED
  434.   YYLTYPE yylloc;
  435. #endif
  436. #endif
  437.  
  438.   YYSTYPE yyval;        /*  the variable used to return        */
  439.                 /*  semantic values from the action    */
  440.                 /*  routines                */
  441.  
  442.   int yylen;
  443.  
  444. #if YYDEBUG != 0
  445.   if (yydebug)
  446.     fprintf(stderr, "Starting parse\n");
  447. #endif
  448.  
  449.   yystate = 0;
  450.   yyerrstatus = 0;
  451.   yynerrs = 0;
  452.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  453.  
  454.   /* Initialize stack pointers.
  455.      Waste one element of value and location stack
  456.      so that they stay on the same level as the state stack.  */
  457.  
  458.   yyssp = yyss - 1;
  459.   yyvsp = yyvs;
  460. #ifdef YYLSP_NEEDED
  461.   yylsp = yyls;
  462. #endif
  463.  
  464. /* Push a new state, which is found in  yystate  .  */
  465. /* In all cases, when you get here, the value and location stacks
  466.    have just been pushed. so pushing a state here evens the stacks.  */
  467. yynewstate:
  468.  
  469.   *++yyssp = yystate;
  470.  
  471.   if (yyssp >= yyss + yystacksize - 1)
  472.     {
  473.       /* Give user a chance to reallocate the stack */
  474.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  475.       YYSTYPE *yyvs1 = yyvs;
  476.       short *yyss1 = yyss;
  477. #ifdef YYLSP_NEEDED
  478.       YYLTYPE *yyls1 = yyls;
  479. #endif
  480.  
  481.       /* Get the current used size of the three stacks, in elements.  */
  482.       int size = yyssp - yyss + 1;
  483.  
  484. #ifdef yyoverflow
  485.       /* Each stack pointer address is followed by the size of
  486.      the data in use in that stack, in bytes.  */
  487.       yyoverflow("parser stack overflow",
  488.          &yyss1, size * sizeof (*yyssp),
  489.          &yyvs1, size * sizeof (*yyvsp),
  490. #ifdef YYLSP_NEEDED
  491.          &yyls1, size * sizeof (*yylsp),
  492. #endif
  493.          &yystacksize);
  494.  
  495.       yyss = yyss1; yyvs = yyvs1;
  496. #ifdef YYLSP_NEEDED
  497.       yyls = yyls1;
  498. #endif
  499. #else /* no yyoverflow */
  500.       /* Extend the stack our own way.  */
  501.       if (yystacksize >= YYMAXDEPTH)
  502.     {
  503.       yyerror("parser stack overflow");
  504.       return 2;
  505.     }
  506.       yystacksize *= 2;
  507.       if (yystacksize > YYMAXDEPTH)
  508.     yystacksize = YYMAXDEPTH;
  509.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  510.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  511.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  512.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  513. #ifdef YYLSP_NEEDED
  514.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  515.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  516. #endif
  517. #endif /* no yyoverflow */
  518.  
  519.       yyssp = yyss + size - 1;
  520.       yyvsp = yyvs + size - 1;
  521. #ifdef YYLSP_NEEDED
  522.       yylsp = yyls + size - 1;
  523. #endif
  524.  
  525. #if YYDEBUG != 0
  526.       if (yydebug)
  527.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  528. #endif
  529.  
  530.       if (yyssp >= yyss + yystacksize - 1)
  531.     YYABORT;
  532.     }
  533.  
  534. #if YYDEBUG != 0
  535.   if (yydebug)
  536.     fprintf(stderr, "Entering state %d\n", yystate);
  537. #endif
  538.  
  539.  yybackup:
  540.  
  541. /* Do appropriate processing given the current state.  */
  542. /* Read a lookahead token if we need one and don't already have one.  */
  543. /* yyresume: */
  544.  
  545.   /* First try to decide what to do without reference to lookahead token.  */
  546.  
  547.   yyn = yypact[yystate];
  548.   if (yyn == YYFLAG)
  549.     goto yydefault;
  550.  
  551.   /* Not known => get a lookahead token if don't already have one.  */
  552.  
  553.   /* yychar is either YYEMPTY or YYEOF
  554.      or a valid token in external form.  */
  555.  
  556.   if (yychar == YYEMPTY)
  557.     {
  558. #if YYDEBUG != 0
  559.       if (yydebug)
  560.     fprintf(stderr, "Reading a token: ");
  561. #endif
  562.       yychar = YYLEX;
  563.     }
  564.  
  565.   /* Convert token to internal form (in yychar1) for indexing tables with */
  566.  
  567.   if (yychar <= 0)        /* This means end of input. */
  568.     {
  569.       yychar1 = 0;
  570.       yychar = YYEOF;        /* Don't call YYLEX any more */
  571.  
  572. #if YYDEBUG != 0
  573.       if (yydebug)
  574.     fprintf(stderr, "Now at end of input.\n");
  575. #endif
  576.     }
  577.   else
  578.     {
  579.       yychar1 = YYTRANSLATE(yychar);
  580.  
  581. #if YYDEBUG != 0
  582.       if (yydebug)
  583.     {
  584.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  585.       /* Give the individual parser a way to print the precise meaning
  586.          of a token, for further debugging info.  */
  587. #ifdef YYPRINT
  588.       YYPRINT (stderr, yychar, yylval);
  589. #endif
  590.       fprintf (stderr, ")\n");
  591.     }
  592. #endif
  593.     }
  594.  
  595.   yyn += yychar1;
  596.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  597.     goto yydefault;
  598.  
  599.   yyn = yytable[yyn];
  600.  
  601.   /* yyn is what to do for this token type in this state.
  602.      Negative => reduce, -yyn is rule number.
  603.      Positive => shift, yyn is new state.
  604.        New state is final state => don't bother to shift,
  605.        just return success.
  606.      0, or most negative number => error.  */
  607.  
  608.   if (yyn < 0)
  609.     {
  610.       if (yyn == YYFLAG)
  611.     goto yyerrlab;
  612.       yyn = -yyn;
  613.       goto yyreduce;
  614.     }
  615.   else if (yyn == 0)
  616.     goto yyerrlab;
  617.  
  618.   if (yyn == YYFINAL)
  619.     YYACCEPT;
  620.  
  621.   /* Shift the lookahead token.  */
  622.  
  623. #if YYDEBUG != 0
  624.   if (yydebug)
  625.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  626. #endif
  627.  
  628.   /* Discard the token being shifted unless it is eof.  */
  629.   if (yychar != YYEOF)
  630.     yychar = YYEMPTY;
  631.  
  632.   *++yyvsp = yylval;
  633. #ifdef YYLSP_NEEDED
  634.   *++yylsp = yylloc;
  635. #endif
  636.  
  637.   /* count tokens shifted since error; after three, turn off error status.  */
  638.   if (yyerrstatus) yyerrstatus--;
  639.  
  640.   yystate = yyn;
  641.   goto yynewstate;
  642.  
  643. /* Do the default action for the current state.  */
  644. yydefault:
  645.  
  646.   yyn = yydefact[yystate];
  647.   if (yyn == 0)
  648.     goto yyerrlab;
  649.  
  650. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  651. yyreduce:
  652.   yylen = yyr2[yyn];
  653.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  654.  
  655. #if YYDEBUG != 0
  656.   if (yydebug)
  657.     {
  658.       int i;
  659.  
  660.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  661.            yyn, yyrline[yyn]);
  662.  
  663.       /* Print the symboles being reduced, and their result.  */
  664.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  665.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  666.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  667.     }
  668. #endif
  669.  
  670.  
  671.   switch (yyn) {
  672.  
  673. case 1:
  674. #line 65 "arparse.y"
  675. { prompt(); ;
  676.     break;}
  677. case 5:
  678. #line 74 "arparse.y"
  679. { prompt(); ;
  680.     break;}
  681. case 18:
  682. #line 89 "arparse.y"
  683. { ar_end(); return 0; ;
  684.     break;}
  685. case 20:
  686. #line 91 "arparse.y"
  687. { yyerror("foo"); ;
  688.     break;}
  689. case 22:
  690. #line 98 "arparse.y"
  691. { ar_extract(yyvsp[0].list); ;
  692.     break;}
  693. case 23:
  694. #line 103 "arparse.y"
  695. { ar_replace(yyvsp[0].list); ;
  696.     break;}
  697. case 24:
  698. #line 108 "arparse.y"
  699. { ar_clear(); ;
  700.     break;}
  701. case 25:
  702. #line 113 "arparse.y"
  703. { ar_delete(yyvsp[0].list); ;
  704.     break;}
  705. case 26:
  706. #line 117 "arparse.y"
  707. { ar_addmod(yyvsp[0].list); ;
  708.     break;}
  709. case 27:
  710. #line 122 "arparse.y"
  711. { ar_list(); ;
  712.     break;}
  713. case 28:
  714. #line 127 "arparse.y"
  715. { ar_save(); ;
  716.     break;}
  717. case 29:
  718. #line 134 "arparse.y"
  719. { ar_open(yyvsp[0].name,0); ;
  720.     break;}
  721. case 30:
  722. #line 139 "arparse.y"
  723. { ar_open(yyvsp[0].name,1); ;
  724.     break;}
  725. case 31:
  726. #line 145 "arparse.y"
  727. { ar_addlib(yyvsp[-1].name,yyvsp[0].list); ;
  728.     break;}
  729. case 32:
  730. #line 149 "arparse.y"
  731. { ar_directory(yyvsp[-2].name, yyvsp[-1].list, yyvsp[0].name); ;
  732.     break;}
  733. case 33:
  734. #line 156 "arparse.y"
  735. { yyval.name = yyvsp[0].name; ;
  736.     break;}
  737. case 34:
  738. #line 157 "arparse.y"
  739. { yyval.name = 0; ;
  740.     break;}
  741. case 35:
  742. #line 162 "arparse.y"
  743. { yyval.list = yyvsp[-1].list; ;
  744.     break;}
  745. case 36:
  746. #line 164 "arparse.y"
  747. { yyval.list = 0; ;
  748.     break;}
  749. case 37:
  750. #line 169 "arparse.y"
  751. {     struct list *n  = (struct list *) malloc(sizeof(struct list));
  752.             n->next = yyvsp[-2].list; 
  753.             n->name = yyvsp[0].name;
  754.             yyval.list = n;
  755.          ;
  756.     break;}
  757. case 38:
  758. #line 174 "arparse.y"
  759. { yyval.list = 0; ;
  760.     break;}
  761. case 41:
  762. #line 186 "arparse.y"
  763. { verbose = !verbose; ;
  764.     break;}
  765. }
  766.    /* the action file gets copied in in place of this dollarsign */
  767. #line 440 "bison.simple"
  768.  
  769.   yyvsp -= yylen;
  770.   yyssp -= yylen;
  771. #ifdef YYLSP_NEEDED
  772.   yylsp -= yylen;
  773. #endif
  774.  
  775. #if YYDEBUG != 0
  776.   if (yydebug)
  777.     {
  778.       short *ssp1 = yyss - 1;
  779.       fprintf (stderr, "state stack now");
  780.       while (ssp1 != yyssp)
  781.     fprintf (stderr, " %d", *++ssp1);
  782.       fprintf (stderr, "\n");
  783.     }
  784. #endif
  785.  
  786.   *++yyvsp = yyval;
  787.  
  788. #ifdef YYLSP_NEEDED
  789.   yylsp++;
  790.   if (yylen == 0)
  791.     {
  792.       yylsp->first_line = yylloc.first_line;
  793.       yylsp->first_column = yylloc.first_column;
  794.       yylsp->last_line = (yylsp-1)->last_line;
  795.       yylsp->last_column = (yylsp-1)->last_column;
  796.       yylsp->text = 0;
  797.     }
  798.   else
  799.     {
  800.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  801.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  802.     }
  803. #endif
  804.  
  805.   /* Now "shift" the result of the reduction.
  806.      Determine what state that goes to,
  807.      based on the state we popped back to
  808.      and the rule number reduced by.  */
  809.  
  810.   yyn = yyr1[yyn];
  811.  
  812.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  813.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  814.     yystate = yytable[yystate];
  815.   else
  816.     yystate = yydefgoto[yyn - YYNTBASE];
  817.  
  818.   goto yynewstate;
  819.  
  820. yyerrlab:   /* here on detecting error */
  821.  
  822.   if (! yyerrstatus)
  823.     /* If not already recovering from an error, report this error.  */
  824.     {
  825.       ++yynerrs;
  826.  
  827. #ifdef YYERROR_VERBOSE
  828.       yyn = yypact[yystate];
  829.  
  830.       if (yyn > YYFLAG && yyn < YYLAST)
  831.     {
  832.       int size = 0;
  833.       char *msg;
  834.       int x, count;
  835.  
  836.       count = 0;
  837.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  838.         if (yycheck[x + yyn] == x)
  839.           size += strlen(yytname[x]) + 15, count++;
  840.       msg = (char *) xmalloc(size + 15);
  841.       strcpy(msg, "parse error");
  842.  
  843.       if (count < 5)
  844.         {
  845.           count = 0;
  846.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  847.         if (yycheck[x + yyn] == x)
  848.           {
  849.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  850.             strcat(msg, yytname[x]);
  851.             strcat(msg, "'");
  852.             count++;
  853.           }
  854.         }
  855.       yyerror(msg);
  856.       free(msg);
  857.     }
  858.       else
  859. #endif /* YYERROR_VERBOSE */
  860.     yyerror("parse error");
  861.     }
  862.  
  863. yyerrlab1:   /* here on error raised explicitly by an action */
  864.  
  865.   if (yyerrstatus == 3)
  866.     {
  867.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  868.  
  869.       /* return failure if at end of input */
  870.       if (yychar == YYEOF)
  871.     YYABORT;
  872.  
  873. #if YYDEBUG != 0
  874.       if (yydebug)
  875.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  876. #endif
  877.  
  878.       yychar = YYEMPTY;
  879.     }
  880.  
  881.   /* Else will try to reuse lookahead token
  882.      after shifting the error token.  */
  883.  
  884.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  885.  
  886.   goto yyerrhandle;
  887.  
  888. yyerrdefault:  /* current state does not do anything special for the error token. */
  889.  
  890. #if 0
  891.   /* This is wrong; only states that explicitly want error tokens
  892.      should shift them.  */
  893.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  894.   if (yyn) goto yydefault;
  895. #endif
  896.  
  897. yyerrpop:   /* pop the current state because it cannot handle the error token */
  898.  
  899.   if (yyssp == yyss) YYABORT;
  900.   yyvsp--;
  901.   yystate = *--yyssp;
  902. #ifdef YYLSP_NEEDED
  903.   yylsp--;
  904. #endif
  905.  
  906. #if YYDEBUG != 0
  907.   if (yydebug)
  908.     {
  909.       short *ssp1 = yyss - 1;
  910.       fprintf (stderr, "Error: state stack now");
  911.       while (ssp1 != yyssp)
  912.     fprintf (stderr, " %d", *++ssp1);
  913.       fprintf (stderr, "\n");
  914.     }
  915. #endif
  916.  
  917. yyerrhandle:
  918.  
  919.   yyn = yypact[yystate];
  920.   if (yyn == YYFLAG)
  921.     goto yyerrdefault;
  922.  
  923.   yyn += YYTERROR;
  924.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  925.     goto yyerrdefault;
  926.  
  927.   yyn = yytable[yyn];
  928.   if (yyn < 0)
  929.     {
  930.       if (yyn == YYFLAG)
  931.     goto yyerrpop;
  932.       yyn = -yyn;
  933.       goto yyreduce;
  934.     }
  935.   else if (yyn == 0)
  936.     goto yyerrpop;
  937.  
  938.   if (yyn == YYFINAL)
  939.     YYACCEPT;
  940.  
  941. #if YYDEBUG != 0
  942.   if (yydebug)
  943.     fprintf(stderr, "Shifting error token, ");
  944. #endif
  945.  
  946.   *++yyvsp = yylval;
  947. #ifdef YYLSP_NEEDED
  948.   *++yylsp = yylloc;
  949. #endif
  950.  
  951.   yystate = yyn;
  952.   goto yynewstate;
  953. }
  954. #line 190 "arparse.y"
  955.  
  956.  
  957.  
  958. int
  959. yyerror(x)
  960. char *x;
  961. {
  962.   extern int linenumber;
  963.   printf("Synax error in archive script, line %d\n", linenumber + 1);
  964.   return 0;
  965. }
  966.