home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / GCC / GCC258_5.LHA / gcc-2.5.8-amiga / bi-parser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-19  |  22.4 KB  |  895 lines

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