home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / c / Flex254.lha / Src / parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-12  |  45.5 KB  |  1,830 lines

  1.  
  2. /*  A Bison parser, made from Src/parse.y
  3.  by  GNU Bison version 1.25
  4.   */
  5.  
  6. #define YYBISON 1  /* Identify Bison output.  */
  7.  
  8. #define    CHAR    258
  9. #define    NUMBER    259
  10. #define    SECTEND    260
  11. #define    SCDECL    261
  12. #define    XSCDECL    262
  13. #define    NAME    263
  14. #define    PREVCCL    264
  15. #define    EOF_OP    265
  16. #define    OPTION_OP    266
  17. #define    OPT_OUTFILE    267
  18. #define    OPT_PREFIX    268
  19. #define    OPT_YYCLASS    269
  20. #define    CCE_ALNUM    270
  21. #define    CCE_ALPHA    271
  22. #define    CCE_BLANK    272
  23. #define    CCE_CNTRL    273
  24. #define    CCE_DIGIT    274
  25. #define    CCE_GRAPH    275
  26. #define    CCE_LOWER    276
  27. #define    CCE_PRINT    277
  28. #define    CCE_PUNCT    278
  29. #define    CCE_SPACE    279
  30. #define    CCE_UPPER    280
  31. #define    CCE_XDIGIT    281
  32.  
  33.  
  34. /*-
  35.  * Copyright (c) 1990 The Regents of the University of California.
  36.  * All rights reserved.
  37.  *
  38.  * This code is derived from software contributed to Berkeley by
  39.  * Vern Paxson.
  40.  * 
  41.  * The United States Government has rights in this work pursuant
  42.  * to contract no. DE-AC03-76SF00098 between the United States
  43.  * Department of Energy and the University of California.
  44.  *
  45.  * Redistribution and use in source and binary forms are permitted provided
  46.  * that: (1) source distributions retain this entire copyright notice and
  47.  * comment, and (2) distributions including binaries display the following
  48.  * acknowledgement:  ``This product includes software developed by the
  49.  * University of California, Berkeley and its contributors'' in the
  50.  * documentation or other materials provided with the distribution and in
  51.  * all advertising materials mentioning features or use of this software.
  52.  * Neither the name of the University nor the names of its contributors may
  53.  * be used to endorse or promote products derived from this software without
  54.  * specific prior written permission.
  55.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  56.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  57.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  58.  */
  59.  
  60. /* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.28 95/04/21 11:51:51 vern Exp $ */
  61.  
  62.  
  63. /* Some versions of bison are broken in that they use alloca() but don't
  64.  * declare it properly.  The following is the patented (just kidding!)
  65.  * #ifdef chud to fix the problem, courtesy of Francois Pinard.
  66.  */
  67. #ifdef YYBISON
  68. /* AIX requires this to be the first thing in the file.  What a piece.  */
  69. # ifdef _AIX
  70.  #pragma alloca
  71. # endif
  72. #endif
  73.  
  74. #include "flexdef.h"
  75.  
  76. /* The remainder of the alloca() cruft has to come after including flexdef.h,
  77.  * so HAVE_ALLOCA_H is (possibly) defined.
  78.  */
  79. #ifdef YYBISON
  80. # ifdef __GNUC__
  81. #  ifndef alloca
  82. #   define alloca __builtin_alloca
  83. #  endif
  84. # else
  85. #  if HAVE_ALLOCA_H
  86. #   include <alloca.h>
  87. #  else
  88. #   ifdef __hpux
  89. void *alloca ();
  90. #   else
  91. #    ifdef __TURBOC__
  92. #     include <malloc.h>
  93. #    else
  94. void *alloca (unsigned int);
  95. #    endif
  96. #   endif
  97. #  endif
  98. # endif
  99. #endif
  100.  
  101. /* Bletch, ^^^^ that was ugly! */
  102.  
  103.  
  104. int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, rulelen;
  105. int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
  106.  
  107. int *scon_stk;
  108. int scon_stk_ptr;
  109.  
  110. static int madeany = false;  /* whether we've made the '.' character class */
  111. int previous_continued_action;    /* whether the previous rule's action was '|' */
  112.  
  113. /* Expand a POSIX character class expression. */
  114. #define CCL_EXPR(func) \
  115.     { \
  116.     int c; \
  117.     for ( c = 0; c < csize; ++c ) \
  118.         if ( isascii(c) && func(c) ) \
  119.             ccladd( currccl, c ); \
  120.     }
  121.  
  122. /* While POSIX defines isblank(), it's not ANSI C. */
  123. #define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
  124.  
  125. /* On some over-ambitious machines, such as DEC Alpha's, the default
  126.  * token type is "long" instead of "int"; this leads to problems with
  127.  * declaring yylval in flexdef.h.  But so far, all the yacc's I've seen
  128.  * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
  129.  * following should ensure that the default token type is "int".
  130.  */
  131. #define YYSTYPE int
  132.  
  133. #ifndef YYSTYPE
  134. #define YYSTYPE int
  135. #endif
  136. #include <stdio.h>
  137.  
  138. #ifndef __cplusplus
  139. #ifndef __STDC__
  140. #define const
  141. #endif
  142. #endif
  143.  
  144.  
  145.  
  146. #define    YYFINAL        107
  147. #define    YYFLAG        -32768
  148. #define    YYNTBASE    48
  149.  
  150. #define YYTRANSLATE(x) ((unsigned)(x) <= 281 ? yytranslate[x] : 73)
  151.  
  152. static const char yytranslate[] = {     0,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,    28,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,    42,     2,    36,     2,     2,     2,    43,
  157.     44,    34,    39,    35,    47,    41,    38,     2,     2,     2,
  158.      2,     2,     2,     2,     2,     2,     2,     2,     2,    32,
  159.     27,    33,    40,     2,     2,     2,     2,     2,     2,     2,
  160.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  161.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  162.     45,     2,    46,    31,     2,     2,     2,     2,     2,     2,
  163.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  164.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  165.      2,     2,    29,    37,    30,     2,     2,     2,     2,     2,
  166.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  167.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  168.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  169.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  170.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  171.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  172.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  173.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  174.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  175.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  176.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  177.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  178.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  179.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  180.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  181.     26
  182. };
  183.  
  184. #if YYDEBUG != 0
  185. static const short yyprhs[] = {     0,
  186.      0,     6,     7,    11,    14,    15,    17,    19,    21,    23,
  187.     26,    28,    30,    33,    36,    37,    41,    45,    49,    55,
  188.     61,    62,    63,    66,    68,    70,    72,    73,    78,    82,
  189.     83,    87,    89,    91,    93,    96,   100,   103,   105,   109,
  190.    111,   114,   117,   119,   122,   125,   128,   135,   141,   146,
  191.    148,   150,   152,   156,   160,   162,   166,   171,   176,   179,
  192.    182,   183,   185,   187,   189,   191,   193,   195,   197,   199,
  193.    201,   203,   205,   207,   210
  194. };
  195.  
  196. static const short yyrhs[] = {    49,
  197.     50,    51,    57,    58,     0,     0,    50,    52,    53,     0,
  198.     50,    54,     0,     0,     1,     0,     5,     0,     6,     0,
  199.      7,     0,    53,     8,     0,     8,     0,     1,     0,    11,
  200.     55,     0,    55,    56,     0,     0,    12,    27,     8,     0,
  201.     13,    27,     8,     0,    14,    27,     8,     0,    57,    61,
  202.     58,    59,    28,     0,    57,    61,    29,    57,    30,     0,
  203.      0,     0,    31,    64,     0,    64,     0,    10,     0,     1,
  204.      0,     0,    32,    60,    62,    33,     0,    32,    34,    33,
  205.      0,     0,    62,    35,    63,     0,    63,     0,     1,     0,
  206.      8,     0,    66,    65,     0,    66,    65,    36,     0,    65,
  207.     36,     0,    65,     0,    65,    37,    67,     0,    67,     0,
  208.     65,    38,     0,    67,    68,     0,    68,     0,    68,    34,
  209.      0,    68,    39,     0,    68,    40,     0,    68,    29,     4,
  210.     35,     4,    30,     0,    68,    29,     4,    35,    30,     0,
  211.     68,    29,     4,    30,     0,    41,     0,    69,     0,     9,
  212.      0,    42,    72,    42,     0,    43,    65,    44,     0,     3,
  213.      0,    45,    70,    46,     0,    45,    31,    70,    46,     0,
  214.     70,     3,    47,     3,     0,    70,     3,     0,    70,    71,
  215.      0,     0,    15,     0,    16,     0,    17,     0,    18,     0,
  216.     19,     0,    20,     0,    21,     0,    22,     0,    23,     0,
  217.     24,     0,    25,     0,    26,     0,    72,     3,     0,     0
  218. };
  219.  
  220. #endif
  221.  
  222. #if YYDEBUG != 0
  223. static const short yyrline[] = { 0,
  224.    112,   141,   149,   150,   151,   152,   156,   164,   167,   171,
  225.    174,   177,   181,   184,   185,   188,   193,   195,   199,   201,
  226.    203,   206,   219,   255,   279,   302,   306,   310,   313,   330,
  227.    334,   336,   338,   342,   365,   420,   423,   466,   484,   490,
  228.    495,   522,   530,   534,   541,   547,   553,   581,   595,   614,
  229.    636,   654,   661,   664,   667,   678,   681,   688,   716,   727,
  230.    734,   742,   743,   744,   745,   746,   747,   748,   749,   750,
  231.    751,   752,   758,   761,   771
  232. };
  233. #endif
  234.  
  235.  
  236. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  237.  
  238. static const char * const yytname[] = {   "$","error","$undefined.","CHAR","NUMBER",
  239. "SECTEND","SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE",
  240. "OPT_PREFIX","OPT_YYCLASS","CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL","CCE_DIGIT",
  241. "CCE_GRAPH","CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE","CCE_UPPER","CCE_XDIGIT",
  242. "'='","'\\n'","'{'","'}'","'^'","'<'","'>'","'*'","','","'$'","'|'","'/'","'+'",
  243. "'?'","'.'","'\"'","'('","')'","'['","']'","'-'","goal","initlex","sect1","sect1end",
  244. "startconddecl","namelist1","options","optionlist","option","sect2","initforrule",
  245. "flexrule","scon_stk_ptr","scon","namelist2","sconname","rule","re","re2","series",
  246. "singleton","fullccl","ccl","ccl_expr","string", NULL
  247. };
  248. #endif
  249.  
  250. static const short yyr1[] = {     0,
  251.     48,    49,    50,    50,    50,    50,    51,    52,    52,    53,
  252.     53,    53,    54,    55,    55,    56,    56,    56,    57,    57,
  253.     57,    58,    59,    59,    59,    59,    60,    61,    61,    61,
  254.     62,    62,    62,    63,    64,    64,    64,    64,    65,    65,
  255.     66,    67,    67,    68,    68,    68,    68,    68,    68,    68,
  256.     68,    68,    68,    68,    68,    69,    69,    70,    70,    70,
  257.     70,    71,    71,    71,    71,    71,    71,    71,    71,    71,
  258.     71,    71,    71,    72,    72
  259. };
  260.  
  261. static const short yyr2[] = {     0,
  262.      5,     0,     3,     2,     0,     1,     1,     1,     1,     2,
  263.      1,     1,     2,     2,     0,     3,     3,     3,     5,     5,
  264.      0,     0,     2,     1,     1,     1,     0,     4,     3,     0,
  265.      3,     1,     1,     1,     2,     3,     2,     1,     3,     1,
  266.      2,     2,     1,     2,     2,     2,     6,     5,     4,     1,
  267.      1,     1,     3,     3,     1,     3,     4,     4,     2,     2,
  268.      0,     1,     1,     1,     1,     1,     1,     1,     1,     1,
  269.      1,     1,     1,     2,     0
  270. };
  271.  
  272. static const short yydefact[] = {     2,
  273.      0,     6,     0,     7,     8,     9,    15,    21,     0,     4,
  274.     13,    30,    12,    11,     3,     0,     0,     0,    14,    27,
  275.      1,    22,    10,     0,     0,     0,     0,     0,    21,     0,
  276.     16,    17,    18,    29,    33,    34,     0,    32,    30,    26,
  277.     55,    52,    25,     0,    50,    75,     0,    61,     0,    24,
  278.     38,     0,    40,    43,    51,    28,     0,    20,    23,     0,
  279.      0,    61,     0,    19,    37,     0,    41,    35,    42,     0,
  280.     44,    45,    46,    31,    74,    53,    54,     0,    59,    62,
  281.     63,    64,    65,    66,    67,    68,    69,    70,    71,    72,
  282.     73,    56,    60,    39,    36,     0,    57,     0,    49,     0,
  283.     58,     0,    48,    47,     0,     0,     0
  284. };
  285.  
  286. static const short yydefgoto[] = {   105,
  287.      1,     3,     8,     9,    15,    10,    11,    19,    12,    21,
  288.     49,    28,    22,    37,    38,    50,    51,    52,    53,    54,
  289.     55,    63,    93,    60
  290. };
  291.  
  292. static const short yypact[] = {-32768,
  293.     78,-32768,    81,-32768,-32768,-32768,-32768,-32768,     6,-32768,
  294.     -2,     5,-32768,-32768,    -7,   -14,     1,     9,-32768,    28,
  295. -32768,    14,-32768,    55,    65,    74,    57,    30,-32768,    -1,
  296. -32768,-32768,-32768,-32768,-32768,-32768,    58,-32768,    44,-32768,
  297. -32768,-32768,-32768,    24,-32768,-32768,    24,    63,    69,-32768,
  298.     23,    24,    24,    41,-32768,-32768,    90,-32768,-32768,    26,
  299.     27,-32768,     0,-32768,-32768,    24,-32768,    59,    41,    95,
  300. -32768,-32768,-32768,-32768,-32768,-32768,-32768,    32,    53,-32768,
  301. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  302. -32768,-32768,-32768,    24,-32768,     4,-32768,    98,-32768,     2,
  303. -32768,    72,-32768,-32768,   103,   104,-32768
  304. };
  305.  
  306. static const short yypgoto[] = {-32768,
  307. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    76,    84,
  308. -32768,-32768,-32768,-32768,    50,    64,    25,-32768,    43,   -49,
  309. -32768,    48,-32768,-32768
  310. };
  311.  
  312.  
  313. #define    YYLAST        110
  314.  
  315.  
  316. static const short yytable[] = {    40,
  317.     23,    41,    79,    69,   -22,   102,    13,    42,    43,    16,
  318.     17,    18,    24,    14,    80,    81,    82,    83,    84,    85,
  319.     86,    87,    88,    89,    90,    91,    41,    25,    75,    44,
  320.     35,   103,    42,    99,    79,    26,    20,    36,   100,    45,
  321.     46,    47,    29,    48,    69,    92,    80,    81,    82,    83,
  322.     84,    85,    86,    87,    88,    89,    90,    91,    65,    66,
  323.     67,    27,    31,    66,    45,    46,    47,    76,    48,    70,
  324.     77,    61,    32,    58,    71,    20,    68,    97,     2,    72,
  325.     73,    33,    -5,    -5,    -5,     4,     5,     6,    -5,    34,
  326.     56,     7,    57,    62,    95,    66,    64,    36,    96,    98,
  327.    101,   104,   106,   107,    39,    30,    74,    59,    94,    78
  328. };
  329.  
  330. static const short yycheck[] = {     1,
  331.      8,     3,     3,    53,     0,     4,     1,     9,    10,    12,
  332.     13,    14,    27,     8,    15,    16,    17,    18,    19,    20,
  333.     21,    22,    23,    24,    25,    26,     3,    27,     3,    31,
  334.      1,    30,     9,    30,     3,    27,    32,     8,    35,    41,
  335.     42,    43,    29,    45,    94,    46,    15,    16,    17,    18,
  336.     19,    20,    21,    22,    23,    24,    25,    26,    36,    37,
  337.     38,    34,     8,    37,    41,    42,    43,    42,    45,    29,
  338.     44,    47,     8,    30,    34,    32,    52,    46,     1,    39,
  339.     40,     8,     5,     6,     7,     5,     6,     7,    11,    33,
  340.     33,    11,    35,    31,    36,    37,    28,     8,     4,    47,
  341.      3,    30,     0,     0,    29,    22,    57,    44,    66,    62
  342. };
  343. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  344.  
  345.  
  346. /* Skeleton output parser for bison,
  347.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  348.  
  349.    This program is free software; you can redistribute it and/or modify
  350.    it under the terms of the GNU General Public License as published by
  351.    the Free Software Foundation; either version 2, or (at your option)
  352.    any later version.
  353.  
  354.    This program is distributed in the hope that it will be useful,
  355.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  356.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  357.    GNU General Public License for more details.
  358.  
  359.    You should have received a copy of the GNU General Public License
  360.    along with this program; if not, write to the Free Software
  361.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  362.  
  363. /* As a special exception, when this file is copied by Bison into a
  364.    Bison output file, you may use that output file without restriction.
  365.    This special exception was added by the Free Software Foundation
  366.    in version 1.24 of Bison.  */
  367.  
  368. #ifndef alloca
  369. #ifdef AMIGA
  370. void *alloca (unsigned int);
  371. #endif
  372. #ifdef __GNUC__
  373. #define alloca __builtin_alloca
  374. #else /* not GNU C.  */
  375. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  376. #include <alloca.h>
  377. #else /* not sparc */
  378. #if defined (MSDOS) && !defined (__TURBOC__)
  379. #include <malloc.h>
  380. #else /* not MSDOS, or __TURBOC__ */
  381. #if defined(_AIX)
  382. #include <malloc.h>
  383.  #pragma alloca
  384. #else /* not MSDOS, __TURBOC__, or _AIX */
  385. #ifdef __hpux
  386. #ifdef __cplusplus
  387. extern "C" {
  388. void *alloca (unsigned int);
  389. };
  390. #else /* not __cplusplus */
  391. void *alloca ();
  392. #endif /* not __cplusplus */
  393. #endif /* __hpux */
  394. #endif /* not _AIX */
  395. #endif /* not MSDOS, or __TURBOC__ */
  396. #endif /* not sparc.  */
  397. #endif /* not GNU C.  */
  398. #endif /* alloca not defined.  */
  399.  
  400. /* This is the parser code that is written into each bison parser
  401.   when the %semantic_parser declaration is not specified in the grammar.
  402.   It was written by Richard Stallman by simplifying the hairy parser
  403.   used when %semantic_parser is specified.  */
  404.  
  405. /* Note: there must be only one dollar sign in this file.
  406.    It is replaced by the list of actions, each action
  407.    as one case of the switch.  */
  408.  
  409. #define yyerrok        (yyerrstatus = 0)
  410. #define yyclearin    (yychar = YYEMPTY)
  411. #define YYEMPTY        -2
  412. #define YYEOF        0
  413. #define YYACCEPT    return(0)
  414. #define YYABORT     return(1)
  415. #define YYERROR        goto yyerrlab1
  416. /* Like YYERROR except do call yyerror.
  417.    This remains here temporarily to ease the
  418.    transition to the new meaning of YYERROR, for GCC.
  419.    Once GCC version 2 has supplanted version 1, this can go.  */
  420. #define YYFAIL        goto yyerrlab
  421. #define YYRECOVERING()  (!!yyerrstatus)
  422. #define YYBACKUP(token, value) \
  423. do                                \
  424.   if (yychar == YYEMPTY && yylen == 1)                \
  425.     { yychar = (token), yylval = (value);            \
  426.       yychar1 = YYTRANSLATE (yychar);                \
  427.       YYPOPSTACK;                        \
  428.       goto yybackup;                        \
  429.     }                                \
  430.   else                                \
  431.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  432. while (0)
  433.  
  434. #define YYTERROR    1
  435. #define YYERRCODE    256
  436.  
  437. #ifndef YYPURE
  438. #define YYLEX        yylex()
  439. #endif
  440.  
  441. #ifdef YYPURE
  442. #ifdef YYLSP_NEEDED
  443. #ifdef YYLEX_PARAM
  444. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  445. #else
  446. #define YYLEX        yylex(&yylval, &yylloc)
  447. #endif
  448. #else /* not YYLSP_NEEDED */
  449. #ifdef YYLEX_PARAM
  450. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  451. #else
  452. #define YYLEX        yylex(&yylval)
  453. #endif
  454. #endif /* not YYLSP_NEEDED */
  455. #endif
  456.  
  457. /* If nonreentrant, generate the variables here */
  458.  
  459. #ifndef YYPURE
  460.  
  461. int    yychar;            /*  the lookahead symbol        */
  462. YYSTYPE    yylval;            /*  the semantic value of the        */
  463.                 /*  lookahead symbol            */
  464.  
  465. #ifdef YYLSP_NEEDED
  466. YYLTYPE yylloc;            /*  location data for the lookahead    */
  467.                 /*  symbol                */
  468. #endif
  469.  
  470. int yynerrs;            /*  number of parse errors so far       */
  471. #endif  /* not YYPURE */
  472.  
  473. #if YYDEBUG != 0
  474. int yydebug;            /*  nonzero means print parse trace    */
  475. /* Since this is uninitialized, it does not stop multiple parsers
  476.    from coexisting.  */
  477. #endif
  478.  
  479. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  480.  
  481. #ifndef    YYINITDEPTH
  482. #define YYINITDEPTH 200
  483. #endif
  484.  
  485. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  486.     (effective only if the built-in stack extension method is used).  */
  487.  
  488. #if YYMAXDEPTH == 0
  489. #undef YYMAXDEPTH
  490. #endif
  491.  
  492. #ifndef YYMAXDEPTH
  493. #define YYMAXDEPTH 10000
  494. #endif
  495.  
  496. /* Prevent warning if -Wstrict-prototypes.  */
  497. #if defined (__GNUC__) || defined AMIGA
  498. int yyparse (void);
  499. #endif
  500.  
  501. #if (__GNUC__ > 1) || defined (AMIGA)    /* GNU C and GNU C++ define this.  */
  502. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  503. #else                /* not GNU C or C++ */
  504. #ifndef __cplusplus
  505.  
  506. /* This is the most reliable way to avoid incompatibilities
  507.    in available built-in functions on various systems.  */
  508. static void
  509. __yy_memcpy (to, from, count)
  510.      char *to;
  511.      char *from;
  512.      int count;
  513. {
  514.   register char *f = from;
  515.   register char *t = to;
  516.   register int i = count;
  517.  
  518.   while (i-- > 0)
  519.     *t++ = *f++;
  520. }
  521.  
  522. #else /* __cplusplus */
  523.  
  524. /* This is the most reliable way to avoid incompatibilities
  525.    in available built-in functions on various systems.  */
  526. static void
  527. __yy_memcpy (char *to, char *from, int count)
  528. {
  529.   register char *f = from;
  530.   register char *t = to;
  531.   register int i = count;
  532.  
  533.   while (i-- > 0)
  534.     *t++ = *f++;
  535. }
  536.  
  537. #endif
  538. #endif
  539.  
  540.  
  541.  
  542. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  543.    into yyparse.  The argument should have type void *.
  544.    It should actually point to an object.
  545.    Grammar actions can access the variable by casting it
  546.    to the proper pointer type.  */
  547.  
  548. #ifdef YYPARSE_PARAM
  549. #ifdef __cplusplus
  550. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  551. #define YYPARSE_PARAM_DECL
  552. #else /* not __cplusplus */
  553. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  554. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  555. #endif /* not __cplusplus */
  556. #else /* not YYPARSE_PARAM */
  557. #define YYPARSE_PARAM_ARG
  558. #define YYPARSE_PARAM_DECL
  559. #endif /* not YYPARSE_PARAM */
  560.  
  561. int
  562. yyparse(YYPARSE_PARAM_ARG)
  563.      YYPARSE_PARAM_DECL
  564. {
  565.   register int yystate;
  566.   register int yyn;
  567.   register short *yyssp;
  568.   register YYSTYPE *yyvsp;
  569.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  570.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  571.  
  572.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  573.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  574.  
  575.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  576.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  577.  
  578. #ifdef YYLSP_NEEDED
  579.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  580.   YYLTYPE *yyls = yylsa;
  581.   YYLTYPE *yylsp;
  582.  
  583. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  584. #else
  585. #define YYPOPSTACK   (yyvsp--, yyssp--)
  586. #endif
  587.  
  588.   int yystacksize = YYINITDEPTH;
  589.  
  590. #ifdef YYPURE
  591.   int yychar;
  592.   YYSTYPE yylval;
  593.   int yynerrs;
  594. #ifdef YYLSP_NEEDED
  595.   YYLTYPE yylloc;
  596. #endif
  597. #endif
  598.  
  599.   YYSTYPE yyval;        /*  the variable used to return        */
  600.                 /*  semantic values from the action    */
  601.                 /*  routines                */
  602.  
  603.   int yylen;
  604.  
  605. #if YYDEBUG != 0
  606.   if (yydebug)
  607.     fprintf(stderr, "Starting parse\n");
  608. #endif
  609.  
  610.   yystate = 0;
  611.   yyerrstatus = 0;
  612.   yynerrs = 0;
  613.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  614.  
  615.   /* Initialize stack pointers.
  616.      Waste one element of value and location stack
  617.      so that they stay on the same level as the state stack.
  618.      The wasted elements are never initialized.  */
  619.  
  620.   yyssp = yyss - 1;
  621.   yyvsp = yyvs;
  622. #ifdef YYLSP_NEEDED
  623.   yylsp = yyls;
  624. #endif
  625.  
  626. /* Push a new state, which is found in  yystate  .  */
  627. /* In all cases, when you get here, the value and location stacks
  628.    have just been pushed. so pushing a state here evens the stacks.  */
  629. yynewstate:
  630.  
  631.   *++yyssp = yystate;
  632.  
  633.   if (yyssp >= yyss + yystacksize - 1)
  634.     {
  635.       /* Give user a chance to reallocate the stack */
  636.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  637.       YYSTYPE *yyvs1 = yyvs;
  638.       short *yyss1 = yyss;
  639. #ifdef YYLSP_NEEDED
  640.       YYLTYPE *yyls1 = yyls;
  641. #endif
  642.  
  643.       /* Get the current used size of the three stacks, in elements.  */
  644.       int size = yyssp - yyss + 1;
  645.  
  646. #ifdef yyoverflow
  647.       /* Each stack pointer address is followed by the size of
  648.      the data in use in that stack, in bytes.  */
  649. #ifdef YYLSP_NEEDED
  650.       /* This used to be a conditional around just the two extra args,
  651.      but that might be undefined if yyoverflow is a macro.  */
  652.       yyoverflow("parser stack overflow",
  653.          &yyss1, size * sizeof (*yyssp),
  654.          &yyvs1, size * sizeof (*yyvsp),
  655.          &yyls1, size * sizeof (*yylsp),
  656.          &yystacksize);
  657. #else
  658.       yyoverflow("parser stack overflow",
  659.          &yyss1, size * sizeof (*yyssp),
  660.          &yyvs1, size * sizeof (*yyvsp),
  661.          &yystacksize);
  662. #endif
  663.  
  664.       yyss = yyss1; yyvs = yyvs1;
  665. #ifdef YYLSP_NEEDED
  666.       yyls = yyls1;
  667. #endif
  668. #else /* no yyoverflow */
  669.       /* Extend the stack our own way.  */
  670.       if (yystacksize >= YYMAXDEPTH)
  671.     {
  672.       yyerror("parser stack overflow");
  673.       return 2;
  674.     }
  675.       yystacksize *= 2;
  676.       if (yystacksize > YYMAXDEPTH)
  677.     yystacksize = YYMAXDEPTH;
  678.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  679.       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
  680.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  681.       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
  682. #ifdef YYLSP_NEEDED
  683.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  684.       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
  685. #endif
  686. #endif /* no yyoverflow */
  687.  
  688.       yyssp = yyss + size - 1;
  689.       yyvsp = yyvs + size - 1;
  690. #ifdef YYLSP_NEEDED
  691.       yylsp = yyls + size - 1;
  692. #endif
  693.  
  694. #if YYDEBUG != 0
  695.       if (yydebug)
  696.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  697. #endif
  698.  
  699.       if (yyssp >= yyss + yystacksize - 1)
  700.     YYABORT;
  701.     }
  702.  
  703. #if YYDEBUG != 0
  704.   if (yydebug)
  705.     fprintf(stderr, "Entering state %d\n", yystate);
  706. #endif
  707.  
  708.   goto yybackup;
  709.  yybackup:
  710.  
  711. /* Do appropriate processing given the current state.  */
  712. /* Read a lookahead token if we need one and don't already have one.  */
  713. /* yyresume: */
  714.  
  715.   /* First try to decide what to do without reference to lookahead token.  */
  716.  
  717.   yyn = yypact[yystate];
  718.   if (yyn == YYFLAG)
  719.     goto yydefault;
  720.  
  721.   /* Not known => get a lookahead token if don't already have one.  */
  722.  
  723.   /* yychar is either YYEMPTY or YYEOF
  724.      or a valid token in external form.  */
  725.  
  726.   if (yychar == YYEMPTY)
  727.     {
  728. #if YYDEBUG != 0
  729.       if (yydebug)
  730.     fprintf(stderr, "Reading a token: ");
  731. #endif
  732.       yychar = YYLEX;
  733.     }
  734.  
  735.   /* Convert token to internal form (in yychar1) for indexing tables with */
  736.  
  737.   if (yychar <= 0)        /* This means end of input. */
  738.     {
  739.       yychar1 = 0;
  740.       yychar = YYEOF;        /* Don't call YYLEX any more */
  741.  
  742. #if YYDEBUG != 0
  743.       if (yydebug)
  744.     fprintf(stderr, "Now at end of input.\n");
  745. #endif
  746.     }
  747.   else
  748.     {
  749.       yychar1 = YYTRANSLATE(yychar);
  750.  
  751. #if YYDEBUG != 0
  752.       if (yydebug)
  753.     {
  754.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  755.       /* Give the individual parser a way to print the precise meaning
  756.          of a token, for further debugging info.  */
  757. #ifdef YYPRINT
  758.       YYPRINT (stderr, yychar, yylval);
  759. #endif
  760.       fprintf (stderr, ")\n");
  761.     }
  762. #endif
  763.     }
  764.  
  765.   yyn += yychar1;
  766.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  767.     goto yydefault;
  768.  
  769.   yyn = yytable[yyn];
  770.  
  771.   /* yyn is what to do for this token type in this state.
  772.      Negative => reduce, -yyn is rule number.
  773.      Positive => shift, yyn is new state.
  774.        New state is final state => don't bother to shift,
  775.        just return success.
  776.      0, or most negative number => error.  */
  777.  
  778.   if (yyn < 0)
  779.     {
  780.       if (yyn == YYFLAG)
  781.     goto yyerrlab;
  782.       yyn = -yyn;
  783.       goto yyreduce;
  784.     }
  785.   else if (yyn == 0)
  786.     goto yyerrlab;
  787.  
  788.   if (yyn == YYFINAL)
  789.     YYACCEPT;
  790.  
  791.   /* Shift the lookahead token.  */
  792.  
  793. #if YYDEBUG != 0
  794.   if (yydebug)
  795.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  796. #endif
  797.  
  798.   /* Discard the token being shifted unless it is eof.  */
  799.   if (yychar != YYEOF)
  800.     yychar = YYEMPTY;
  801.  
  802.   *++yyvsp = yylval;
  803. #ifdef YYLSP_NEEDED
  804.   *++yylsp = yylloc;
  805. #endif
  806.  
  807.   /* count tokens shifted since error; after three, turn off error status.  */
  808.   if (yyerrstatus) yyerrstatus--;
  809.  
  810.   yystate = yyn;
  811.   goto yynewstate;
  812.  
  813. /* Do the default action for the current state.  */
  814. yydefault:
  815.  
  816.   yyn = yydefact[yystate];
  817.   if (yyn == 0)
  818.     goto yyerrlab;
  819.  
  820. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  821. yyreduce:
  822.   yylen = yyr2[yyn];
  823.   if (yylen > 0)
  824.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  825.  
  826. #if YYDEBUG != 0
  827.   if (yydebug)
  828.     {
  829.       int i;
  830.  
  831.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  832.            yyn, yyrline[yyn]);
  833.  
  834.       /* Print the symbols being reduced, and their result.  */
  835.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  836.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  837.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  838.     }
  839. #endif
  840.  
  841.  
  842.   switch (yyn) {
  843.  
  844. case 1:
  845. { /* add default rule */
  846.             int def_rule;
  847.  
  848.             pat = cclinit();
  849.             cclnegate( pat );
  850.  
  851.             def_rule = mkstate( -pat );
  852.  
  853.             /* Remember the number of the default rule so we
  854.              * don't generate "can't match" warnings for it.
  855.              */
  856.             default_rule = num_rules;
  857.  
  858.             finish_rule( def_rule, false, 0, 0 );
  859.  
  860.             for ( i = 1; i <= lastsc; ++i )
  861.                 scset[i] = mkbranch( scset[i], def_rule );
  862.  
  863.             if ( spprdflt )
  864.                 add_action(
  865.                 "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
  866.             else
  867.                 add_action( "ECHO" );
  868.  
  869.             add_action( ";\n\tYY_BREAK\n" );
  870.             ;
  871.     break;}
  872. case 2:
  873. { /* initialize for processing rules */
  874.  
  875.             /* Create default DFA start condition. */
  876.             scinstal( "INITIAL", false );
  877.             ;
  878.     break;}
  879. case 6:
  880. { synerr( "unknown error processing section 1" ); ;
  881.     break;}
  882. case 7:
  883. {
  884.             check_options();
  885.             scon_stk = allocate_integer_array( lastsc + 1 );
  886.             scon_stk_ptr = 0;
  887.             ;
  888.     break;}
  889. case 8:
  890. { xcluflg = false; ;
  891.     break;}
  892. case 9:
  893. { xcluflg = true; ;
  894.     break;}
  895. case 10:
  896. { scinstal( nmstr, xcluflg ); ;
  897.     break;}
  898. case 11:
  899. { scinstal( nmstr, xcluflg ); ;
  900.     break;}
  901. case 12:
  902. { synerr( "bad start condition list" ); ;
  903.     break;}
  904. case 16:
  905. {
  906.             outfilename = copy_string( nmstr );
  907.             did_outfilename = 1;
  908.             ;
  909.     break;}
  910. case 17:
  911. { prefix = copy_string( nmstr ); ;
  912.     break;}
  913. case 18:
  914. { yyclass = copy_string( nmstr ); ;
  915.     break;}
  916. case 19:
  917. { scon_stk_ptr = yyvsp[-3]; ;
  918.     break;}
  919. case 20:
  920. { scon_stk_ptr = yyvsp[-3]; ;
  921.     break;}
  922. case 22:
  923. {
  924.             /* Initialize for a parse of one rule. */
  925.             trlcontxt = variable_trail_rule = varlength = false;
  926.             trailcnt = headcnt = rulelen = 0;
  927.             current_state_type = STATE_NORMAL;
  928.             previous_continued_action = continued_action;
  929.             in_rule = true;
  930.  
  931.             new_rule();
  932.             ;
  933.     break;}
  934. case 23:
  935. {
  936.             pat = yyvsp[0];
  937.             finish_rule( pat, variable_trail_rule,
  938.                 headcnt, trailcnt );
  939.  
  940.             if ( scon_stk_ptr > 0 )
  941.                 {
  942.                 for ( i = 1; i <= scon_stk_ptr; ++i )
  943.                     scbol[scon_stk[i]] =
  944.                         mkbranch( scbol[scon_stk[i]],
  945.                                 pat );
  946.                 }
  947.  
  948.             else
  949.                 {
  950.                 /* Add to all non-exclusive start conditions,
  951.                  * including the default (0) start condition.
  952.                  */
  953.  
  954.                 for ( i = 1; i <= lastsc; ++i )
  955.                     if ( ! scxclu[i] )
  956.                         scbol[i] = mkbranch( scbol[i],
  957.                                     pat );
  958.                 }
  959.  
  960.             if ( ! bol_needed )
  961.                 {
  962.                 bol_needed = true;
  963.  
  964.                 if ( performance_report > 1 )
  965.                     pinpoint_message(
  966.             "'^' operator results in sub-optimal performance" );
  967.                 }
  968.             ;
  969.     break;}
  970. case 24:
  971. {
  972.             pat = yyvsp[0];
  973.             finish_rule( pat, variable_trail_rule,
  974.                 headcnt, trailcnt );
  975.  
  976.             if ( scon_stk_ptr > 0 )
  977.                 {
  978.                 for ( i = 1; i <= scon_stk_ptr; ++i )
  979.                     scset[scon_stk[i]] =
  980.                         mkbranch( scset[scon_stk[i]],
  981.                                 pat );
  982.                 }
  983.  
  984.             else
  985.                 {
  986.                 for ( i = 1; i <= lastsc; ++i )
  987.                     if ( ! scxclu[i] )
  988.                         scset[i] =
  989.                             mkbranch( scset[i],
  990.                                 pat );
  991.                 }
  992.             ;
  993.     break;}
  994. case 25:
  995. {
  996.             if ( scon_stk_ptr > 0 )
  997.                 build_eof_action();
  998.     
  999.             else
  1000.                 {
  1001.                 /* This EOF applies to all start conditions
  1002.                  * which don't already have EOF actions.
  1003.                  */
  1004.                 for ( i = 1; i <= lastsc; ++i )
  1005.                     if ( ! sceof[i] )
  1006.                         scon_stk[++scon_stk_ptr] = i;
  1007.  
  1008.                 if ( scon_stk_ptr == 0 )
  1009.                     warn(
  1010.             "all start conditions already have <<EOF>> rules" );
  1011.  
  1012.                 else
  1013.                     build_eof_action();
  1014.                 }
  1015.             ;
  1016.     break;}
  1017. case 26:
  1018. { synerr( "unrecognized rule" ); ;
  1019.     break;}
  1020. case 27:
  1021. { yyval = scon_stk_ptr; ;
  1022.     break;}
  1023. case 28:
  1024. { yyval = yyvsp[-2]; ;
  1025.     break;}
  1026. case 29:
  1027. {
  1028.             yyval = scon_stk_ptr;
  1029.  
  1030.             for ( i = 1; i <= lastsc; ++i )
  1031.                 {
  1032.                 int j;
  1033.  
  1034.                 for ( j = 1; j <= scon_stk_ptr; ++j )
  1035.                     if ( scon_stk[j] == i )
  1036.                         break;
  1037.  
  1038.                 if ( j > scon_stk_ptr )
  1039.                     scon_stk[++scon_stk_ptr] = i;
  1040.                 }
  1041.             ;
  1042.     break;}
  1043. case 30:
  1044. { yyval = scon_stk_ptr; ;
  1045.     break;}
  1046. case 33:
  1047. { synerr( "bad start condition list" ); ;
  1048.     break;}
  1049. case 34:
  1050. {
  1051.             if ( (scnum = sclookup( nmstr )) == 0 )
  1052.                 format_pinpoint_message(
  1053.                     "undeclared start condition %s",
  1054.                     nmstr );
  1055.             else
  1056.                 {
  1057.                 for ( i = 1; i <= scon_stk_ptr; ++i )
  1058.                     if ( scon_stk[i] == scnum )
  1059.                         {
  1060.                         format_warn(
  1061.                             "<%s> specified twice",
  1062.                             scname[scnum] );
  1063.                         break;
  1064.                         }
  1065.  
  1066.                 if ( i > scon_stk_ptr )
  1067.                     scon_stk[++scon_stk_ptr] = scnum;
  1068.                 }
  1069.             ;
  1070.     break;}
  1071. case 35:
  1072. {
  1073.             if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
  1074.                 /* Provide final transition \now/ so it
  1075.                  * will be marked as a trailing context
  1076.                  * state.
  1077.                  */
  1078.                 yyvsp[0] = link_machines( yyvsp[0],
  1079.                         mkstate( SYM_EPSILON ) );
  1080.  
  1081.             mark_beginning_as_normal( yyvsp[0] );
  1082.             current_state_type = STATE_NORMAL;
  1083.  
  1084.             if ( previous_continued_action )
  1085.                 {
  1086.                 /* We need to treat this as variable trailing
  1087.                  * context so that the backup does not happen
  1088.                  * in the action but before the action switch
  1089.                  * statement.  If the backup happens in the
  1090.                  * action, then the rules "falling into" this
  1091.                  * one's action will *also* do the backup,
  1092.                  * erroneously.
  1093.                  */
  1094.                 if ( ! varlength || headcnt != 0 )
  1095.                     warn(
  1096.         "trailing context made variable due to preceding '|' action" );
  1097.  
  1098.                 /* Mark as variable. */
  1099.                 varlength = true;
  1100.                 headcnt = 0;
  1101.                 }
  1102.  
  1103.             if ( lex_compat || (varlength && headcnt == 0) )
  1104.                 { /* variable trailing context rule */
  1105.                 /* Mark the first part of the rule as the
  1106.                  * accepting "head" part of a trailing
  1107.                  * context rule.
  1108.                  *
  1109.                  * By the way, we didn't do this at the
  1110.                  * beginning of this production because back
  1111.                  * then current_state_type was set up for a
  1112.                  * trail rule, and add_accept() can create
  1113.                  * a new state ...
  1114.                  */
  1115.                 add_accept( yyvsp[-1],
  1116.                     num_rules | YY_TRAILING_HEAD_MASK );
  1117.                 variable_trail_rule = true;
  1118.                 }
  1119.             
  1120.             else
  1121.                 trailcnt = rulelen;
  1122.  
  1123.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1124.             ;
  1125.     break;}
  1126. case 36:
  1127. { synerr( "trailing context used twice" ); ;
  1128.     break;}
  1129. case 37:
  1130. {
  1131.             headcnt = 0;
  1132.             trailcnt = 1;
  1133.             rulelen = 1;
  1134.             varlength = false;
  1135.  
  1136.             current_state_type = STATE_TRAILING_CONTEXT;
  1137.  
  1138.             if ( trlcontxt )
  1139.                 {
  1140.                 synerr( "trailing context used twice" );
  1141.                 yyval = mkstate( SYM_EPSILON );
  1142.                 }
  1143.  
  1144.             else if ( previous_continued_action )
  1145.                 {
  1146.                 /* See the comment in the rule for "re2 re"
  1147.                  * above.
  1148.                  */
  1149.                 warn(
  1150.         "trailing context made variable due to preceding '|' action" );
  1151.  
  1152.                 varlength = true;
  1153.                 }
  1154.  
  1155.             if ( lex_compat || varlength )
  1156.                 {
  1157.                 /* Again, see the comment in the rule for
  1158.                  * "re2 re" above.
  1159.                  */
  1160.                 add_accept( yyvsp[-1],
  1161.                     num_rules | YY_TRAILING_HEAD_MASK );
  1162.                 variable_trail_rule = true;
  1163.                 }
  1164.  
  1165.             trlcontxt = true;
  1166.  
  1167.             eps = mkstate( SYM_EPSILON );
  1168.             yyval = link_machines( yyvsp[-1],
  1169.                 link_machines( eps, mkstate( '\n' ) ) );
  1170.             ;
  1171.     break;}
  1172. case 38:
  1173. {
  1174.             yyval = yyvsp[0];
  1175.  
  1176.             if ( trlcontxt )
  1177.                 {
  1178.                 if ( lex_compat || (varlength && headcnt == 0) )
  1179.                     /* Both head and trail are
  1180.                      * variable-length.
  1181.                      */
  1182.                     variable_trail_rule = true;
  1183.                 else
  1184.                     trailcnt = rulelen;
  1185.                 }
  1186.             ;
  1187.     break;}
  1188. case 39:
  1189. {
  1190.             varlength = true;
  1191.             yyval = mkor( yyvsp[-2], yyvsp[0] );
  1192.             ;
  1193.     break;}
  1194. case 40:
  1195. { yyval = yyvsp[0]; ;
  1196.     break;}
  1197. case 41:
  1198. {
  1199.             /* This rule is written separately so the
  1200.              * reduction will occur before the trailing
  1201.              * series is parsed.
  1202.              */
  1203.  
  1204.             if ( trlcontxt )
  1205.                 synerr( "trailing context used twice" );
  1206.             else
  1207.                 trlcontxt = true;
  1208.  
  1209.             if ( varlength )
  1210.                 /* We hope the trailing context is
  1211.                  * fixed-length.
  1212.                  */
  1213.                 varlength = false;
  1214.             else
  1215.                 headcnt = rulelen;
  1216.  
  1217.             rulelen = 0;
  1218.  
  1219.             current_state_type = STATE_TRAILING_CONTEXT;
  1220.             yyval = yyvsp[-1];
  1221.             ;
  1222.     break;}
  1223. case 42:
  1224. {
  1225.             /* This is where concatenation of adjacent patterns
  1226.              * gets done.
  1227.              */
  1228.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1229.             ;
  1230.     break;}
  1231. case 43:
  1232. { yyval = yyvsp[0]; ;
  1233.     break;}
  1234. case 44:
  1235. {
  1236.             varlength = true;
  1237.  
  1238.             yyval = mkclos( yyvsp[-1] );
  1239.             ;
  1240.     break;}
  1241. case 45:
  1242. {
  1243.             varlength = true;
  1244.             yyval = mkposcl( yyvsp[-1] );
  1245.             ;
  1246.     break;}
  1247. case 46:
  1248. {
  1249.             varlength = true;
  1250.             yyval = mkopt( yyvsp[-1] );
  1251.             ;
  1252.     break;}
  1253. case 47:
  1254. {
  1255.             varlength = true;
  1256.  
  1257.             if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
  1258.                 {
  1259.                 synerr( "bad iteration values" );
  1260.                 yyval = yyvsp[-5];
  1261.                 }
  1262.             else
  1263.                 {
  1264.                 if ( yyvsp[-3] == 0 )
  1265.                     {
  1266.                     if ( yyvsp[-1] <= 0 )
  1267.                         {
  1268.                         synerr(
  1269.                         "bad iteration values" );
  1270.                         yyval = yyvsp[-5];
  1271.                         }
  1272.                     else
  1273.                         yyval = mkopt(
  1274.                             mkrep( yyvsp[-5], 1, yyvsp[-1] ) );
  1275.                     }
  1276.                 else
  1277.                     yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
  1278.                 }
  1279.             ;
  1280.     break;}
  1281. case 48:
  1282. {
  1283.             varlength = true;
  1284.  
  1285.             if ( yyvsp[-2] <= 0 )
  1286.                 {
  1287.                 synerr( "iteration value must be positive" );
  1288.                 yyval = yyvsp[-4];
  1289.                 }
  1290.  
  1291.             else
  1292.                 yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
  1293.             ;
  1294.     break;}
  1295. case 49:
  1296. {
  1297.             /* The singleton could be something like "(foo)",
  1298.              * in which case we have no idea what its length
  1299.              * is, so we punt here.
  1300.              */
  1301.             varlength = true;
  1302.  
  1303.             if ( yyvsp[-1] <= 0 )
  1304.                 {
  1305.                 synerr( "iteration value must be positive" );
  1306.                 yyval = yyvsp[-3];
  1307.                 }
  1308.  
  1309.             else
  1310.                 yyval = link_machines( yyvsp[-3],
  1311.                         copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
  1312.             ;
  1313.     break;}
  1314. case 50:
  1315. {
  1316.             if ( ! madeany )
  1317.                 {
  1318.                 /* Create the '.' character class. */
  1319.                 anyccl = cclinit();
  1320.                 ccladd( anyccl, '\n' );
  1321.                 cclnegate( anyccl );
  1322.  
  1323.                 if ( useecs )
  1324.                     mkeccl( ccltbl + cclmap[anyccl],
  1325.                         ccllen[anyccl], nextecm,
  1326.                         ecgroup, csize, csize );
  1327.  
  1328.                 madeany = true;
  1329.                 }
  1330.  
  1331.             ++rulelen;
  1332.  
  1333.             yyval = mkstate( -anyccl );
  1334.             ;
  1335.     break;}
  1336. case 51:
  1337. {
  1338.             if ( ! cclsorted )
  1339.                 /* Sort characters for fast searching.  We
  1340.                  * use a shell sort since this list could
  1341.                  * be large.
  1342.                  */
  1343.                 cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true );
  1344.  
  1345.             if ( useecs )
  1346.                 mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
  1347.                     nextecm, ecgroup, csize, csize );
  1348.  
  1349.             ++rulelen;
  1350.  
  1351.             yyval = mkstate( -yyvsp[0] );
  1352.             ;
  1353.     break;}
  1354. case 52:
  1355. {
  1356.             ++rulelen;
  1357.  
  1358.             yyval = mkstate( -yyvsp[0] );
  1359.             ;
  1360.     break;}
  1361. case 53:
  1362. { yyval = yyvsp[-1]; ;
  1363.     break;}
  1364. case 54:
  1365. { yyval = yyvsp[-1]; ;
  1366.     break;}
  1367. case 55:
  1368. {
  1369.             ++rulelen;
  1370.  
  1371.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1372.                 yyvsp[0] = clower( yyvsp[0] );
  1373.  
  1374.             yyval = mkstate( yyvsp[0] );
  1375.             ;
  1376.     break;}
  1377. case 56:
  1378. { yyval = yyvsp[-1]; ;
  1379.     break;}
  1380. case 57:
  1381. {
  1382.             cclnegate( yyvsp[-1] );
  1383.             yyval = yyvsp[-1];
  1384.             ;
  1385.     break;}
  1386. case 58:
  1387. {
  1388.             if ( caseins )
  1389.                 {
  1390.                 if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
  1391.                     yyvsp[-2] = clower( yyvsp[-2] );
  1392.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1393.                     yyvsp[0] = clower( yyvsp[0] );
  1394.                 }
  1395.  
  1396.             if ( yyvsp[-2] > yyvsp[0] )
  1397.                 synerr( "negative range in character class" );
  1398.  
  1399.             else
  1400.                 {
  1401.                 for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
  1402.                     ccladd( yyvsp[-3], i );
  1403.  
  1404.                 /* Keep track if this ccl is staying in
  1405.                  * alphabetical order.
  1406.                  */
  1407.                 cclsorted = cclsorted && (yyvsp[-2] > lastchar);
  1408.                 lastchar = yyvsp[0];
  1409.                 }
  1410.  
  1411.             yyval = yyvsp[-3];
  1412.             ;
  1413.     break;}
  1414. case 59:
  1415. {
  1416.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1417.                 yyvsp[0] = clower( yyvsp[0] );
  1418.  
  1419.             ccladd( yyvsp[-1], yyvsp[0] );
  1420.             cclsorted = cclsorted && (yyvsp[0] > lastchar);
  1421.             lastchar = yyvsp[0];
  1422.             yyval = yyvsp[-1];
  1423.             ;
  1424.     break;}
  1425. case 60:
  1426. {
  1427.             /* Too hard to properly maintain cclsorted. */
  1428.             cclsorted = false;
  1429.             yyval = yyvsp[-1];
  1430.             ;
  1431.     break;}
  1432. case 61:
  1433. {
  1434.             cclsorted = true;
  1435.             lastchar = 0;
  1436.             currccl = yyval = cclinit();
  1437.             ;
  1438.     break;}
  1439. case 62:
  1440. { CCL_EXPR(isalnum) ;
  1441.     break;}
  1442. case 63:
  1443. { CCL_EXPR(isalpha) ;
  1444.     break;}
  1445. case 64:
  1446. { CCL_EXPR(IS_BLANK) ;
  1447.     break;}
  1448. case 65:
  1449. { CCL_EXPR(iscntrl) ;
  1450.     break;}
  1451. case 66:
  1452. { CCL_EXPR(isdigit) ;
  1453.     break;}
  1454. case 67:
  1455. { CCL_EXPR(isgraph) ;
  1456.     break;}
  1457. case 68:
  1458. { CCL_EXPR(islower) ;
  1459.     break;}
  1460. case 69:
  1461. { CCL_EXPR(isprint) ;
  1462.     break;}
  1463. case 70:
  1464. { CCL_EXPR(ispunct) ;
  1465.     break;}
  1466. case 71:
  1467. { CCL_EXPR(isspace) ;
  1468.     break;}
  1469. case 72:
  1470. {
  1471.                 if ( caseins )
  1472.                     CCL_EXPR(islower)
  1473.                 else
  1474.                     CCL_EXPR(isupper)
  1475.                 ;
  1476.     break;}
  1477. case 73:
  1478. { CCL_EXPR(isxdigit) ;
  1479.     break;}
  1480. case 74:
  1481. {
  1482.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1483.                 yyvsp[0] = clower( yyvsp[0] );
  1484.  
  1485.             ++rulelen;
  1486.  
  1487.             yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
  1488.             ;
  1489.     break;}
  1490. case 75:
  1491. { yyval = mkstate( SYM_EPSILON ); ;
  1492.     break;}
  1493. }
  1494.    /* the action file gets copied in in place of this dollarsign */
  1495.  
  1496.  
  1497.   yyvsp -= yylen;
  1498.   yyssp -= yylen;
  1499. #ifdef YYLSP_NEEDED
  1500.   yylsp -= yylen;
  1501. #endif
  1502.  
  1503. #if YYDEBUG != 0
  1504.   if (yydebug)
  1505.     {
  1506.       short *ssp1 = yyss - 1;
  1507.       fprintf (stderr, "state stack now");
  1508.       while (ssp1 != yyssp)
  1509.     fprintf (stderr, " %d", *++ssp1);
  1510.       fprintf (stderr, "\n");
  1511.     }
  1512. #endif
  1513.  
  1514.   *++yyvsp = yyval;
  1515.  
  1516. #ifdef YYLSP_NEEDED
  1517.   yylsp++;
  1518.   if (yylen == 0)
  1519.     {
  1520.       yylsp->first_line = yylloc.first_line;
  1521.       yylsp->first_column = yylloc.first_column;
  1522.       yylsp->last_line = (yylsp-1)->last_line;
  1523.       yylsp->last_column = (yylsp-1)->last_column;
  1524.       yylsp->text = 0;
  1525.     }
  1526.   else
  1527.     {
  1528.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1529.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1530.     }
  1531. #endif
  1532.  
  1533.   /* Now "shift" the result of the reduction.
  1534.      Determine what state that goes to,
  1535.      based on the state we popped back to
  1536.      and the rule number reduced by.  */
  1537.  
  1538.   yyn = yyr1[yyn];
  1539.  
  1540.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1541.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1542.     yystate = yytable[yystate];
  1543.   else
  1544.     yystate = yydefgoto[yyn - YYNTBASE];
  1545.  
  1546.   goto yynewstate;
  1547.  
  1548. yyerrlab:   /* here on detecting error */
  1549.  
  1550.   if (! yyerrstatus)
  1551.     /* If not already recovering from an error, report this error.  */
  1552.     {
  1553.       ++yynerrs;
  1554.  
  1555. #ifdef YYERROR_VERBOSE
  1556.       yyn = yypact[yystate];
  1557.  
  1558.       if (yyn > YYFLAG && yyn < YYLAST)
  1559.     {
  1560.       int size = 0;
  1561.       char *msg;
  1562.       int x, count;
  1563.  
  1564.       count = 0;
  1565.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1566.       for (x = (yyn < 0 ? -yyn : 0);
  1567.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1568.         if (yycheck[x + yyn] == x)
  1569.           size += strlen(yytname[x]) + 15, count++;
  1570.       msg = (char *) malloc(size + 15);
  1571.       if (msg != 0)
  1572.         {
  1573.           strcpy(msg, "parse error");
  1574.  
  1575.           if (count < 5)
  1576.         {
  1577.           count = 0;
  1578.           for (x = (yyn < 0 ? -yyn : 0);
  1579.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1580.             if (yycheck[x + yyn] == x)
  1581.               {
  1582.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1583.             strcat(msg, yytname[x]);
  1584.             strcat(msg, "'");
  1585.             count++;
  1586.               }
  1587.         }
  1588.           yyerror(msg);
  1589.           free(msg);
  1590.         }
  1591.       else
  1592.         yyerror ("parse error; also virtual memory exceeded");
  1593.     }
  1594.       else
  1595. #endif /* YYERROR_VERBOSE */
  1596.     yyerror("parse error");
  1597.     }
  1598.  
  1599.   goto yyerrlab1;
  1600. yyerrlab1:   /* here on error raised explicitly by an action */
  1601.  
  1602.   if (yyerrstatus == 3)
  1603.     {
  1604.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1605.  
  1606.       /* return failure if at end of input */
  1607.       if (yychar == YYEOF)
  1608.     YYABORT;
  1609.  
  1610. #if YYDEBUG != 0
  1611.       if (yydebug)
  1612.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1613. #endif
  1614.  
  1615.       yychar = YYEMPTY;
  1616.     }
  1617.  
  1618.   /* Else will try to reuse lookahead token
  1619.      after shifting the error token.  */
  1620.  
  1621.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1622.  
  1623.   goto yyerrhandle;
  1624.  
  1625. yyerrdefault:  /* current state does not do anything special for the error token. */
  1626.  
  1627. #if 0
  1628.   /* This is wrong; only states that explicitly want error tokens
  1629.      should shift them.  */
  1630.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1631.   if (yyn) goto yydefault;
  1632. #endif
  1633.  
  1634. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1635.  
  1636.   if (yyssp == yyss) YYABORT;
  1637.   yyvsp--;
  1638.   yystate = *--yyssp;
  1639. #ifdef YYLSP_NEEDED
  1640.   yylsp--;
  1641. #endif
  1642.  
  1643. #if YYDEBUG != 0
  1644.   if (yydebug)
  1645.     {
  1646.       short *ssp1 = yyss - 1;
  1647.       fprintf (stderr, "Error: state stack now");
  1648.       while (ssp1 != yyssp)
  1649.     fprintf (stderr, " %d", *++ssp1);
  1650.       fprintf (stderr, "\n");
  1651.     }
  1652. #endif
  1653.  
  1654. yyerrhandle:
  1655.  
  1656.   yyn = yypact[yystate];
  1657.   if (yyn == YYFLAG)
  1658.     goto yyerrdefault;
  1659.  
  1660.   yyn += YYTERROR;
  1661.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1662.     goto yyerrdefault;
  1663.  
  1664.   yyn = yytable[yyn];
  1665.   if (yyn < 0)
  1666.     {
  1667.       if (yyn == YYFLAG)
  1668.     goto yyerrpop;
  1669.       yyn = -yyn;
  1670.       goto yyreduce;
  1671.     }
  1672.   else if (yyn == 0)
  1673.     goto yyerrpop;
  1674.  
  1675.   if (yyn == YYFINAL)
  1676.     YYACCEPT;
  1677.  
  1678. #if YYDEBUG != 0
  1679.   if (yydebug)
  1680.     fprintf(stderr, "Shifting error token, ");
  1681. #endif
  1682.  
  1683.   *++yyvsp = yylval;
  1684. #ifdef YYLSP_NEEDED
  1685.   *++yylsp = yylloc;
  1686. #endif
  1687.  
  1688.   yystate = yyn;
  1689.   goto yynewstate;
  1690. }
  1691.  
  1692.  
  1693.  
  1694. /* build_eof_action - build the "<<EOF>>" action for the active start
  1695.  *                    conditions
  1696.  */
  1697.  
  1698. void build_eof_action()
  1699.     {
  1700.     register int i;
  1701.     char action_text[MAXLINE];
  1702.  
  1703.     for ( i = 1; i <= scon_stk_ptr; ++i )
  1704.         {
  1705.         if ( sceof[scon_stk[i]] )
  1706.             format_pinpoint_message(
  1707.                 "multiple <<EOF>> rules for start condition %s",
  1708.                 scname[scon_stk[i]] );
  1709.  
  1710.         else
  1711.             {
  1712.             sceof[scon_stk[i]] = true;
  1713.             sprintf( action_text, "case YY_STATE_EOF(%s):\n",
  1714.                 scname[scon_stk[i]] );
  1715.             add_action( action_text );
  1716.             }
  1717.         }
  1718.  
  1719.     line_directive_out( (FILE *) 0, 1 );
  1720.  
  1721.     /* This isn't a normal rule after all - don't count it as
  1722.      * such, so we don't have any holes in the rule numbering
  1723.      * (which make generating "rule can never match" warnings
  1724.      * more difficult.
  1725.      */
  1726.     --num_rules;
  1727.     ++num_eof_rules;
  1728.     }
  1729.  
  1730.  
  1731. /* format_synerr - write out formatted syntax error */
  1732.  
  1733. void format_synerr( msg, arg )
  1734. char msg[], arg[];
  1735.     {
  1736.     char errmsg[MAXLINE];
  1737.  
  1738.     (void) sprintf( errmsg, msg, arg );
  1739.     synerr( errmsg );
  1740.     }
  1741.  
  1742.  
  1743. /* synerr - report a syntax error */
  1744.  
  1745. void synerr( str )
  1746. char str[];
  1747.     {
  1748.     syntaxerror = true;
  1749.     pinpoint_message( str );
  1750.     }
  1751.  
  1752.  
  1753. /* format_warn - write out formatted warning */
  1754.  
  1755. void format_warn( msg, arg )
  1756. char msg[], arg[];
  1757.     {
  1758.     char warn_msg[MAXLINE];
  1759.  
  1760.     (void) sprintf( warn_msg, msg, arg );
  1761.     warn( warn_msg );
  1762.     }
  1763.  
  1764.  
  1765. /* warn - report a warning, unless -w was given */
  1766.  
  1767. void warn( str )
  1768. char str[];
  1769.     {
  1770.     line_warning( str, linenum );
  1771.     }
  1772.  
  1773. /* format_pinpoint_message - write out a message formatted with one string,
  1774.  *                 pinpointing its location
  1775.  */
  1776.  
  1777. void format_pinpoint_message( msg, arg )
  1778. char msg[], arg[];
  1779.     {
  1780.     char errmsg[MAXLINE];
  1781.  
  1782.     (void) sprintf( errmsg, msg, arg );
  1783.     pinpoint_message( errmsg );
  1784.     }
  1785.  
  1786.  
  1787. /* pinpoint_message - write out a message, pinpointing its location */
  1788.  
  1789. void pinpoint_message( str )
  1790. char str[];
  1791.     {
  1792.     line_pinpoint( str, linenum );
  1793.     }
  1794.  
  1795.  
  1796. /* line_warning - report a warning at a given line, unless -w was given */
  1797.  
  1798. void line_warning( str, line )
  1799. char str[];
  1800. int line;
  1801.     {
  1802.     char warning[MAXLINE];
  1803.  
  1804.     if ( ! nowarn )
  1805.         {
  1806.         sprintf( warning, "warning, %s", str );
  1807.         line_pinpoint( warning, line );
  1808.         }
  1809.     }
  1810.  
  1811.  
  1812. /* line_pinpoint - write out a message, pinpointing it at the given line */
  1813.  
  1814. void line_pinpoint( str, line )
  1815. char str[];
  1816. int line;
  1817.     {
  1818.     fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str );
  1819.     }
  1820.  
  1821.  
  1822. /* yyerror - eat up an error message from the parser;
  1823.  *         currently, messages are ignore
  1824.  */
  1825.  
  1826. void yyerror( msg )
  1827. char msg[];
  1828.     {
  1829.     }
  1830.