home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 213b.lha / Flex / Flex1 / parse.c < prev    next >
C/C++ Source or Header  |  1996-02-14  |  31KB  |  1,163 lines

  1.  
  2. /*  A Bison parser, made from parse.y  */
  3.  
  4. #define    CHAR    258
  5. #define    NUMBER    259
  6. #define    SECTEND    260
  7. #define    SCDECL    261
  8. #define    XSCDECL    262
  9. #define    WHITESPACE    263
  10. #define    NAME    264
  11. #define    PREVCCL    265
  12.  
  13. #line 17 "parse.y"
  14.  
  15. #include "flexdef.h"
  16.  
  17. int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
  18. int trlcontxt, xcluflg, cclsorted, varlength;
  19. char clower();
  20.  
  21. static int madeany = false;  /* whether we've made the '.' character class */
  22.  
  23.  
  24. #ifndef YYLTYPE
  25. typedef
  26.   struct yyltype
  27. {
  28.       int timestamp;
  29.       int first_line;
  30.       int first_column;
  31. int last_line;
  32.       int last_column;
  33.       char *text;
  34.    }
  35. yyltype;
  36.  
  37. #define YYLTYPE yyltype
  38. #endif
  39.  
  40. #define    YYACCEPT    return(0)
  41. #define    YYABORT    return(1)
  42. #define    YYERROR    return(1)
  43. #ifndef YYSTYPE
  44. #define YYSTYPE int
  45. #endif
  46. #ifndef stdin
  47. #include <stdio.h>
  48. #endif
  49.  
  50. #ifndef __STDC__
  51. #define const
  52. #endif
  53.  
  54.  
  55.  
  56. #define    YYFINAL        81
  57. #define    YYFLAG        -32768
  58. #define    YYNTBASE    31
  59.  
  60. #define YYTRANSLATE(x) ((unsigned)(x) <= 265 ? yytranslate[x] : 50)
  61.  
  62. static const char yytranslate[] = {     0,
  63.      2,     2,     2,     2,     2,     2,     2,     2,     2,    11,
  64.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  65.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  66.      2,     2,     2,    25,     2,    16,     2,     2,     2,    26,
  67.     27,    19,    20,    15,    30,    24,    18,     2,     2,     2,
  68.      2,     2,     2,     2,     2,     2,     2,     2,     2,    13,
  69.      2,    14,    21,     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.     28,     2,    29,    12,     2,     2,     2,     2,     2,     2,
  73.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  74.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.      2,     2,    22,    17,    23,     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,     1,     2,     3,     4,     5,
  89.      6,     7,     8,     9,    10
  90. };
  91.  
  92. static const short yyrline[] = {     0,
  93.     29,    32,    41,    42,    43,    47,    50,    60,    64,    67,
  94.     70,    74,    75,    78,    86,    95,   104,   118,   128,   132,
  95.    135,   144,   152,   156,   178,   194,   201,   204,   209,   232,
  96.    240,   244,   251,   258,   265,   278,   292,   310,   332,   349,
  97.    356,   359,   362,   376,   379,   393,   421,   433,   441,   452
  98. };
  99.  
  100. static const char * yytname[] = {     0,
  101. "error","$illegal.","CHAR","NUMBER","SECTEND","SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL",
  102. "'\\n'","'^'","'<'","'>'","','","'$'","'|'","'/'","'*'","'+'",
  103. "'?'","'{'","'}'","'.'","'\"'","'('","')'","'['","']'","'-'",
  104. "goal"
  105. };
  106.  
  107. static const short yyr1[] = {     0,
  108.     31,    32,    33,    33,    33,    34,    35,    35,    36,    36,
  109.     36,    37,    37,    38,    39,    39,    39,    39,    39,    40,
  110.     41,    41,    41,    42,    42,    43,    43,    43,    44,    45,
  111.     45,    46,    46,    46,    46,    46,    46,    46,    46,    46,
  112.     46,    46,    46,    47,    47,    48,    48,    48,    49,    49
  113. };
  114.  
  115. static const short yyr2[] = {     0,
  116.      4,     0,     5,     0,     2,     1,     1,     1,     3,     1,
  117.      1,     4,     0,     0,     4,     3,     3,     2,     1,     3,
  118.      3,     1,     1,     1,     0,     3,     2,     1,     2,     2,
  119.      1,     2,     2,     2,     6,     5,     4,     1,     1,     1,
  120.      3,     3,     1,     3,     4,     4,     2,     0,     2,     0
  121. };
  122.  
  123. static const short yydefact[] = {     2,
  124.      0,     0,     0,     5,     6,     7,     8,    13,     0,    14,
  125.      0,     0,    11,    10,     0,    19,    43,    40,     0,     0,
  126.     38,    50,     0,    48,     0,     0,    25,     0,    28,    31,
  127.     39,     0,     3,    25,    23,    22,     0,     0,     0,    48,
  128.      0,    12,     0,    25,    24,     0,    29,    18,    27,    30,
  129.     32,    33,    34,     0,     9,    17,    20,     0,    49,    41,
  130.     42,     0,    47,    44,    25,    16,    26,     0,    21,    45,
  131.      0,    15,     0,    37,    46,     0,    36,    35,     0,     0,
  132.      0
  133. };
  134.  
  135. static const short yydefgoto[] = {    79,
  136.      1,     3,     8,     9,    15,    10,    12,    25,    26,    37,
  137.     48,    27,    28,    29,    30,    31,    41,    38
  138. };
  139.  
  140. static const short yypact[] = {-32768,
  141.     61,    -5,    43,-32768,-32768,-32768,-32768,-32768,     8,     9,
  142.      1,     2,-32768,-32768,    28,-32768,-32768,-32768,    32,    45,
  143. -32768,-32768,    32,    13,    42,    19,    57,    32,    32,    50,
  144. -32768,    55,-32768,    57,-32768,-32768,    62,    15,    34,-32768,
  145.      4,-32768,    32,    57,-32768,    32,-32768,-32768,    32,    50,
  146. -32768,-32768,-32768,    74,-32768,-32768,-32768,    56,-32768,-32768,
  147. -32768,     5,   -17,-32768,    57,-32768,    32,    40,-32768,-32768,
  148.     76,-32768,     0,-32768,-32768,    36,-32768,-32768,    80,    81,
  149. -32768
  150. };
  151.  
  152. static const short yypgoto[] = {-32768,
  153. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  154.    -33,    -2,-32768,    -9,   -29,-32768,    44,-32768
  155. };
  156.  
  157.  
  158. #define    YYLAST        84
  159.  
  160.  
  161. static const short yytable[] = {    50,
  162.     56,    13,    16,    76,    17,     4,    63,    63,    -1,    14,
  163.     66,    18,    71,    19,    20,    11,    34,    59,    49,    50,
  164.     39,    17,    77,    44,    40,    21,    22,    23,    18,    24,
  165.     43,    72,    64,    70,    17,    32,    67,    50,    33,    60,
  166.     65,    18,    21,    22,    23,    35,    24,     5,     6,     7,
  167.     46,    47,    42,    36,    73,    21,    22,    23,    78,    24,
  168.     61,     2,    74,    55,    69,    -4,    -4,    -4,    51,    52,
  169.     53,    54,    45,    46,    47,    57,    58,    68,    75,    80,
  170.     81,     0,     0,    62
  171. };
  172.  
  173. static const short yycheck[] = {    29,
  174.     34,     1,     1,     4,     3,    11,     3,     3,     0,     9,
  175.     44,    10,    30,    12,    13,     8,    19,     3,    28,    49,
  176.     23,     3,    23,    26,    12,    24,    25,    26,    10,    28,
  177.     12,    65,    29,    29,     3,     8,    46,    67,    11,    25,
  178.     43,    10,    24,    25,    26,     1,    28,     5,     6,     7,
  179.     17,    18,    11,     9,    15,    24,    25,    26,    23,    28,
  180.     27,     1,    23,     9,     9,     5,     6,     7,    19,    20,
  181.     21,    22,    16,    17,    18,    14,    15,     4,     3,     0,
  182.      0,    -1,    -1,    40
  183. };
  184. #define YYPURE 1
  185.  
  186. #line 2 "bison.simple"
  187.  
  188. /* Skeleton output parser for bison,
  189.    copyright (C) 1984 Bob Corbett and Richard Stallman
  190.  
  191.                NO WARRANTY
  192.  
  193.   BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  194. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  195. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  196. RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
  197. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  198. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  199. FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  200. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
  201. DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
  202. CORRECTION.
  203.  
  204.  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
  205. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
  206. WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
  207. LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
  208. OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
  209. USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
  210. DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
  211. A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
  212. PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
  213. DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  214.  
  215.         GENERAL PUBLIC LICENSE TO COPY
  216.  
  217.   1. You may copy and distribute verbatim copies of this source file
  218. as you receive it, in any medium, provided that you conspicuously and
  219. appropriately publish on each copy a valid copyright notice "Copyright
  220. (C) 1985 Free Software Foundation, Inc."; and include following the
  221. copyright notice a verbatim copy of the above disclaimer of warranty
  222. and of this License.  You may charge a distribution fee for the
  223. physical act of transferring a copy.
  224.  
  225.   2. You may modify your copy or copies of this source file or
  226. any portion of it, and copy and distribute such modifications under
  227. the terms of Paragraph 1 above, provided that you also do the following:
  228.  
  229.     a) cause the modified files to carry prominent notices stating
  230.     that you changed the files and the date of any change; and
  231.  
  232.     b) cause the whole of any work that you distribute or publish,
  233.     that in whole or in part contains or is a derivative of this
  234.     program or any part thereof, to be licensed at no charge to all
  235.     third parties on terms identical to those contained in this
  236.     License Agreement (except that you may choose to grant more
  237.     extensive warranty protection to third parties, at your option).
  238.  
  239.     c) You may charge a distribution fee for the physical act of
  240.     transferring a copy, and you may at your option offer warranty
  241.     protection in exchange for a fee.
  242.  
  243.   3. You may copy and distribute this program or any portion of it in
  244. compiled, executable or object code form under the terms of Paragraphs
  245. 1 and 2 above provided that you do the following:
  246.  
  247.     a) cause each such copy to be accompanied by the
  248.     corresponding machine-readable source code, which must
  249.     be distributed under the terms of Paragraphs 1 and 2 above; or,
  250.  
  251.     b) cause each such copy to be accompanied by a
  252.     written offer, with no time limit, to give any third party
  253.     free (except for a nominal shipping charge) a machine readable
  254.     copy of the corresponding source code, to be distributed
  255.     under the terms of Paragraphs 1 and 2 above; or,
  256.  
  257.     c) in the case of a recipient of this program in compiled, executable
  258.     or object code form (without the corresponding source code) you
  259.     shall cause copies you distribute to be accompanied by a copy
  260.     of the written offer of source code which you received along
  261.     with the copy you received.
  262.  
  263.   4. You may not copy, sublicense, distribute or transfer this program
  264. except as expressly provided under this License Agreement.  Any attempt
  265. otherwise to copy, sublicense, distribute or transfer this program is void and
  266. your rights to use the program under this License agreement shall be
  267. automatically terminated.  However, parties who have received computer
  268. software programs from you with this License Agreement will not have
  269. their licenses terminated so long as such parties remain in full compliance.
  270.  
  271.   5. If you wish to incorporate parts of this program into other free
  272. programs whose distribution conditions are different, write to the Free
  273. Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
  274. worked out a simple rule that can be stated here, but we will often permit
  275. this.  We will be guided by the two goals of preserving the free status of
  276. all derivatives of our free software and of promoting the sharing and reuse of
  277. software.
  278.  
  279.  
  280. In other words, you are welcome to use, share and improve this program.
  281. You are forbidden to forbid anyone else to use, share and improve
  282. what you give them.   Help stamp out software-hoarding!  */
  283.  
  284. /* This is the parser code that is written into each bison parser
  285.   when the %semantic_parser declaration is not specified in the grammar.
  286.   It was written by Richard Stallman by simplifying the hairy parser
  287.   used when %semantic_parser is specified.  */
  288.  
  289. /* Note: there must be only one dollar sign in this file.
  290.    It is replaced by the list of actions, each action
  291.    as one case of the switch.  */
  292.  
  293. #define yyerrok        (yyerrstatus = 0)
  294. #define yyclearin    (yychar = YYEMPTY)
  295. #define YYEMPTY        -2
  296. #define YYEOF        0
  297. #define YYFAIL        goto yyerrlab;
  298.  
  299. #define YYTERROR    1
  300.  
  301. #ifndef YYIMPURE
  302. #define YYLEX        yylex()
  303. #endif
  304.  
  305. #ifndef YYPURE
  306. #define YYLEX        yylex(&yylval, &yylloc)
  307. #endif
  308.  
  309. /* If nonreentrant, generate the variables here */
  310.  
  311. #ifndef YYIMPURE
  312.  
  313. int    yychar;            /*  the lookahead symbol        */
  314. YYSTYPE    yylval;            /*  the semantic value of the        */
  315.                 /*  lookahead symbol            */
  316.  
  317. YYLTYPE yylloc;            /*  location data for the lookahead    */
  318.                 /*  symbol                */
  319.  
  320. int yydebug = 0;        /*  nonzero means print parse trace    */
  321.  
  322. #endif  /* YYIMPURE */
  323.  
  324.  
  325. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  326.  
  327. #ifndef    YYMAXDEPTH
  328. #define YYMAXDEPTH 200
  329. #endif
  330.  
  331. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  332.     (effective only if the built-in stack extension method is used).  */
  333.  
  334. #ifndef YYMAXLIMIT
  335. #define YYMAXLIMIT 10000
  336. #endif
  337.  
  338.  
  339. #line 87 "bison.simple"
  340. int
  341. yyparse()
  342. {
  343.   register int yystate;
  344.   register int yyn;
  345.   register short *yyssp;
  346.   register YYSTYPE *yyvsp;
  347.   YYLTYPE *yylsp;
  348.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  349.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  350.  
  351.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  352.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  353.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  354.  
  355.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  356.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  357.   YYLTYPE *yyls = yylsa;
  358.  
  359.   int yymaxdepth = YYMAXDEPTH;
  360.  
  361. #ifndef YYPURE
  362.  
  363.   int yychar;
  364.   YYSTYPE yylval;
  365.   YYLTYPE yylloc;
  366.  
  367.   extern int yydebug;
  368.  
  369. #endif
  370.  
  371.  
  372.   YYSTYPE yyval;        /*  the variable used to return        */
  373.                 /*  semantic values from the action    */
  374.                 /*  routines                */
  375.  
  376.   int yylen;
  377.  
  378.   if (yydebug)
  379.     fprintf(stderr, "Starting parse\n");
  380.  
  381.   yystate = 0;
  382.   yyerrstatus = 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.   yylsp = yyls;
  392.  
  393. /* Push a new state, which is found in  yystate  .  */
  394. /* In all cases, when you get here, the value and location stacks
  395.    have just been pushed. so pushing a state here evens the stacks.  */
  396. yynewstate:
  397.  
  398.   *++yyssp = yystate;
  399.  
  400.   if (yyssp >= yyss + yymaxdepth - 1)
  401.     {
  402.       /* Give user a chance to reallocate the stack */
  403.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  404.       YYSTYPE *yyvs1 = yyvs;
  405.       YYLTYPE *yyls1 = yyls;
  406.       short *yyss1 = yyss;
  407.  
  408.       /* Get the current used size of the three stacks, in elements.  */
  409.       int size = yyssp - yyss + 1;
  410.  
  411. #ifdef yyoverflow
  412.       /* Each stack pointer address is followed by the size of
  413.      the data in use in that stack, in bytes.  */
  414.       yyoverflow("parser stack overflow",
  415.          &yyss1, size * sizeof (*yyssp),
  416.          &yyvs1, size * sizeof (*yyvsp),
  417.          &yyls1, size * sizeof (*yylsp),
  418.          &yymaxdepth);
  419.  
  420.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  421. #else /* no yyoverflow */
  422.       /* Extend the stack our own way.  */
  423.       if (yymaxdepth >= YYMAXLIMIT)
  424.     yyerror("parser stack overflow");
  425.       yymaxdepth *= 2;
  426.       if (yymaxdepth > YYMAXLIMIT)
  427.     yymaxdepth = YYMAXLIMIT;
  428.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  429.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  430.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  431.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  432.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  433.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  434. #endif /* no yyoverflow */
  435.  
  436.       yyssp = yyss + size - 1;
  437.       yylsp = yyls + size - 1;
  438.       yyvsp = yyvs + size - 1;
  439.  
  440.       if (yydebug)
  441.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  442.  
  443.       if (yyssp >= yyss + yymaxdepth - 1)
  444.     YYERROR;
  445.     }
  446.  
  447.   if (yydebug)
  448.     fprintf(stderr, "Entering state %d\n", yystate);
  449.  
  450. /* Do appropriate processing given the current state.  */
  451. /* Read a lookahead token if we need one and don't already have one.  */
  452. yyresume:
  453.  
  454.   /* First try to decide what to do without reference to lookahead token.  */
  455.  
  456.   yyn = yypact[yystate];
  457.   if (yyn == YYFLAG)
  458.     goto yydefault;
  459.  
  460.   /* Not known => get a lookahead token if don't already have one.  */
  461.  
  462.   /* yychar is either YYEMPTY or YYEOF
  463.      or a valid token in external form.  */
  464.  
  465.   if (yychar == YYEMPTY)
  466.     {
  467.       yychar = YYLEX;
  468.     }
  469.  
  470.   /* Convert token to internal form (in yychar1) for indexing tables with */
  471.  
  472.   if (yychar <= 0)        /* This means end of input. */
  473.     {
  474.       yychar1 = 0;
  475.       yychar = YYEOF;        /* Don't call YYLEX any more */
  476.  
  477.       if (yydebug)
  478.     fprintf(stderr, "Now at end of input.\n");
  479.     }
  480.   else
  481.     {
  482.       yychar1 = YYTRANSLATE(yychar);
  483.  
  484.       if (yydebug)
  485.     fprintf(stderr, "Parsing next token; it is %d (%s)\n", yychar, yytname[yychar1]);
  486.     }
  487.  
  488.   yyn += yychar1;
  489.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  490.     goto yydefault;
  491.  
  492.   yyn = yytable[yyn];
  493.  
  494.   /* yyn is what to do for this token type in this state.
  495.      Negative => reduce, -yyn is rule number.
  496.      Positive => shift, yyn is new state.
  497.        New state is final state => don't bother to shift,
  498.        just return success.
  499.      0, or most negative number => error.  */
  500.  
  501.   if (yyn < 0)
  502.     {
  503.       if (yyn == YYFLAG)
  504.     goto yyerrlab;
  505.       yyn = -yyn;
  506.       goto yyreduce;
  507.     }
  508.   else if (yyn == 0)
  509.     goto yyerrlab;
  510.  
  511.   if (yyn == YYFINAL)
  512.     YYACCEPT;
  513.  
  514.   /* Shift the lookahead token.  */
  515.  
  516.   if (yydebug)
  517.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  518.  
  519.   /* Discard the token being shifted unless it is eof.  */
  520.   if (yychar != YYEOF)
  521.     yychar = YYEMPTY;
  522.  
  523.   *++yyvsp = yylval;
  524.   *++yylsp = yylloc;
  525.  
  526.   /* count tokens shifted since error; after three, turn off error status.  */
  527.   if (yyerrstatus) yyerrstatus--;
  528.  
  529.   yystate = yyn;
  530.   goto yynewstate;
  531.  
  532. /* Do the default action for the current state.  */
  533. yydefault:
  534.  
  535.   yyn = yydefact[yystate];
  536.   if (yyn == 0)
  537.     goto yyerrlab;
  538.  
  539. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  540. yyreduce:
  541.   yylen = yyr2[yyn];
  542.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  543.  
  544.   if (yydebug)
  545.     {
  546.       if (yylen == 1)
  547.     fprintf (stderr, "Reducing 1 value via line %d, ",
  548.          yyrline[yyn]);
  549.       else
  550.     fprintf (stderr, "Reducing %d values via line %d, ",
  551.          yylen, yyrline[yyn]);
  552.     }
  553.  
  554.  
  555.   switch (yyn) {
  556.  
  557. case 2:
  558. #line 33 "parse.y"
  559. {
  560.             /* initialize for processing rules */
  561.  
  562.             /* create default DFA start condition */
  563.             scinstal( "INITIAL", false );
  564.             ;
  565.     break;}
  566. case 5:
  567. #line 44 "parse.y"
  568. { synerr( "unknown error processing section 1" ); ;
  569.     break;}
  570. case 7:
  571. #line 51 "parse.y"
  572. {
  573.             /* these productions are separate from the s1object
  574.              * rule because the semantics must be done before
  575.              * we parse the remainder of an s1object
  576.              */
  577.  
  578.             xcluflg = false;
  579.             ;
  580.     break;}
  581. case 8:
  582. #line 61 "parse.y"
  583. { xcluflg = true; ;
  584.     break;}
  585. case 9:
  586. #line 65 "parse.y"
  587. { scinstal( nmstr, xcluflg ); ;
  588.     break;}
  589. case 10:
  590. #line 68 "parse.y"
  591. { scinstal( nmstr, xcluflg ); ;
  592.     break;}
  593. case 11:
  594. #line 71 "parse.y"
  595. { synerr( "bad start condition list" ); ;
  596.     break;}
  597. case 14:
  598. #line 79 "parse.y"
  599. {
  600.             /* initialize for a parse of one rule */
  601.             trlcontxt = varlength = false;
  602.             trailcnt = headcnt = rulelen = 0;
  603.             ;
  604.     break;}
  605. case 15:
  606. #line 87 "parse.y"
  607. {
  608.             pat = link_machines( yyvsp[-1], yyvsp[0] );
  609.             add_accept( pat, headcnt, trailcnt );
  610.  
  611.             for ( i = 1; i <= actvp; ++i )
  612.                 scbol[actvsc[i]] = mkbranch( scbol[actvsc[i]], pat );
  613.             ;
  614.     break;}
  615. case 16:
  616. #line 96 "parse.y"
  617. {
  618.             pat = link_machines( yyvsp[-1], yyvsp[0] );
  619.             add_accept( pat, headcnt, trailcnt );
  620.  
  621.             for ( i = 1; i <= actvp; ++i )
  622.                 scset[actvsc[i]] = mkbranch( scset[actvsc[i]], pat );
  623.             ;
  624.     break;}
  625. case 17:
  626. #line 105 "parse.y"
  627. {
  628.             pat = link_machines( yyvsp[-1], yyvsp[0] );
  629.             add_accept( pat, headcnt, trailcnt );
  630.  
  631.             /* add to all non-exclusive start conditions,
  632.              * including the default (0) start condition
  633.              */
  634.  
  635.             for ( i = 1; i <= lastsc; ++i )
  636.                 if ( ! scxclu[i] )
  637.                 scbol[i] = mkbranch( scbol[i], pat );
  638.             ;
  639.     break;}
  640. case 18:
  641. #line 119 "parse.y"
  642. {
  643.             pat = link_machines( yyvsp[-1], yyvsp[0] );
  644.             add_accept( pat, headcnt, trailcnt );
  645.  
  646.             for ( i = 1; i <= lastsc; ++i )
  647.                 if ( ! scxclu[i] )
  648.                 scset[i] = mkbranch( scset[i], pat );
  649.             ;
  650.     break;}
  651. case 19:
  652. #line 129 "parse.y"
  653. { synerr( "unrecognized rule" ); ;
  654.     break;}
  655. case 21:
  656. #line 136 "parse.y"
  657. {
  658.             if ( (scnum = sclookup( nmstr )) == 0 )
  659.                 synerr( "undeclared start condition" );
  660.  
  661.             else
  662.                 actvsc[++actvp] = scnum;
  663.             ;
  664.     break;}
  665. case 22:
  666. #line 145 "parse.y"
  667. {
  668.             if ( (scnum = sclookup( nmstr )) == 0 )
  669.                 synerr( "undeclared start condition" );
  670.             else
  671.                 actvsc[actvp = 1] = scnum;
  672.             ;
  673.     break;}
  674. case 23:
  675. #line 153 "parse.y"
  676. { synerr( "bad start condition list" ); ;
  677.     break;}
  678. case 24:
  679. #line 157 "parse.y"
  680. {
  681.             if ( trlcontxt )
  682.                 {
  683.                 synerr( "trailing context used twice" );
  684.                 yyval = mkstate( SYM_EPSILON );
  685.                 }
  686.             else
  687.                 {
  688.                 trlcontxt = true;
  689.  
  690.                 if ( ! varlength )
  691.                 headcnt = rulelen;
  692.  
  693.                 ++rulelen;
  694.                 trailcnt = 1;
  695.  
  696.                 eps = mkstate( SYM_EPSILON );
  697.                 yyval = link_machines( eps, mkstate( '\n' ) );
  698.                 }
  699.             ;
  700.     break;}
  701. case 25:
  702. #line 179 "parse.y"
  703. {
  704.                 yyval = mkstate( SYM_EPSILON );
  705.  
  706.             if ( trlcontxt )
  707.                 {
  708.                 if ( varlength && headcnt == 0 )
  709.                 /* both head and trail are variable-length */
  710.                 synerr( "illegal trailing context" );
  711.  
  712.                 else
  713.                 trailcnt = rulelen;
  714.                 }
  715.                 ;
  716.     break;}
  717. case 26:
  718. #line 195 "parse.y"
  719. {
  720.             varlength = true;
  721.  
  722.             yyval = mkor( yyvsp[-2], yyvsp[0] );
  723.             ;
  724.     break;}
  725. case 27:
  726. #line 202 "parse.y"
  727. { yyval = link_machines( yyvsp[-1], yyvsp[0] ); ;
  728.     break;}
  729. case 28:
  730. #line 205 "parse.y"
  731. { yyval = yyvsp[0]; ;
  732.     break;}
  733. case 29:
  734. #line 210 "parse.y"
  735. {
  736.             /* this rule is separate from the others for "re" so
  737.              * that the reduction will occur before the trailing
  738.              * series is parsed
  739.              */
  740.  
  741.             if ( trlcontxt )
  742.                 synerr( "trailing context used twice" );
  743.             else
  744.                 trlcontxt = true;
  745.  
  746.             if ( varlength )
  747.                 /* the trailing context had better be fixed-length */
  748.                 varlength = false;
  749.             else
  750.                 headcnt = rulelen;
  751.  
  752.             rulelen = 0;
  753.             yyval = yyvsp[-1];
  754.             ;
  755.     break;}
  756. case 30:
  757. #line 233 "parse.y"
  758. {
  759.             /* this is where concatenation of adjacent patterns
  760.              * gets done
  761.              */
  762.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  763.             ;
  764.     break;}
  765. case 31:
  766. #line 241 "parse.y"
  767. { yyval = yyvsp[0]; ;
  768.     break;}
  769. case 32:
  770. #line 245 "parse.y"
  771. {
  772.             varlength = true;
  773.  
  774.             yyval = mkclos( yyvsp[-1] );
  775.             ;
  776.     break;}
  777. case 33:
  778. #line 252 "parse.y"
  779. {
  780.             varlength = true;
  781.  
  782.             yyval = mkposcl( yyvsp[-1] );
  783.             ;
  784.     break;}
  785. case 34:
  786. #line 259 "parse.y"
  787. {
  788.             varlength = true;
  789.  
  790.             yyval = mkopt( yyvsp[-1] );
  791.             ;
  792.     break;}
  793. case 35:
  794. #line 266 "parse.y"
  795. {
  796.             varlength = true;
  797.  
  798.             if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] <= 0 )
  799.                 {
  800.                 synerr( "bad iteration values" );
  801.                 yyval = yyvsp[-5];
  802.                 }
  803.             else
  804.                 yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
  805.             ;
  806.     break;}
  807. case 36:
  808. #line 279 "parse.y"
  809. {
  810.             varlength = true;
  811.  
  812.             if ( yyvsp[-2] <= 0 )
  813.                 {
  814.                 synerr( "iteration value must be positive" );
  815.                 yyval = yyvsp[-4];
  816.                 }
  817.  
  818.             else
  819.                 yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
  820.             ;
  821.     break;}
  822. case 37:
  823. #line 293 "parse.y"
  824. {
  825.             /* the singleton could be something like "(foo)",
  826.              * in which case we have no idea what its length
  827.              * is, so we punt here.
  828.              */
  829.             varlength = true;
  830.  
  831.             if ( yyvsp[-1] <= 0 )
  832.                 {
  833.                 synerr( "iteration value must be positive" );
  834.                 yyval = yyvsp[-3];
  835.                 }
  836.  
  837.             else
  838.                 yyval = link_machines( yyvsp[-3], copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
  839.             ;
  840.     break;}
  841. case 38:
  842. #line 311 "parse.y"
  843. {
  844.             if ( ! madeany )
  845.                 {
  846.                 /* create the '.' character class */
  847.                 anyccl = cclinit();
  848.                 ccladd( anyccl, '\n' );
  849.                 cclnegate( anyccl );
  850.  
  851.                 if ( useecs )
  852.                 mkeccl( ccltbl + cclmap[anyccl],
  853.                     ccllen[anyccl], nextecm,
  854.                     ecgroup, CSIZE );
  855.                 
  856.                 madeany = true;
  857.                 }
  858.  
  859.             ++rulelen;
  860.  
  861.             yyval = mkstate( -anyccl );
  862.             ;
  863.     break;}
  864. case 39:
  865. #line 333 "parse.y"
  866. {
  867.             if ( ! cclsorted )
  868.                 /* sort characters for fast searching.  We use a
  869.                  * shell sort since this list could be large.
  870.                  */
  871.                 cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]] );
  872.  
  873.             if ( useecs )
  874.                 mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
  875.                     nextecm, ecgroup, CSIZE );
  876.                      
  877.             ++rulelen;
  878.  
  879.             yyval = mkstate( -yyvsp[0] );
  880.             ;
  881.     break;}
  882. case 40:
  883. #line 350 "parse.y"
  884. {
  885.             ++rulelen;
  886.  
  887.             yyval = mkstate( -yyvsp[0] );
  888.             ;
  889.     break;}
  890. case 41:
  891. #line 357 "parse.y"
  892. { yyval = yyvsp[-1]; ;
  893.     break;}
  894. case 42:
  895. #line 360 "parse.y"
  896. { yyval = yyvsp[-1]; ;
  897.     break;}
  898. case 43:
  899. #line 363 "parse.y"
  900. {
  901.             ++rulelen;
  902.  
  903.             if ( yyvsp[0] == '\0' )
  904.                 synerr( "null in rule" );
  905.  
  906.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  907.                 yyvsp[0] = clower( yyvsp[0] );
  908.  
  909.             yyval = mkstate( yyvsp[0] );
  910.             ;
  911.     break;}
  912. case 44:
  913. #line 377 "parse.y"
  914. { yyval = yyvsp[-1]; ;
  915.     break;}
  916. case 45:
  917. #line 380 "parse.y"
  918. {
  919.             /* *Sigh* - to be compatible Unix lex, negated ccls
  920.              * match newlines
  921.              */
  922. #ifdef NOTDEF
  923.             ccladd( yyvsp[-1], '\n' ); /* negated ccls don't match '\n' */
  924.             cclsorted = false; /* because we added the newline */
  925. #endif
  926.             cclnegate( yyvsp[-1] );
  927.             yyval = yyvsp[-1];
  928.             ;
  929.     break;}
  930. case 46:
  931. #line 394 "parse.y"
  932. {
  933.             if ( yyvsp[-2] > yyvsp[0] )
  934.                 synerr( "negative range in character class" );
  935.  
  936.             else
  937.                 {
  938.                 if ( caseins )
  939.                 {
  940.                 if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
  941.                     yyvsp[-2] = clower( yyvsp[-2] );
  942.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  943.                     yyvsp[0] = clower( yyvsp[0] );
  944.                 }
  945.  
  946.                 for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
  947.                     ccladd( yyvsp[-3], i );
  948.  
  949.                 /* keep track if this ccl is staying in alphabetical
  950.                  * order
  951.                  */
  952.                 cclsorted = cclsorted && (yyvsp[-2] > lastchar);
  953.                 lastchar = yyvsp[0];
  954.                 }
  955.             
  956.             yyval = yyvsp[-3];
  957.             ;
  958.     break;}
  959. case 47:
  960. #line 422 "parse.y"
  961. {
  962.             if ( caseins )
  963.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  964.                 yyvsp[0] = clower( yyvsp[0] );
  965.  
  966.             ccladd( yyvsp[-1], yyvsp[0] );
  967.             cclsorted = cclsorted && (yyvsp[0] > lastchar);
  968.             lastchar = yyvsp[0];
  969.             yyval = yyvsp[-1];
  970.             ;
  971.     break;}
  972. case 48:
  973. #line 434 "parse.y"
  974. {
  975.             cclsorted = true;
  976.             lastchar = 0;
  977.             yyval = cclinit();
  978.             ;
  979.     break;}
  980. case 49:
  981. #line 442 "parse.y"
  982. {
  983.             if ( caseins )
  984.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  985.                 yyvsp[0] = clower( yyvsp[0] );
  986.  
  987.             ++rulelen;
  988.  
  989.             yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
  990.             ;
  991.     break;}
  992. case 50:
  993. #line 453 "parse.y"
  994. { yyval = mkstate( SYM_EPSILON ); ;
  995.     break;}
  996. }
  997.    /* the action file gets copied in in place of this dollarsign */
  998. #line 303 "bison.simple"
  999.  
  1000.   yyvsp -= yylen;
  1001.   yylsp -= yylen;
  1002.   yyssp -= yylen;
  1003.  
  1004.   if (yydebug)
  1005.     {
  1006.       short *ssp1 = yyss - 1;
  1007.       fprintf (stderr, "state stack now", yyssp-yyss);
  1008.       while (ssp1 != yyssp)
  1009.     fprintf (stderr, " %d", *++ssp1);
  1010.       fprintf (stderr, "\n");
  1011.     }
  1012.  
  1013.   *++yyvsp = yyval;
  1014.  
  1015.   yylsp++;
  1016.   if (yylen == 0)
  1017.     {
  1018.       yylsp->first_line = yylloc.first_line;
  1019.       yylsp->first_column = yylloc.first_column;
  1020.       yylsp->last_line = (yylsp-1)->last_line;
  1021.       yylsp->last_column = (yylsp-1)->last_column;
  1022.       yylsp->text = 0;
  1023.     }
  1024.   else
  1025.     {
  1026.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1027.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1028.     }
  1029.  
  1030.   /* Now "shift" the result of the reduction.
  1031.      Determine what state that goes to,
  1032.      based on the state we popped back to
  1033.      and the rule number reduced by.  */
  1034.  
  1035.   yyn = yyr1[yyn];
  1036.  
  1037.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1038.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1039.     yystate = yytable[yystate];
  1040.   else
  1041.     yystate = yydefgoto[yyn - YYNTBASE];
  1042.  
  1043.   goto yynewstate;
  1044.  
  1045. yyerrlab:   /* here on detecting error */
  1046.  
  1047.   if (! yyerrstatus)
  1048.     /* If not already recovering from an error, report this error.  */
  1049.     {
  1050.       yyerror("parse error");
  1051.     }
  1052.  
  1053.   if (yyerrstatus == 3)
  1054.     {
  1055.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1056.  
  1057.       /* return failure if at end of input */
  1058.       if (yychar == YYEOF)
  1059.     YYERROR;
  1060.  
  1061.       if (yydebug)
  1062.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1063.  
  1064.       yychar = YYEMPTY;
  1065.     }
  1066.  
  1067.   /* Else will try to reuse lookahead token
  1068.      after shifting the error token.  */
  1069.  
  1070.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1071.  
  1072.   goto yyerrhandle;
  1073.  
  1074. yyerrdefault:  /* current state does not do anything special for the error token. */
  1075.  
  1076. #if 0
  1077.   /* This is wrong; only states that explicitly want error tokens
  1078.      should shift them.  */
  1079.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1080.   if (yyn) goto yydefault;
  1081. #endif
  1082.  
  1083. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1084.  
  1085.   if (yyssp == yyss) YYERROR;
  1086.   yyvsp--;
  1087.   yylsp--;
  1088.   yystate = *--yyssp;
  1089.  
  1090.   if (yydebug)
  1091.     {
  1092.       short *ssp1 = yyss - 1;
  1093.       fprintf (stderr, "Error: state stack now", yyssp-yyss);
  1094.       while (ssp1 != yyssp)
  1095.     fprintf (stderr, " %d", *++ssp1);
  1096.       fprintf (stderr, "\n");
  1097.     }
  1098.  
  1099. yyerrhandle:
  1100.  
  1101.   yyn = yypact[yystate];
  1102.   if (yyn == YYFLAG)
  1103.     goto yyerrdefault;
  1104.  
  1105.   yyn += YYTERROR;
  1106.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1107.     goto yyerrdefault;
  1108.  
  1109.   yyn = yytable[yyn];
  1110.   if (yyn < 0)
  1111.     {
  1112.       if (yyn == YYFLAG)
  1113.     goto yyerrpop;
  1114.       yyn = -yyn;
  1115.       goto yyreduce;
  1116.     }
  1117.   else if (yyn == 0)
  1118.     goto yyerrpop;
  1119.  
  1120.   if (yyn == YYFINAL)
  1121.     YYACCEPT;
  1122.  
  1123.   if (yydebug)
  1124.     fprintf(stderr, "Shifting error token, ");
  1125.  
  1126.   *++yyvsp = yylval;
  1127.   *++yylsp = yylloc;
  1128.  
  1129.   yystate = yyn;
  1130.   goto yynewstate;
  1131. }
  1132. #line 456 "parse.y"
  1133.  
  1134.  
  1135. /* synerr - report a syntax error
  1136.  *
  1137.  * synopsis
  1138.  *    char str[];
  1139.  *    synerr( str );
  1140.  */
  1141.  
  1142. synerr( str )
  1143. char str[];
  1144.  
  1145.     {
  1146.     syntaxerror = true;
  1147.     fprintf( stderr, "Syntax error at line %d:  %s\n", linenum, str );
  1148.     }
  1149.  
  1150.  
  1151. /* yyerror - eat up an error message from the parser
  1152.  *
  1153.  * synopsis
  1154.  *    char msg[];
  1155.  *    yyerror( msg );
  1156.  */
  1157.  
  1158. yyerror( msg )
  1159. char msg[];
  1160.  
  1161.     {
  1162.     }
  1163.