xref: /freebsd/usr.bin/lex/initparse.c (revision 8c2f6c3be0125142d3c1782e4b0ee0634c584b9e)
1 /* original parser id follows */
2 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
3 
4 #define YYBYACC 1
5 #define YYMAJOR 1
6 #define YYMINOR 9
7 #define YYPATCH 20200330
8 
9 #define YYEMPTY        (-1)
10 #define yyclearin      (yychar = YYEMPTY)
11 #define yyerrok        (yyerrflag = 0)
12 #define YYRECOVERING() (yyerrflag != 0)
13 #define YYENOMEM       (-2)
14 #define YYEOF          0
15 #define YYPREFIX "yy"
16 
17 #define YYPURE 0
18 
19 #line 35 "parse.y"
20 /*  Copyright (c) 1990 The Regents of the University of California. */
21 /*  All rights reserved. */
22 
23 /*  This code is derived from software contributed to Berkeley by */
24 /*  Vern Paxson. */
25 
26 /*  The United States Government has rights in this work pursuant */
27 /*  to contract no. DE-AC03-76SF00098 between the United States */
28 /*  Department of Energy and the University of California. */
29 
30 /*  This file is part of flex. */
31 
32 /*  Redistribution and use in source and binary forms, with or without */
33 /*  modification, are permitted provided that the following conditions */
34 /*  are met: */
35 
36 /*  1. Redistributions of source code must retain the above copyright */
37 /*     notice, this list of conditions and the following disclaimer. */
38 /*  2. Redistributions in binary form must reproduce the above copyright */
39 /*     notice, this list of conditions and the following disclaimer in the */
40 /*     documentation and/or other materials provided with the distribution. */
41 
42 /*  Neither the name of the University nor the names of its contributors */
43 /*  may be used to endorse or promote products derived from this software */
44 /*  without specific prior written permission. */
45 
46 /*  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
47 /*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
48 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
49 /*  PURPOSE. */
50 
51 #include "flexdef.h"
52 #include "tables.h"
53 
54 int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen;
55 int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
56 
57 int *scon_stk;
58 int scon_stk_ptr;
59 
60 static int madeany = false;  /* whether we've made the '.' character class */
61 static int ccldot, cclany;
62 int previous_continued_action;	/* whether the previous rule's action was '|' */
63 
64 #define format_warn3(fmt, a1, a2) \
65 	do{ \
66         char fw3_msg[MAXLINE];\
67         snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
68         lwarn( fw3_msg );\
69 	}while(0)
70 
71 /* Expand a POSIX character class expression. */
72 #define CCL_EXPR(func) \
73 	do{ \
74 	int c; \
75 	for ( c = 0; c < csize; ++c ) \
76 		if ( isascii(c) && func(c) ) \
77 			ccladd( currccl, c ); \
78 	}while(0)
79 
80 /* negated class */
81 #define CCL_NEG_EXPR(func) \
82 	do{ \
83 	int c; \
84 	for ( c = 0; c < csize; ++c ) \
85 		if ( !func(c) ) \
86 			ccladd( currccl, c ); \
87 	}while(0)
88 
89 /* While POSIX defines isblank(), it's not ANSI C. */
90 #define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
91 
92 /* On some over-ambitious machines, such as DEC Alpha's, the default
93  * token type is "long" instead of "int"; this leads to problems with
94  * declaring yylval in flexdef.h.  But so far, all the yacc's I've seen
95  * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
96  * following should ensure that the default token type is "int".
97  */
98 #define YYSTYPE int
99 
100 #line 102 "parse.c"
101 
102 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
103 /* Default: YYSTYPE is the semantic value type. */
104 typedef int YYSTYPE;
105 # define YYSTYPE_IS_DECLARED 1
106 #endif
107 
108 /* compatibility with bison */
109 #ifdef YYPARSE_PARAM
110 /* compatibility with FreeBSD */
111 # ifdef YYPARSE_PARAM_TYPE
112 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
113 # else
114 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
115 # endif
116 #else
117 # define YYPARSE_DECL() yyparse(void)
118 #endif
119 
120 /* Parameters sent to lex. */
121 #ifdef YYLEX_PARAM
122 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
123 # define YYLEX yylex(YYLEX_PARAM)
124 #else
125 # define YYLEX_DECL() yylex(void)
126 # define YYLEX yylex()
127 #endif
128 
129 #if !(defined(yylex) || defined(YYSTATE))
130 int YYLEX_DECL();
131 #endif
132 
133 /* Parameters sent to yyerror. */
134 #ifndef YYERROR_DECL
135 #define YYERROR_DECL() yyerror(const char *s)
136 #endif
137 #ifndef YYERROR_CALL
138 #define YYERROR_CALL(msg) yyerror(msg)
139 #endif
140 
141 extern int YYPARSE_DECL();
142 
143 #define CHAR 257
144 #define NUMBER 258
145 #define SECTEND 259
146 #define SCDECL 260
147 #define XSCDECL 261
148 #define NAME 262
149 #define PREVCCL 263
150 #define EOF_OP 264
151 #define TOK_OPTION 265
152 #define TOK_OUTFILE 266
153 #define TOK_PREFIX 267
154 #define TOK_YYCLASS 268
155 #define TOK_HEADER_FILE 269
156 #define TOK_EXTRA_TYPE 270
157 #define TOK_TABLES_FILE 271
158 #define CCE_ALNUM 272
159 #define CCE_ALPHA 273
160 #define CCE_BLANK 274
161 #define CCE_CNTRL 275
162 #define CCE_DIGIT 276
163 #define CCE_GRAPH 277
164 #define CCE_LOWER 278
165 #define CCE_PRINT 279
166 #define CCE_PUNCT 280
167 #define CCE_SPACE 281
168 #define CCE_UPPER 282
169 #define CCE_XDIGIT 283
170 #define CCE_NEG_ALNUM 284
171 #define CCE_NEG_ALPHA 285
172 #define CCE_NEG_BLANK 286
173 #define CCE_NEG_CNTRL 287
174 #define CCE_NEG_DIGIT 288
175 #define CCE_NEG_GRAPH 289
176 #define CCE_NEG_LOWER 290
177 #define CCE_NEG_PRINT 291
178 #define CCE_NEG_PUNCT 292
179 #define CCE_NEG_SPACE 293
180 #define CCE_NEG_UPPER 294
181 #define CCE_NEG_XDIGIT 295
182 #define CCL_OP_DIFF 296
183 #define CCL_OP_UNION 297
184 #define BEGIN_REPEAT_POSIX 298
185 #define END_REPEAT_POSIX 299
186 #define BEGIN_REPEAT_FLEX 300
187 #define END_REPEAT_FLEX 301
188 #define YYERRCODE 256
189 typedef int YYINT;
190 static const YYINT yylhs[] = {                           -1,
191     0,    1,    2,    2,    2,    2,    3,    6,    6,    7,
192     7,    7,    8,    9,    9,   10,   10,   10,   10,   10,
193    10,    4,    4,    4,    5,   12,   12,   12,   12,   14,
194    11,   11,   11,   15,   15,   15,   16,   13,   13,   13,
195    13,   18,   18,   17,   19,   19,   19,   19,   19,   20,
196    20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
197    20,   21,   21,   21,   23,   23,   24,   24,   24,   24,
198    25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
199    25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
200    25,   25,   25,   25,   22,   22,
201 };
202 static const YYINT yylen[] = {                            2,
203     5,    0,    3,    2,    0,    1,    1,    1,    1,    2,
204     1,    1,    2,    2,    0,    3,    3,    3,    3,    3,
205     3,    5,    5,    0,    0,    2,    1,    1,    1,    0,
206     4,    3,    0,    3,    1,    1,    1,    2,    3,    2,
207     1,    3,    1,    2,    2,    1,    6,    5,    4,    2,
208     2,    2,    6,    5,    4,    1,    1,    1,    3,    3,
209     1,    3,    3,    1,    3,    4,    4,    2,    2,    0,
210     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
211     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
212     1,    1,    1,    1,    2,    0,
213 };
214 static const YYINT yydefred[] = {                         2,
215     0,    0,    6,    0,    7,    8,    9,   15,   24,    0,
216     4,    0,    0,   12,   11,    0,    0,    0,    0,    0,
217     0,    0,   14,    0,    1,    0,   10,    0,    0,    0,
218     0,    0,    0,    0,    0,   24,    0,   16,   18,   19,
219    20,   17,   21,   32,   36,   37,    0,   35,    0,   29,
220    61,   58,   28,    0,   56,   96,    0,    0,    0,   27,
221     0,    0,    0,    0,    0,   64,   31,    0,   23,   26,
222     0,    0,   70,    0,   22,    0,   40,    0,   44,    0,
223     0,    0,   50,   51,   52,    0,    0,   34,   95,   59,
224    60,    0,    0,   71,   72,   73,   74,   75,   76,   77,
225    78,   79,   80,   82,   81,   83,   84,   85,   86,   87,
226    88,   93,   89,   90,   91,   94,   92,   65,   69,   39,
227     0,    0,    0,   62,   63,   66,    0,   49,    0,   55,
228     0,   67,    0,   48,    0,   54,   47,   53,
229 };
230 static const YYINT yydgoto[] = {                          1,
231     2,    4,    9,   13,   25,   10,   16,   11,   12,   23,
232    26,   59,   60,   35,   47,   48,   61,   62,   63,   64,
233    65,   71,   66,   74,  119,
234 };
235 static const YYINT yysindex[] = {                         0,
236     0, -222,    0, -155,    0,    0,    0,    0,    0, -215,
237     0, -123,    6,    0,    0, -193,   10,   21,   26,   31,
238    35,   37,    0,   59,    0,  -44,    0, -147, -145, -140,
239  -133, -132, -129,   75, -214,    0,  -19,    0,    0,    0,
240     0,    0,    0,    0,    0,    0,   23,    0,  -48,    0,
241     0,    0,    0,  -17,    0,    0,  -17,   27,  128,    0,
242   -17,   -1,  -30,  -41, -189,    0,    0, -121,    0,    0,
243   -31,  -34,    0,  -87,    0,  -25,    0,  -17,    0, -109,
244   -41, -108,    0,    0,    0,   60,   60,    0,    0,    0,
245     0,   46,  107,    0,    0,    0,    0,    0,    0,    0,
246     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
247     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
248   -30,  -36,  -39,    0,    0,    0, -104,    0, -219,    0,
249  -238,    0, -144,    0, -143,    0,    0,    0,
250 };
251 static const YYINT yyrindex[] = {                         0,
252     0, -141,    0,    0,    0,    0,    0,    0,    0,    0,
253     0, -134,    9,    0,    0, -125,    0,    0,    0,    0,
254     0,    0,    0, -178,    0,   22,    0,    0,    0,    0,
255     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
256     0,    0,    0,    0,    0,    0,    0,    0,  -21,    0,
257     0,    0,    0,    0,    0,    0,    0,   85,    0,    0,
258     0,  144,   47,    4,  -10,    0,    0,    0,    0,    0,
259     0,    0,    0,    0,    0,  146,    0,    0,    0,    0,
260    18,    0,    0,    0,    0,    0,    0,    0,    0,    0,
261     0,    0,  124,    0,    0,    0,    0,    0,    0,    0,
262     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
263     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
264    50,    0,    0,    0,    0,    0,    0,    0,    0,    0,
265     0,    0,    0,    0,    0,    0,    0,    0,
266 };
267 static const YYINT yygindex[] = {                         0,
268     0,    0,    0,  121,  133,    0,    0,    0,    0,    0,
269     0,    0,  106,    0,    0,   93,    0,   32,   84,  -45,
270     0,    0,   25,   90,    0,
271 };
272 #define YYTABLESIZE 419
273 static const YYINT yytable[] = {                         57,
274    83,   84,   90,   56,  131,  118,   91,  129,   25,   57,
275   120,   24,   33,   46,   56,   55,   56,   81,   33,  135,
276    57,   85,   57,   57,   33,   57,   55,   45,   55,   57,
277    57,   57,   57,    3,   77,   57,   57,   46,  133,   46,
278    14,   45,   33,   46,   46,   79,   15,   46,   33,   46,
279    46,   45,   57,   45,   33,   25,   43,   45,   45,   42,
280    58,   25,  136,   45,   45,   24,   68,   25,   27,   33,
281    28,   58,   33,   58,   54,   81,   69,   30,   36,  134,
282    57,   29,   43,   30,   67,   42,   30,   43,   72,   78,
283    42,   31,   76,   43,   46,   32,   42,   33,   78,   33,
284    34,   33,   33,    5,    6,    7,   86,   87,   45,    8,
285   124,  125,   25,   57,   38,   25,   39,    5,    5,    5,
286    73,   40,   78,    5,   13,   13,   13,   46,   41,   42,
287    13,   33,   43,    3,    3,    3,   44,   75,  126,    3,
288    46,   45,   17,   18,   19,   20,   21,   22,  122,  123,
289    58,  127,  132,   41,  137,   38,   49,  138,   37,   70,
290    88,  121,   92,    0,    0,    0,    0,    0,    0,   93,
291    43,    0,    0,   42,    0,    0,    0,   70,    0,    0,
292     0,    0,    0,    0,   94,   95,   96,   97,   98,   99,
293   100,  101,  102,  103,  104,  105,  106,  107,  108,  109,
294   110,  111,  112,  113,  114,  115,  116,  117,    0,    0,
295     0,    0,    0,    0,    0,    0,   68,    0,    0,    0,
296     0,    0,    0,    0,    0,   89,   51,    0,    0,    0,
297     0,    0,   52,    0,   33,   33,   50,   51,    0,   51,
298     0,   33,   33,   52,   53,   52,   57,    0,    0,    0,
299     0,    0,   57,    0,    0,    0,    0,    0,   82,    0,
300    46,  130,  128,    0,   33,   33,   46,   80,    0,    0,
301     0,   33,   33,    0,   45,    0,    0,   25,   25,    0,
302    45,    0,    0,    0,   25,   25,    0,   57,    0,   57,
303     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
304     0,   46,   93,    0,    0,    0,    0,    0,    0,    0,
305     0,    0,    0,    0,    0,   45,    0,   94,   95,   96,
306    97,   98,   99,  100,  101,  102,  103,  104,  105,  106,
307   107,  108,  109,  110,  111,  112,  113,  114,  115,  116,
308   117,   70,    0,    0,    0,    0,    0,    0,    0,    0,
309     0,    0,    0,    0,    0,    0,   70,   70,   70,   70,
310    70,   70,   70,   70,   70,   70,   70,   70,   70,   70,
311    70,   70,   70,   70,   70,   70,   70,   70,   70,   70,
312    68,    0,    0,    0,    0,    0,    0,    0,    0,    0,
313     0,    0,    0,    0,    0,   68,   68,   68,   68,   68,
314    68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
315    68,   68,   68,   68,   68,   68,   68,   68,   68,
316 };
317 static const YYINT yycheck[] = {                         10,
318    42,   43,   34,   34,   44,   93,   41,   44,    0,   40,
319    36,   60,   34,   10,   34,   46,   34,   63,   40,  258,
320    40,   63,   40,   34,   46,   36,   46,   10,   46,   40,
321    41,   42,   43,  256,   36,   46,   47,   34,  258,   36,
322   256,  256,   34,   40,   41,   47,  262,  262,   40,   46,
323    47,   34,   63,   36,   46,   34,   10,   40,   41,   10,
324    91,   40,  301,   46,   47,   60,   44,   46,  262,   91,
325    61,   91,   94,   91,   94,  121,  125,  256,  123,  299,
326    91,   61,   36,  262,   62,   36,   61,   41,   57,  124,
327    41,   61,   61,   47,   91,   61,   47,   61,  124,   91,
328    42,  123,   94,  259,  260,  261,  296,  297,   91,  265,
329    86,   87,   91,  124,  262,   94,  262,  259,  260,  261,
330    94,  262,  124,  265,  259,  260,  261,  124,  262,  262,
331   265,  123,  262,  259,  260,  261,   62,   10,   93,  265,
332   262,  124,  266,  267,  268,  269,  270,  271,  258,  258,
333    91,   45,  257,   10,  299,   10,   36,  301,   26,   54,
334    68,   78,   73,   -1,   -1,   -1,   -1,   -1,   -1,  257,
335   124,   -1,   -1,  124,   -1,   -1,   -1,   93,   -1,   -1,
336    -1,   -1,   -1,   -1,  272,  273,  274,  275,  276,  277,
337   278,  279,  280,  281,  282,  283,  284,  285,  286,  287,
338   288,  289,  290,  291,  292,  293,  294,  295,   -1,   -1,
339    -1,   -1,   -1,   -1,   -1,   -1,   93,   -1,   -1,   -1,
340    -1,   -1,   -1,   -1,   -1,  257,  257,   -1,   -1,   -1,
341    -1,   -1,  263,   -1,  256,  257,  256,  257,   -1,  257,
342    -1,  263,  264,  263,  264,  263,  257,   -1,   -1,   -1,
343    -1,   -1,  263,   -1,   -1,   -1,   -1,   -1,  300,   -1,
344   257,  301,  299,   -1,  256,  257,  263,  298,   -1,   -1,
345    -1,  263,  264,   -1,  257,   -1,   -1,  256,  257,   -1,
346   263,   -1,   -1,   -1,  263,  264,   -1,  298,   -1,  300,
347    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
348    -1,  298,  257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
349    -1,   -1,   -1,   -1,   -1,  298,   -1,  272,  273,  274,
350   275,  276,  277,  278,  279,  280,  281,  282,  283,  284,
351   285,  286,  287,  288,  289,  290,  291,  292,  293,  294,
352   295,  257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
353    -1,   -1,   -1,   -1,   -1,   -1,  272,  273,  274,  275,
354   276,  277,  278,  279,  280,  281,  282,  283,  284,  285,
355   286,  287,  288,  289,  290,  291,  292,  293,  294,  295,
356   257,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
357    -1,   -1,   -1,   -1,   -1,  272,  273,  274,  275,  276,
358   277,  278,  279,  280,  281,  282,  283,  284,  285,  286,
359   287,  288,  289,  290,  291,  292,  293,  294,  295,
360 };
361 #define YYFINAL 1
362 #ifndef YYDEBUG
363 #define YYDEBUG 0
364 #endif
365 #define YYMAXTOKEN 301
366 #define YYUNDFTOKEN 329
367 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
368 #if YYDEBUG
369 static const char *const yyname[] = {
370 
371 "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
372 0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,
373 0,0,0,0,0,0,0,0,0,0,"'<'","'='","'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
374 0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
375 0,0,0,0,0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
376 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
377 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
378 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR","NUMBER","SECTEND",
379 "SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","TOK_OPTION","TOK_OUTFILE",
380 "TOK_PREFIX","TOK_YYCLASS","TOK_HEADER_FILE","TOK_EXTRA_TYPE","TOK_TABLES_FILE",
381 "CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL","CCE_DIGIT","CCE_GRAPH",
382 "CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE","CCE_UPPER","CCE_XDIGIT",
383 "CCE_NEG_ALNUM","CCE_NEG_ALPHA","CCE_NEG_BLANK","CCE_NEG_CNTRL","CCE_NEG_DIGIT",
384 "CCE_NEG_GRAPH","CCE_NEG_LOWER","CCE_NEG_PRINT","CCE_NEG_PUNCT","CCE_NEG_SPACE",
385 "CCE_NEG_UPPER","CCE_NEG_XDIGIT","CCL_OP_DIFF","CCL_OP_UNION",
386 "BEGIN_REPEAT_POSIX","END_REPEAT_POSIX","BEGIN_REPEAT_FLEX","END_REPEAT_FLEX",0,
387 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"illegal-symbol",
388 };
389 static const char *const yyrule[] = {
390 "$accept : goal",
391 "goal : initlex sect1 sect1end sect2 initforrule",
392 "initlex :",
393 "sect1 : sect1 startconddecl namelist1",
394 "sect1 : sect1 options",
395 "sect1 :",
396 "sect1 : error",
397 "sect1end : SECTEND",
398 "startconddecl : SCDECL",
399 "startconddecl : XSCDECL",
400 "namelist1 : namelist1 NAME",
401 "namelist1 : NAME",
402 "namelist1 : error",
403 "options : TOK_OPTION optionlist",
404 "optionlist : optionlist option",
405 "optionlist :",
406 "option : TOK_OUTFILE '=' NAME",
407 "option : TOK_EXTRA_TYPE '=' NAME",
408 "option : TOK_PREFIX '=' NAME",
409 "option : TOK_YYCLASS '=' NAME",
410 "option : TOK_HEADER_FILE '=' NAME",
411 "option : TOK_TABLES_FILE '=' NAME",
412 "sect2 : sect2 scon initforrule flexrule '\\n'",
413 "sect2 : sect2 scon '{' sect2 '}'",
414 "sect2 :",
415 "initforrule :",
416 "flexrule : '^' rule",
417 "flexrule : rule",
418 "flexrule : EOF_OP",
419 "flexrule : error",
420 "scon_stk_ptr :",
421 "scon : '<' scon_stk_ptr namelist2 '>'",
422 "scon : '<' '*' '>'",
423 "scon :",
424 "namelist2 : namelist2 ',' sconname",
425 "namelist2 : sconname",
426 "namelist2 : error",
427 "sconname : NAME",
428 "rule : re2 re",
429 "rule : re2 re '$'",
430 "rule : re '$'",
431 "rule : re",
432 "re : re '|' series",
433 "re : series",
434 "re2 : re '/'",
435 "series : series singleton",
436 "series : singleton",
437 "series : series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX",
438 "series : series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX",
439 "series : series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX",
440 "singleton : singleton '*'",
441 "singleton : singleton '+'",
442 "singleton : singleton '?'",
443 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX",
444 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX",
445 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX",
446 "singleton : '.'",
447 "singleton : fullccl",
448 "singleton : PREVCCL",
449 "singleton : '\"' string '\"'",
450 "singleton : '(' re ')'",
451 "singleton : CHAR",
452 "fullccl : fullccl CCL_OP_DIFF braceccl",
453 "fullccl : fullccl CCL_OP_UNION braceccl",
454 "fullccl : braceccl",
455 "braceccl : '[' ccl ']'",
456 "braceccl : '[' '^' ccl ']'",
457 "ccl : ccl CHAR '-' CHAR",
458 "ccl : ccl CHAR",
459 "ccl : ccl ccl_expr",
460 "ccl :",
461 "ccl_expr : CCE_ALNUM",
462 "ccl_expr : CCE_ALPHA",
463 "ccl_expr : CCE_BLANK",
464 "ccl_expr : CCE_CNTRL",
465 "ccl_expr : CCE_DIGIT",
466 "ccl_expr : CCE_GRAPH",
467 "ccl_expr : CCE_LOWER",
468 "ccl_expr : CCE_PRINT",
469 "ccl_expr : CCE_PUNCT",
470 "ccl_expr : CCE_SPACE",
471 "ccl_expr : CCE_XDIGIT",
472 "ccl_expr : CCE_UPPER",
473 "ccl_expr : CCE_NEG_ALNUM",
474 "ccl_expr : CCE_NEG_ALPHA",
475 "ccl_expr : CCE_NEG_BLANK",
476 "ccl_expr : CCE_NEG_CNTRL",
477 "ccl_expr : CCE_NEG_DIGIT",
478 "ccl_expr : CCE_NEG_GRAPH",
479 "ccl_expr : CCE_NEG_PRINT",
480 "ccl_expr : CCE_NEG_PUNCT",
481 "ccl_expr : CCE_NEG_SPACE",
482 "ccl_expr : CCE_NEG_XDIGIT",
483 "ccl_expr : CCE_NEG_LOWER",
484 "ccl_expr : CCE_NEG_UPPER",
485 "string : string CHAR",
486 "string :",
487 
488 };
489 #endif
490 
491 #if YYDEBUG
492 int      yydebug;
493 #endif
494 
495 int      yyerrflag;
496 int      yychar;
497 YYSTYPE  yyval;
498 YYSTYPE  yylval;
499 int      yynerrs;
500 
501 /* define the initial stack-sizes */
502 #ifdef YYSTACKSIZE
503 #undef YYMAXDEPTH
504 #define YYMAXDEPTH  YYSTACKSIZE
505 #else
506 #ifdef YYMAXDEPTH
507 #define YYSTACKSIZE YYMAXDEPTH
508 #else
509 #define YYSTACKSIZE 10000
510 #define YYMAXDEPTH  10000
511 #endif
512 #endif
513 
514 #define YYINITSTACKSIZE 200
515 
516 typedef struct {
517     unsigned stacksize;
518     YYINT    *s_base;
519     YYINT    *s_mark;
520     YYINT    *s_last;
521     YYSTYPE  *l_base;
522     YYSTYPE  *l_mark;
523 } YYSTACKDATA;
524 /* variables for the parser stack */
525 static YYSTACKDATA yystack;
526 #line 950 "parse.y"
527 
528 
529 /* build_eof_action - build the "<<EOF>>" action for the active start
530  *                    conditions
531  */
532 
533 void build_eof_action(void)
534 	{
535 	int i;
536 	char action_text[MAXLINE];
537 
538 	for ( i = 1; i <= scon_stk_ptr; ++i )
539 		{
540 		if ( sceof[scon_stk[i]] )
541 			format_pinpoint_message(
542 				"multiple <<EOF>> rules for start condition %s",
543 				scname[scon_stk[i]] );
544 
545 		else
546 			{
547 			sceof[scon_stk[i]] = true;
548 
549 			if (previous_continued_action /* && previous action was regular */)
550 				add_action("YY_RULE_SETUP\n");
551 
552 			snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n",
553 				scname[scon_stk[i]] );
554 			add_action( action_text );
555 			}
556 		}
557 
558 	line_directive_out(NULL, 1);
559         add_action("[[");
560 
561 	/* This isn't a normal rule after all - don't count it as
562 	 * such, so we don't have any holes in the rule numbering
563 	 * (which make generating "rule can never match" warnings
564 	 * more difficult.
565 	 */
566 	--num_rules;
567 	++num_eof_rules;
568 	}
569 
570 
571 /* format_synerr - write out formatted syntax error */
572 
573 void format_synerr( const char *msg, const char arg[] )
574 	{
575 	char errmsg[MAXLINE];
576 
577 	(void) snprintf( errmsg, sizeof(errmsg), msg, arg );
578 	synerr( errmsg );
579 	}
580 
581 
582 /* synerr - report a syntax error */
583 
584 void synerr( const char *str )
585 	{
586 	syntaxerror = true;
587 	pinpoint_message( str );
588 	}
589 
590 
591 /* format_warn - write out formatted warning */
592 
593 void format_warn( const char *msg, const char arg[] )
594 	{
595 	char warn_msg[MAXLINE];
596 
597 	snprintf( warn_msg, sizeof(warn_msg), msg, arg );
598 	lwarn( warn_msg );
599 	}
600 
601 
602 /* lwarn - report a warning, unless -w was given */
603 
604 void lwarn( const char *str )
605 	{
606 	line_warning( str, linenum );
607 	}
608 
609 /* format_pinpoint_message - write out a message formatted with one string,
610  *			     pinpointing its location
611  */
612 
613 void format_pinpoint_message( const char *msg, const char arg[] )
614 	{
615 	char errmsg[MAXLINE];
616 
617 	snprintf( errmsg, sizeof(errmsg), msg, arg );
618 	pinpoint_message( errmsg );
619 	}
620 
621 
622 /* pinpoint_message - write out a message, pinpointing its location */
623 
624 void pinpoint_message( const char *str )
625 	{
626 	line_pinpoint( str, linenum );
627 	}
628 
629 
630 /* line_warning - report a warning at a given line, unless -w was given */
631 
632 void line_warning( const char *str, int line )
633 	{
634 	char warning[MAXLINE];
635 
636 	if ( ! nowarn )
637 		{
638 		snprintf( warning, sizeof(warning), "warning, %s", str );
639 		line_pinpoint( warning, line );
640 		}
641 	}
642 
643 
644 /* line_pinpoint - write out a message, pinpointing it at the given line */
645 
646 void line_pinpoint( const char *str, int line )
647 	{
648 	fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
649 	}
650 
651 
652 /* yyerror - eat up an error message from the parser;
653  *	     currently, messages are ignore
654  */
655 
656 void yyerror( const char *msg )
657 	{
658 		(void)msg;
659 	}
660 #line 662 "parse.c"
661 
662 #if YYDEBUG
663 #include <stdio.h>	/* needed for printf */
664 #endif
665 
666 #include <stdlib.h>	/* needed for malloc, etc */
667 #include <string.h>	/* needed for memset */
668 
669 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
670 static int yygrowstack(YYSTACKDATA *data)
671 {
672     int i;
673     unsigned newsize;
674     YYINT *newss;
675     YYSTYPE *newvs;
676 
677     if ((newsize = data->stacksize) == 0)
678         newsize = YYINITSTACKSIZE;
679     else if (newsize >= YYMAXDEPTH)
680         return YYENOMEM;
681     else if ((newsize *= 2) > YYMAXDEPTH)
682         newsize = YYMAXDEPTH;
683 
684     i = (int) (data->s_mark - data->s_base);
685     newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
686     if (newss == NULL)
687         return YYENOMEM;
688 
689     data->s_base = newss;
690     data->s_mark = newss + i;
691 
692     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
693     if (newvs == NULL)
694         return YYENOMEM;
695 
696     data->l_base = newvs;
697     data->l_mark = newvs + i;
698 
699     data->stacksize = newsize;
700     data->s_last = data->s_base + newsize - 1;
701     return 0;
702 }
703 
704 #if YYPURE || defined(YY_NO_LEAKS)
705 static void yyfreestack(YYSTACKDATA *data)
706 {
707     free(data->s_base);
708     free(data->l_base);
709     memset(data, 0, sizeof(*data));
710 }
711 #else
712 #define yyfreestack(data) /* nothing */
713 #endif
714 
715 #define YYABORT  goto yyabort
716 #define YYREJECT goto yyabort
717 #define YYACCEPT goto yyaccept
718 #define YYERROR  goto yyerrlab
719 
720 int
721 YYPARSE_DECL()
722 {
723     int yym, yyn, yystate;
724 #if YYDEBUG
725     const char *yys;
726 
727     if ((yys = getenv("YYDEBUG")) != NULL)
728     {
729         yyn = *yys;
730         if (yyn >= '0' && yyn <= '9')
731             yydebug = yyn - '0';
732     }
733 #endif
734 
735     yym = 0;
736     yyn = 0;
737     yynerrs = 0;
738     yyerrflag = 0;
739     yychar = YYEMPTY;
740     yystate = 0;
741 
742 #if YYPURE
743     memset(&yystack, 0, sizeof(yystack));
744 #endif
745 
746     if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
747     yystack.s_mark = yystack.s_base;
748     yystack.l_mark = yystack.l_base;
749     yystate = 0;
750     *yystack.s_mark = 0;
751 
752 yyloop:
753     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
754     if (yychar < 0)
755     {
756         yychar = YYLEX;
757         if (yychar < 0) yychar = YYEOF;
758 #if YYDEBUG
759         if (yydebug)
760         {
761             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
762             printf("%sdebug: state %d, reading %d (%s)\n",
763                     YYPREFIX, yystate, yychar, yys);
764         }
765 #endif
766     }
767     if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
768             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
769     {
770 #if YYDEBUG
771         if (yydebug)
772             printf("%sdebug: state %d, shifting to state %d\n",
773                     YYPREFIX, yystate, yytable[yyn]);
774 #endif
775         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
776         yystate = yytable[yyn];
777         *++yystack.s_mark = yytable[yyn];
778         *++yystack.l_mark = yylval;
779         yychar = YYEMPTY;
780         if (yyerrflag > 0)  --yyerrflag;
781         goto yyloop;
782     }
783     if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
784             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
785     {
786         yyn = yytable[yyn];
787         goto yyreduce;
788     }
789     if (yyerrflag != 0) goto yyinrecovery;
790 
791     YYERROR_CALL("syntax error");
792 
793     goto yyerrlab; /* redundant goto avoids 'unused label' warning */
794 yyerrlab:
795     ++yynerrs;
796 
797 yyinrecovery:
798     if (yyerrflag < 3)
799     {
800         yyerrflag = 3;
801         for (;;)
802         {
803             if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
804                     yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
805             {
806 #if YYDEBUG
807                 if (yydebug)
808                     printf("%sdebug: state %d, error recovery shifting\
809  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
810 #endif
811                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
812                 yystate = yytable[yyn];
813                 *++yystack.s_mark = yytable[yyn];
814                 *++yystack.l_mark = yylval;
815                 goto yyloop;
816             }
817             else
818             {
819 #if YYDEBUG
820                 if (yydebug)
821                     printf("%sdebug: error recovery discarding state %d\n",
822                             YYPREFIX, *yystack.s_mark);
823 #endif
824                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
825                 --yystack.s_mark;
826                 --yystack.l_mark;
827             }
828         }
829     }
830     else
831     {
832         if (yychar == YYEOF) goto yyabort;
833 #if YYDEBUG
834         if (yydebug)
835         {
836             if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
837             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
838                     YYPREFIX, yystate, yychar, yys);
839         }
840 #endif
841         yychar = YYEMPTY;
842         goto yyloop;
843     }
844 
845 yyreduce:
846 #if YYDEBUG
847     if (yydebug)
848         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
849                 YYPREFIX, yystate, yyn, yyrule[yyn]);
850 #endif
851     yym = yylen[yyn];
852     if (yym > 0)
853         yyval = yystack.l_mark[1-yym];
854     else
855         memset(&yyval, 0, sizeof yyval);
856 
857     switch (yyn)
858     {
859 case 1:
860 #line 119 "parse.y"
861 	{ /* add default rule */
862 			int def_rule;
863 
864 			pat = cclinit();
865 			cclnegate( pat );
866 
867 			def_rule = mkstate( -pat );
868 
869 			/* Remember the number of the default rule so we
870 			 * don't generate "can't match" warnings for it.
871 			 */
872 			default_rule = num_rules;
873 
874 			finish_rule( def_rule, false, 0, 0, 0);
875 
876 			for ( i = 1; i <= lastsc; ++i )
877 				scset[i] = mkbranch( scset[i], def_rule );
878 
879 			if ( spprdflt )
880 				add_action(
881 				"YY_FATAL_ERROR( \"flex scanner jammed\" )" );
882 			else
883 				add_action( "ECHO" );
884 
885 			add_action( ";\n\tYY_BREAK]]\n" );
886 			}
887 break;
888 case 2:
889 #line 148 "parse.y"
890 	{ /* initialize for processing rules */
891 
892 			/* Create default DFA start condition. */
893 			scinstal( "INITIAL", false );
894 			}
895 break;
896 case 6:
897 #line 159 "parse.y"
898 	{ synerr( _("unknown error processing section 1") ); }
899 break;
900 case 7:
901 #line 163 "parse.y"
902 	{
903 			check_options();
904 			scon_stk = allocate_integer_array( lastsc + 1 );
905 			scon_stk_ptr = 0;
906 			}
907 break;
908 case 8:
909 #line 171 "parse.y"
910 	{ xcluflg = false; }
911 break;
912 case 9:
913 #line 174 "parse.y"
914 	{ xcluflg = true; }
915 break;
916 case 10:
917 #line 178 "parse.y"
918 	{ scinstal( nmstr, xcluflg ); }
919 break;
920 case 11:
921 #line 181 "parse.y"
922 	{ scinstal( nmstr, xcluflg ); }
923 break;
924 case 12:
925 #line 184 "parse.y"
926 	{ synerr( _("bad start condition list") ); }
927 break;
928 case 16:
929 #line 195 "parse.y"
930 	{
931 			outfilename = xstrdup(nmstr);
932 			did_outfilename = 1;
933 			}
934 break;
935 case 17:
936 #line 200 "parse.y"
937 	{ extra_type = xstrdup(nmstr); }
938 break;
939 case 18:
940 #line 202 "parse.y"
941 	{ prefix = xstrdup(nmstr);
942                           if (strchr(prefix, '[') || strchr(prefix, ']'))
943                               flexerror(_("Prefix must not contain [ or ]")); }
944 break;
945 case 19:
946 #line 206 "parse.y"
947 	{ yyclass = xstrdup(nmstr); }
948 break;
949 case 20:
950 #line 208 "parse.y"
951 	{ headerfilename = xstrdup(nmstr); }
952 break;
953 case 21:
954 #line 210 "parse.y"
955 	{ tablesext = true; tablesfilename = xstrdup(nmstr); }
956 break;
957 case 22:
958 #line 214 "parse.y"
959 	{ scon_stk_ptr = yystack.l_mark[-3]; }
960 break;
961 case 23:
962 #line 216 "parse.y"
963 	{ scon_stk_ptr = yystack.l_mark[-3]; }
964 break;
965 case 25:
966 #line 221 "parse.y"
967 	{
968 			/* Initialize for a parse of one rule. */
969 			trlcontxt = variable_trail_rule = varlength = false;
970 			trailcnt = headcnt = rulelen = 0;
971 			current_state_type = STATE_NORMAL;
972 			previous_continued_action = continued_action;
973 			in_rule = true;
974 
975 			new_rule();
976 			}
977 break;
978 case 26:
979 #line 234 "parse.y"
980 	{
981 			pat = yystack.l_mark[0];
982 			finish_rule( pat, variable_trail_rule,
983 				headcnt, trailcnt , previous_continued_action);
984 
985 			if ( scon_stk_ptr > 0 )
986 				{
987 				for ( i = 1; i <= scon_stk_ptr; ++i )
988 					scbol[scon_stk[i]] =
989 						mkbranch( scbol[scon_stk[i]],
990 								pat );
991 				}
992 
993 			else
994 				{
995 				/* Add to all non-exclusive start conditions,
996 				 * including the default (0) start condition.
997 				 */
998 
999 				for ( i = 1; i <= lastsc; ++i )
1000 					if ( ! scxclu[i] )
1001 						scbol[i] = mkbranch( scbol[i],
1002 									pat );
1003 				}
1004 
1005 			if ( ! bol_needed )
1006 				{
1007 				bol_needed = true;
1008 
1009 				if ( performance_report > 1 )
1010 					pinpoint_message(
1011 			"'^' operator results in sub-optimal performance" );
1012 				}
1013 			}
1014 break;
1015 case 27:
1016 #line 270 "parse.y"
1017 	{
1018 			pat = yystack.l_mark[0];
1019 			finish_rule( pat, variable_trail_rule,
1020 				headcnt, trailcnt , previous_continued_action);
1021 
1022 			if ( scon_stk_ptr > 0 )
1023 				{
1024 				for ( i = 1; i <= scon_stk_ptr; ++i )
1025 					scset[scon_stk[i]] =
1026 						mkbranch( scset[scon_stk[i]],
1027 								pat );
1028 				}
1029 
1030 			else
1031 				{
1032 				for ( i = 1; i <= lastsc; ++i )
1033 					if ( ! scxclu[i] )
1034 						scset[i] =
1035 							mkbranch( scset[i],
1036 								pat );
1037 				}
1038 			}
1039 break;
1040 case 28:
1041 #line 294 "parse.y"
1042 	{
1043 			if ( scon_stk_ptr > 0 )
1044 				build_eof_action();
1045 
1046 			else
1047 				{
1048 				/* This EOF applies to all start conditions
1049 				 * which don't already have EOF actions.
1050 				 */
1051 				for ( i = 1; i <= lastsc; ++i )
1052 					if ( ! sceof[i] )
1053 						scon_stk[++scon_stk_ptr] = i;
1054 
1055 				if ( scon_stk_ptr == 0 )
1056 					lwarn(
1057 			"all start conditions already have <<EOF>> rules" );
1058 
1059 				else
1060 					build_eof_action();
1061 				}
1062 			}
1063 break;
1064 case 29:
1065 #line 317 "parse.y"
1066 	{ synerr( _("unrecognized rule") ); }
1067 break;
1068 case 30:
1069 #line 321 "parse.y"
1070 	{ yyval = scon_stk_ptr; }
1071 break;
1072 case 31:
1073 #line 325 "parse.y"
1074 	{ yyval = yystack.l_mark[-2]; }
1075 break;
1076 case 32:
1077 #line 328 "parse.y"
1078 	{
1079 			yyval = scon_stk_ptr;
1080 
1081 			for ( i = 1; i <= lastsc; ++i )
1082 				{
1083 				int j;
1084 
1085 				for ( j = 1; j <= scon_stk_ptr; ++j )
1086 					if ( scon_stk[j] == i )
1087 						break;
1088 
1089 				if ( j > scon_stk_ptr )
1090 					scon_stk[++scon_stk_ptr] = i;
1091 				}
1092 			}
1093 break;
1094 case 33:
1095 #line 345 "parse.y"
1096 	{ yyval = scon_stk_ptr; }
1097 break;
1098 case 36:
1099 #line 353 "parse.y"
1100 	{ synerr( _("bad start condition list") ); }
1101 break;
1102 case 37:
1103 #line 357 "parse.y"
1104 	{
1105 			if ( (scnum = sclookup( nmstr )) == 0 )
1106 				format_pinpoint_message(
1107 					"undeclared start condition %s",
1108 					nmstr );
1109 			else
1110 				{
1111 				for ( i = 1; i <= scon_stk_ptr; ++i )
1112 					if ( scon_stk[i] == scnum )
1113 						{
1114 						format_warn(
1115 							"<%s> specified twice",
1116 							scname[scnum] );
1117 						break;
1118 						}
1119 
1120 				if ( i > scon_stk_ptr )
1121 					scon_stk[++scon_stk_ptr] = scnum;
1122 				}
1123 			}
1124 break;
1125 case 38:
1126 #line 380 "parse.y"
1127 	{
1128 			if ( transchar[lastst[yystack.l_mark[0]]] != SYM_EPSILON )
1129 				/* Provide final transition \now/ so it
1130 				 * will be marked as a trailing context
1131 				 * state.
1132 				 */
1133 				yystack.l_mark[0] = link_machines( yystack.l_mark[0],
1134 						mkstate( SYM_EPSILON ) );
1135 
1136 			mark_beginning_as_normal( yystack.l_mark[0] );
1137 			current_state_type = STATE_NORMAL;
1138 
1139 			if ( previous_continued_action )
1140 				{
1141 				/* We need to treat this as variable trailing
1142 				 * context so that the backup does not happen
1143 				 * in the action but before the action switch
1144 				 * statement.  If the backup happens in the
1145 				 * action, then the rules "falling into" this
1146 				 * one's action will *also* do the backup,
1147 				 * erroneously.
1148 				 */
1149 				if ( ! varlength || headcnt != 0 )
1150 					lwarn(
1151 		"trailing context made variable due to preceding '|' action" );
1152 
1153 				/* Mark as variable. */
1154 				varlength = true;
1155 				headcnt = 0;
1156 
1157 				}
1158 
1159 			if ( lex_compat || (varlength && headcnt == 0) )
1160 				{ /* variable trailing context rule */
1161 				/* Mark the first part of the rule as the
1162 				 * accepting "head" part of a trailing
1163 				 * context rule.
1164 				 *
1165 				 * By the way, we didn't do this at the
1166 				 * beginning of this production because back
1167 				 * then current_state_type was set up for a
1168 				 * trail rule, and add_accept() can create
1169 				 * a new state ...
1170 				 */
1171 				add_accept( yystack.l_mark[-1],
1172 					num_rules | YY_TRAILING_HEAD_MASK );
1173 				variable_trail_rule = true;
1174 				}
1175 
1176 			else
1177 				trailcnt = rulelen;
1178 
1179 			yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1180 			}
1181 break;
1182 case 39:
1183 #line 436 "parse.y"
1184 	{ synerr( _("trailing context used twice") ); }
1185 break;
1186 case 40:
1187 #line 439 "parse.y"
1188 	{
1189 			headcnt = 0;
1190 			trailcnt = 1;
1191 			rulelen = 1;
1192 			varlength = false;
1193 
1194 			current_state_type = STATE_TRAILING_CONTEXT;
1195 
1196 			if ( trlcontxt )
1197 				{
1198 				synerr( _("trailing context used twice") );
1199 				yyval = mkstate( SYM_EPSILON );
1200 				}
1201 
1202 			else if ( previous_continued_action )
1203 				{
1204 				/* See the comment in the rule for "re2 re"
1205 				 * above.
1206 				 */
1207 				lwarn(
1208 		"trailing context made variable due to preceding '|' action" );
1209 
1210 				varlength = true;
1211 				}
1212 
1213 			if ( lex_compat || varlength )
1214 				{
1215 				/* Again, see the comment in the rule for
1216 				 * "re2 re" above.
1217 				 */
1218 				add_accept( yystack.l_mark[-1],
1219 					num_rules | YY_TRAILING_HEAD_MASK );
1220 				variable_trail_rule = true;
1221 				}
1222 
1223 			trlcontxt = true;
1224 
1225 			eps = mkstate( SYM_EPSILON );
1226 			yyval = link_machines( yystack.l_mark[-1],
1227 				link_machines( eps, mkstate( '\n' ) ) );
1228 			}
1229 break;
1230 case 41:
1231 #line 482 "parse.y"
1232 	{
1233 			yyval = yystack.l_mark[0];
1234 
1235 			if ( trlcontxt )
1236 				{
1237 				if ( lex_compat || (varlength && headcnt == 0) )
1238 					/* Both head and trail are
1239 					 * variable-length.
1240 					 */
1241 					variable_trail_rule = true;
1242 				else
1243 					trailcnt = rulelen;
1244 				}
1245 			}
1246 break;
1247 case 42:
1248 #line 500 "parse.y"
1249 	{
1250 			varlength = true;
1251 			yyval = mkor( yystack.l_mark[-2], yystack.l_mark[0] );
1252 			}
1253 break;
1254 case 43:
1255 #line 506 "parse.y"
1256 	{ yyval = yystack.l_mark[0]; }
1257 break;
1258 case 44:
1259 #line 511 "parse.y"
1260 	{
1261 			/* This rule is written separately so the
1262 			 * reduction will occur before the trailing
1263 			 * series is parsed.
1264 			 */
1265 
1266 			if ( trlcontxt )
1267 				synerr( _("trailing context used twice") );
1268 			else
1269 				trlcontxt = true;
1270 
1271 			if ( varlength )
1272 				/* We hope the trailing context is
1273 				 * fixed-length.
1274 				 */
1275 				varlength = false;
1276 			else
1277 				headcnt = rulelen;
1278 
1279 			rulelen = 0;
1280 
1281 			current_state_type = STATE_TRAILING_CONTEXT;
1282 			yyval = yystack.l_mark[-1];
1283 			}
1284 break;
1285 case 45:
1286 #line 538 "parse.y"
1287 	{
1288 			/* This is where concatenation of adjacent patterns
1289 			 * gets done.
1290 			 */
1291 			yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1292 			}
1293 break;
1294 case 46:
1295 #line 546 "parse.y"
1296 	{ yyval = yystack.l_mark[0]; }
1297 break;
1298 case 47:
1299 #line 549 "parse.y"
1300 	{
1301 			varlength = true;
1302 
1303 			if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1304 				{
1305 				synerr( _("bad iteration values") );
1306 				yyval = yystack.l_mark[-5];
1307 				}
1308 			else
1309 				{
1310 				if ( yystack.l_mark[-3] == 0 )
1311 					{
1312 					if ( yystack.l_mark[-1] <= 0 )
1313 						{
1314 						synerr(
1315 						_("bad iteration values") );
1316 						yyval = yystack.l_mark[-5];
1317 						}
1318 					else
1319 						yyval = mkopt(
1320 							mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1321 					}
1322 				else
1323 					yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1324 				}
1325 			}
1326 break;
1327 case 48:
1328 #line 577 "parse.y"
1329 	{
1330 			varlength = true;
1331 
1332 			if ( yystack.l_mark[-2] <= 0 )
1333 				{
1334 				synerr( _("iteration value must be positive") );
1335 				yyval = yystack.l_mark[-4];
1336 				}
1337 
1338 			else
1339 				yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1340 			}
1341 break;
1342 case 49:
1343 #line 591 "parse.y"
1344 	{
1345 			/* The series could be something like "(foo)",
1346 			 * in which case we have no idea what its length
1347 			 * is, so we punt here.
1348 			 */
1349 			varlength = true;
1350 
1351 			if ( yystack.l_mark[-1] <= 0 )
1352 				{
1353 				  synerr( _("iteration value must be positive")
1354 					  );
1355 				yyval = yystack.l_mark[-3];
1356 				}
1357 
1358 			else
1359 				yyval = link_machines( yystack.l_mark[-3],
1360 						copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1361 			}
1362 break;
1363 case 50:
1364 #line 613 "parse.y"
1365 	{
1366 			varlength = true;
1367 
1368 			yyval = mkclos( yystack.l_mark[-1] );
1369 			}
1370 break;
1371 case 51:
1372 #line 620 "parse.y"
1373 	{
1374 			varlength = true;
1375 			yyval = mkposcl( yystack.l_mark[-1] );
1376 			}
1377 break;
1378 case 52:
1379 #line 626 "parse.y"
1380 	{
1381 			varlength = true;
1382 			yyval = mkopt( yystack.l_mark[-1] );
1383 			}
1384 break;
1385 case 53:
1386 #line 632 "parse.y"
1387 	{
1388 			varlength = true;
1389 
1390 			if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1391 				{
1392 				synerr( _("bad iteration values") );
1393 				yyval = yystack.l_mark[-5];
1394 				}
1395 			else
1396 				{
1397 				if ( yystack.l_mark[-3] == 0 )
1398 					{
1399 					if ( yystack.l_mark[-1] <= 0 )
1400 						{
1401 						synerr(
1402 						_("bad iteration values") );
1403 						yyval = yystack.l_mark[-5];
1404 						}
1405 					else
1406 						yyval = mkopt(
1407 							mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1408 					}
1409 				else
1410 					yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1411 				}
1412 			}
1413 break;
1414 case 54:
1415 #line 660 "parse.y"
1416 	{
1417 			varlength = true;
1418 
1419 			if ( yystack.l_mark[-2] <= 0 )
1420 				{
1421 				synerr( _("iteration value must be positive") );
1422 				yyval = yystack.l_mark[-4];
1423 				}
1424 
1425 			else
1426 				yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1427 			}
1428 break;
1429 case 55:
1430 #line 674 "parse.y"
1431 	{
1432 			/* The singleton could be something like "(foo)",
1433 			 * in which case we have no idea what its length
1434 			 * is, so we punt here.
1435 			 */
1436 			varlength = true;
1437 
1438 			if ( yystack.l_mark[-1] <= 0 )
1439 				{
1440 				synerr( _("iteration value must be positive") );
1441 				yyval = yystack.l_mark[-3];
1442 				}
1443 
1444 			else
1445 				yyval = link_machines( yystack.l_mark[-3],
1446 						copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1447 			}
1448 break;
1449 case 56:
1450 #line 693 "parse.y"
1451 	{
1452 			if ( ! madeany )
1453 				{
1454 				/* Create the '.' character class. */
1455                     ccldot = cclinit();
1456                     ccladd( ccldot, '\n' );
1457                     cclnegate( ccldot );
1458 
1459                     if ( useecs )
1460                         mkeccl( ccltbl + cclmap[ccldot],
1461                             ccllen[ccldot], nextecm,
1462                             ecgroup, csize, csize );
1463 
1464 				/* Create the (?s:'.') character class. */
1465                     cclany = cclinit();
1466                     cclnegate( cclany );
1467 
1468                     if ( useecs )
1469                         mkeccl( ccltbl + cclmap[cclany],
1470                             ccllen[cclany], nextecm,
1471                             ecgroup, csize, csize );
1472 
1473 				madeany = true;
1474 				}
1475 
1476 			++rulelen;
1477 
1478             if (sf_dot_all())
1479                 yyval = mkstate( -cclany );
1480             else
1481                 yyval = mkstate( -ccldot );
1482 			}
1483 break;
1484 case 57:
1485 #line 727 "parse.y"
1486 	{
1487 				/* Sort characters for fast searching.
1488 				 */
1489 				qsort( ccltbl + cclmap[yystack.l_mark[0]], (size_t) ccllen[yystack.l_mark[0]], sizeof (*ccltbl), cclcmp );
1490 
1491 			if ( useecs )
1492 				mkeccl( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]],
1493 					nextecm, ecgroup, csize, csize );
1494 
1495 			++rulelen;
1496 
1497 			if (ccl_has_nl[yystack.l_mark[0]])
1498 				rule_has_nl[num_rules] = true;
1499 
1500 			yyval = mkstate( -yystack.l_mark[0] );
1501 			}
1502 break;
1503 case 58:
1504 #line 745 "parse.y"
1505 	{
1506 			++rulelen;
1507 
1508 			if (ccl_has_nl[yystack.l_mark[0]])
1509 				rule_has_nl[num_rules] = true;
1510 
1511 			yyval = mkstate( -yystack.l_mark[0] );
1512 			}
1513 break;
1514 case 59:
1515 #line 755 "parse.y"
1516 	{ yyval = yystack.l_mark[-1]; }
1517 break;
1518 case 60:
1519 #line 758 "parse.y"
1520 	{ yyval = yystack.l_mark[-1]; }
1521 break;
1522 case 61:
1523 #line 761 "parse.y"
1524 	{
1525 			++rulelen;
1526 
1527 			if (yystack.l_mark[0] == nlch)
1528 				rule_has_nl[num_rules] = true;
1529 
1530             if (sf_case_ins() && has_case(yystack.l_mark[0]))
1531                 /* create an alternation, as in (a|A) */
1532                 yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1533             else
1534                 yyval = mkstate( yystack.l_mark[0] );
1535 			}
1536 break;
1537 case 62:
1538 #line 775 "parse.y"
1539 	{ yyval = ccl_set_diff  (yystack.l_mark[-2], yystack.l_mark[0]); }
1540 break;
1541 case 63:
1542 #line 776 "parse.y"
1543 	{ yyval = ccl_set_union (yystack.l_mark[-2], yystack.l_mark[0]); }
1544 break;
1545 case 65:
1546 #line 782 "parse.y"
1547 	{ yyval = yystack.l_mark[-1]; }
1548 break;
1549 case 66:
1550 #line 785 "parse.y"
1551 	{
1552 			cclnegate( yystack.l_mark[-1] );
1553 			yyval = yystack.l_mark[-1];
1554 			}
1555 break;
1556 case 67:
1557 #line 792 "parse.y"
1558 	{
1559 
1560 			if (sf_case_ins())
1561 			  {
1562 
1563 			    /* If one end of the range has case and the other
1564 			     * does not, or the cases are different, then we're not
1565 			     * sure what range the user is trying to express.
1566 			     * Examples: [@-z] or [S-t]
1567 			     */
1568 			    if (has_case (yystack.l_mark[-2]) != has_case (yystack.l_mark[0])
1569 				     || (has_case (yystack.l_mark[-2]) && (b_islower (yystack.l_mark[-2]) != b_islower (yystack.l_mark[0])))
1570 				     || (has_case (yystack.l_mark[-2]) && (b_isupper (yystack.l_mark[-2]) != b_isupper (yystack.l_mark[0]))))
1571 			      format_warn3 (
1572 			      _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
1573 					    yystack.l_mark[-2], yystack.l_mark[0]);
1574 
1575 			    /* If the range spans uppercase characters but not
1576 			     * lowercase (or vice-versa), then should we automatically
1577 			     * include lowercase characters in the range?
1578 			     * Example: [@-_] spans [a-z] but not [A-Z]
1579 			     */
1580 			    else if (!has_case (yystack.l_mark[-2]) && !has_case (yystack.l_mark[0]) && !range_covers_case (yystack.l_mark[-2], yystack.l_mark[0]))
1581 			      format_warn3 (
1582 			      _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
1583 					    yystack.l_mark[-2], yystack.l_mark[0]);
1584 			  }
1585 
1586 			if ( yystack.l_mark[-2] > yystack.l_mark[0] )
1587 				synerr( _("negative range in character class") );
1588 
1589 			else
1590 				{
1591 				for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
1592 					ccladd( yystack.l_mark[-3], i );
1593 
1594 				/* Keep track if this ccl is staying in
1595 				 * alphabetical order.
1596 				 */
1597 				cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
1598 				lastchar = yystack.l_mark[0];
1599 
1600                 /* Do it again for upper/lowercase */
1601                 if (sf_case_ins() && has_case(yystack.l_mark[-2]) && has_case(yystack.l_mark[0])){
1602                     yystack.l_mark[-2] = reverse_case (yystack.l_mark[-2]);
1603                     yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
1604 
1605                     for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
1606                         ccladd( yystack.l_mark[-3], i );
1607 
1608                     cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
1609                     lastchar = yystack.l_mark[0];
1610                 }
1611 
1612 				}
1613 
1614 			yyval = yystack.l_mark[-3];
1615 			}
1616 break;
1617 case 68:
1618 #line 852 "parse.y"
1619 	{
1620 			ccladd( yystack.l_mark[-1], yystack.l_mark[0] );
1621 			cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
1622 			lastchar = yystack.l_mark[0];
1623 
1624             /* Do it again for upper/lowercase */
1625             if (sf_case_ins() && has_case(yystack.l_mark[0])){
1626                 yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
1627                 ccladd (yystack.l_mark[-1], yystack.l_mark[0]);
1628 
1629                 cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
1630                 lastchar = yystack.l_mark[0];
1631             }
1632 
1633 			yyval = yystack.l_mark[-1];
1634 			}
1635 break;
1636 case 69:
1637 #line 870 "parse.y"
1638 	{
1639 			/* Too hard to properly maintain cclsorted. */
1640 			cclsorted = false;
1641 			yyval = yystack.l_mark[-1];
1642 			}
1643 break;
1644 case 70:
1645 #line 877 "parse.y"
1646 	{
1647 			cclsorted = true;
1648 			lastchar = 0;
1649 			currccl = yyval = cclinit();
1650 			}
1651 break;
1652 case 71:
1653 #line 885 "parse.y"
1654 	{ CCL_EXPR(isalnum); }
1655 break;
1656 case 72:
1657 #line 886 "parse.y"
1658 	{ CCL_EXPR(isalpha); }
1659 break;
1660 case 73:
1661 #line 887 "parse.y"
1662 	{ CCL_EXPR(IS_BLANK); }
1663 break;
1664 case 74:
1665 #line 888 "parse.y"
1666 	{ CCL_EXPR(iscntrl); }
1667 break;
1668 case 75:
1669 #line 889 "parse.y"
1670 	{ CCL_EXPR(isdigit); }
1671 break;
1672 case 76:
1673 #line 890 "parse.y"
1674 	{ CCL_EXPR(isgraph); }
1675 break;
1676 case 77:
1677 #line 891 "parse.y"
1678 	{
1679                           CCL_EXPR(islower);
1680                           if (sf_case_ins())
1681                               CCL_EXPR(isupper);
1682                         }
1683 break;
1684 case 78:
1685 #line 896 "parse.y"
1686 	{ CCL_EXPR(isprint); }
1687 break;
1688 case 79:
1689 #line 897 "parse.y"
1690 	{ CCL_EXPR(ispunct); }
1691 break;
1692 case 80:
1693 #line 898 "parse.y"
1694 	{ CCL_EXPR(isspace); }
1695 break;
1696 case 81:
1697 #line 899 "parse.y"
1698 	{ CCL_EXPR(isxdigit); }
1699 break;
1700 case 82:
1701 #line 900 "parse.y"
1702 	{
1703                     CCL_EXPR(isupper);
1704                     if (sf_case_ins())
1705                         CCL_EXPR(islower);
1706 				}
1707 break;
1708 case 83:
1709 #line 906 "parse.y"
1710 	{ CCL_NEG_EXPR(isalnum); }
1711 break;
1712 case 84:
1713 #line 907 "parse.y"
1714 	{ CCL_NEG_EXPR(isalpha); }
1715 break;
1716 case 85:
1717 #line 908 "parse.y"
1718 	{ CCL_NEG_EXPR(IS_BLANK); }
1719 break;
1720 case 86:
1721 #line 909 "parse.y"
1722 	{ CCL_NEG_EXPR(iscntrl); }
1723 break;
1724 case 87:
1725 #line 910 "parse.y"
1726 	{ CCL_NEG_EXPR(isdigit); }
1727 break;
1728 case 88:
1729 #line 911 "parse.y"
1730 	{ CCL_NEG_EXPR(isgraph); }
1731 break;
1732 case 89:
1733 #line 912 "parse.y"
1734 	{ CCL_NEG_EXPR(isprint); }
1735 break;
1736 case 90:
1737 #line 913 "parse.y"
1738 	{ CCL_NEG_EXPR(ispunct); }
1739 break;
1740 case 91:
1741 #line 914 "parse.y"
1742 	{ CCL_NEG_EXPR(isspace); }
1743 break;
1744 case 92:
1745 #line 915 "parse.y"
1746 	{ CCL_NEG_EXPR(isxdigit); }
1747 break;
1748 case 93:
1749 #line 916 "parse.y"
1750 	{
1751 				if ( sf_case_ins() )
1752 					lwarn(_("[:^lower:] is ambiguous in case insensitive scanner"));
1753 				else
1754 					CCL_NEG_EXPR(islower);
1755 				}
1756 break;
1757 case 94:
1758 #line 922 "parse.y"
1759 	{
1760 				if ( sf_case_ins() )
1761 					lwarn(_("[:^upper:] ambiguous in case insensitive scanner"));
1762 				else
1763 					CCL_NEG_EXPR(isupper);
1764 				}
1765 break;
1766 case 95:
1767 #line 931 "parse.y"
1768 	{
1769 			if ( yystack.l_mark[0] == nlch )
1770 				rule_has_nl[num_rules] = true;
1771 
1772 			++rulelen;
1773 
1774             if (sf_case_ins() && has_case(yystack.l_mark[0]))
1775                 yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1776             else
1777                 yyval = mkstate (yystack.l_mark[0]);
1778 
1779 			yyval = link_machines( yystack.l_mark[-1], yyval);
1780 			}
1781 break;
1782 case 96:
1783 #line 946 "parse.y"
1784 	{ yyval = mkstate( SYM_EPSILON ); }
1785 break;
1786 #line 1788 "parse.c"
1787     }
1788     yystack.s_mark -= yym;
1789     yystate = *yystack.s_mark;
1790     yystack.l_mark -= yym;
1791     yym = yylhs[yyn];
1792     if (yystate == 0 && yym == 0)
1793     {
1794 #if YYDEBUG
1795         if (yydebug)
1796             printf("%sdebug: after reduction, shifting from state 0 to\
1797  state %d\n", YYPREFIX, YYFINAL);
1798 #endif
1799         yystate = YYFINAL;
1800         *++yystack.s_mark = YYFINAL;
1801         *++yystack.l_mark = yyval;
1802         if (yychar < 0)
1803         {
1804             yychar = YYLEX;
1805             if (yychar < 0) yychar = YYEOF;
1806 #if YYDEBUG
1807             if (yydebug)
1808             {
1809                 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1810                 printf("%sdebug: state %d, reading %d (%s)\n",
1811                         YYPREFIX, YYFINAL, yychar, yys);
1812             }
1813 #endif
1814         }
1815         if (yychar == YYEOF) goto yyaccept;
1816         goto yyloop;
1817     }
1818     if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1819             yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1820         yystate = yytable[yyn];
1821     else
1822         yystate = yydgoto[yym];
1823 #if YYDEBUG
1824     if (yydebug)
1825         printf("%sdebug: after reduction, shifting from state %d \
1826 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1827 #endif
1828     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1829     *++yystack.s_mark = (YYINT) yystate;
1830     *++yystack.l_mark = yyval;
1831     goto yyloop;
1832 
1833 yyoverflow:
1834     YYERROR_CALL("yacc stack overflow");
1835 
1836 yyabort:
1837     yyfreestack(&yystack);
1838     return (1);
1839 
1840 yyaccept:
1841     yyfreestack(&yystack);
1842     return (0);
1843 }
1844