tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / flex / dist / initparse.c
blob47a0e878f562827656874ef439e43395788586fb
1 #ifndef lint
2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
3 #endif
5 #ifdef _LIBC
6 #include "namespace.h"
7 #endif
8 #include <stdlib.h>
9 #include <string.h>
11 #define YYBYACC 1
12 #define YYMAJOR 1
13 #define YYMINOR 9
15 #define YYEMPTY (-1)
16 #define yyclearin (yychar = YYEMPTY)
17 #define yyerrok (yyerrflag = 0)
18 #define YYRECOVERING() (yyerrflag != 0)
20 #define YYPREFIX "yy"
22 #define YYPURE 0
24 /* Copyright (c) 1990 The Regents of the University of California. */
25 /* All rights reserved. */
27 /* This code is derived from software contributed to Berkeley by */
28 /* Vern Paxson. */
30 /* The United States Government has rights in this work pursuant */
31 /* to contract no. DE-AC03-76SF00098 between the United States */
32 /* Department of Energy and the University of California. */
34 /* This file is part of flex. */
36 /* Redistribution and use in source and binary forms, with or without */
37 /* modification, are permitted provided that the following conditions */
38 /* are met: */
40 /* 1. Redistributions of source code must retain the above copyright */
41 /* notice, this list of conditions and the following disclaimer. */
42 /* 2. Redistributions in binary form must reproduce the above copyright */
43 /* notice, this list of conditions and the following disclaimer in the */
44 /* documentation and/or other materials provided with the distribution. */
46 /* Neither the name of the University nor the names of its contributors */
47 /* may be used to endorse or promote products derived from this software */
48 /* without specific prior written permission. */
50 /* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
51 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
52 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
53 /* PURPOSE. */
55 #include "flexdef.h"
56 #include "tables.h"
58 int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen;
59 int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
61 int *scon_stk;
62 int scon_stk_ptr;
64 static int madeany = false; /* whether we've made the '.' character class */
65 static int ccldot, cclany;
66 int previous_continued_action; /* whether the previous rule's action was '|' */
68 #define format_warn3(fmt, a1, a2) \
69 do{ \
70 char fw3_msg[MAXLINE];\
71 snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
72 lwarn( fw3_msg );\
73 }while(0)
75 /* Expand a POSIX character class expression. */
76 #define CCL_EXPR(func) \
77 do{ \
78 int c; \
79 for ( c = 0; c < csize; ++c ) \
80 if ( isascii(c) && func(c) ) \
81 ccladd( currccl, c ); \
82 }while(0)
84 /* negated class */
85 #define CCL_NEG_EXPR(func) \
86 do{ \
87 int c; \
88 for ( c = 0; c < csize; ++c ) \
89 if ( !func(c) ) \
90 ccladd( currccl, c ); \
91 }while(0)
93 /* While POSIX defines isblank(), it's not ANSI C. */
94 #define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
96 /* On some over-ambitious machines, such as DEC Alpha's, the default
97 * token type is "long" instead of "int"; this leads to problems with
98 * declaring yylval in flexdef.h. But so far, all the yacc's I've seen
99 * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
100 * following should ensure that the default token type is "int".
102 #define YYSTYPE int
105 #ifndef YYSTYPE
106 typedef int YYSTYPE;
107 #endif
109 /* compatibility with bison */
110 #ifdef YYPARSE_PARAM
111 /* compatibility with FreeBSD */
112 # ifdef YYPARSE_PARAM_TYPE
113 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
114 # else
115 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
116 # endif
117 #else
118 # define YYPARSE_DECL() yyparse(void)
119 #endif
121 /* Parameters sent to lex. */
122 #ifdef YYLEX_PARAM
123 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
124 # define YYLEX yylex(YYLEX_PARAM)
125 #else
126 # define YYLEX_DECL() yylex(void)
127 # define YYLEX yylex()
128 #endif
130 /* Parameters sent to yyerror. */
131 #ifndef YYERROR_DECL
132 #define YYERROR_DECL() yyerror(const char *s)
133 #endif
134 #ifndef YYERROR_CALL
135 #define YYERROR_CALL(msg) yyerror(msg)
136 #endif
138 extern int YYPARSE_DECL();
141 #define CHAR 257
142 #define NUMBER 258
143 #define SECTEND 259
144 #define SCDECL 260
145 #define XSCDECL 261
146 #define NAME 262
147 #define PREVCCL 263
148 #define EOF_OP 264
149 #define OPTION_OP 265
150 #define OPT_OUTFILE 266
151 #define OPT_PREFIX 267
152 #define OPT_YYCLASS 268
153 #define OPT_HEADER 269
154 #define OPT_EXTRA_TYPE 270
155 #define OPT_TABLES 271
156 #define CCE_ALNUM 272
157 #define CCE_ALPHA 273
158 #define CCE_BLANK 274
159 #define CCE_CNTRL 275
160 #define CCE_DIGIT 276
161 #define CCE_GRAPH 277
162 #define CCE_LOWER 278
163 #define CCE_PRINT 279
164 #define CCE_PUNCT 280
165 #define CCE_SPACE 281
166 #define CCE_UPPER 282
167 #define CCE_XDIGIT 283
168 #define CCE_NEG_ALNUM 284
169 #define CCE_NEG_ALPHA 285
170 #define CCE_NEG_BLANK 286
171 #define CCE_NEG_CNTRL 287
172 #define CCE_NEG_DIGIT 288
173 #define CCE_NEG_GRAPH 289
174 #define CCE_NEG_LOWER 290
175 #define CCE_NEG_PRINT 291
176 #define CCE_NEG_PUNCT 292
177 #define CCE_NEG_SPACE 293
178 #define CCE_NEG_UPPER 294
179 #define CCE_NEG_XDIGIT 295
180 #define CCL_OP_DIFF 296
181 #define CCL_OP_UNION 297
182 #define BEGIN_REPEAT_POSIX 298
183 #define END_REPEAT_POSIX 299
184 #define BEGIN_REPEAT_FLEX 300
185 #define END_REPEAT_FLEX 301
186 #define YYERRCODE 256
187 static const short yylhs[] = { -1,
188 0, 1, 2, 2, 2, 2, 3, 6, 6, 7,
189 7, 7, 8, 9, 9, 10, 10, 10, 10, 10,
190 10, 4, 4, 4, 5, 12, 12, 12, 12, 14,
191 11, 11, 11, 15, 15, 15, 16, 13, 13, 13,
192 13, 18, 18, 17, 19, 19, 19, 19, 19, 20,
193 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
194 20, 21, 21, 21, 23, 23, 24, 24, 24, 24,
195 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
196 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
197 25, 25, 25, 25, 22, 22,
199 static const short yylen[] = { 2,
200 5, 0, 3, 2, 0, 1, 1, 1, 1, 2,
201 1, 1, 2, 2, 0, 3, 3, 3, 3, 3,
202 3, 5, 5, 0, 0, 2, 1, 1, 1, 0,
203 4, 3, 0, 3, 1, 1, 1, 2, 3, 2,
204 1, 3, 1, 2, 2, 1, 6, 5, 4, 2,
205 2, 2, 6, 5, 4, 1, 1, 1, 3, 3,
206 1, 3, 3, 1, 3, 4, 4, 2, 2, 0,
207 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
208 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
209 1, 1, 1, 1, 2, 0,
211 static const short yydefred[] = { 2,
212 0, 0, 6, 0, 7, 8, 9, 15, 24, 0,
213 4, 0, 0, 12, 11, 0, 0, 0, 0, 0,
214 0, 0, 14, 0, 1, 0, 10, 0, 0, 0,
215 0, 0, 0, 0, 0, 24, 0, 16, 18, 19,
216 20, 17, 21, 32, 36, 37, 0, 35, 0, 29,
217 61, 58, 28, 0, 56, 96, 0, 0, 0, 27,
218 0, 0, 0, 0, 0, 64, 31, 0, 23, 26,
219 0, 0, 70, 0, 22, 0, 40, 0, 44, 0,
220 0, 0, 50, 51, 52, 0, 0, 34, 95, 59,
221 60, 0, 0, 71, 72, 73, 74, 75, 76, 77,
222 78, 79, 80, 82, 81, 83, 84, 85, 86, 87,
223 88, 93, 89, 90, 91, 94, 92, 65, 69, 39,
224 0, 0, 0, 62, 63, 66, 0, 49, 0, 55,
225 0, 67, 0, 48, 0, 54, 47, 53,
227 static const short yydgoto[] = { 1,
228 2, 4, 9, 13, 25, 10, 16, 11, 12, 23,
229 26, 59, 60, 35, 47, 48, 61, 62, 63, 64,
230 65, 71, 66, 74, 119,
232 static const short yysindex[] = { 0,
233 0, -222, 0, -155, 0, 0, 0, 0, 0, -215,
234 0, -123, 6, 0, 0, -193, 10, 21, 26, 31,
235 35, 37, 0, 59, 0, -44, 0, -147, -145, -140,
236 -133, -132, -129, 75, -214, 0, -19, 0, 0, 0,
237 0, 0, 0, 0, 0, 0, 23, 0, -48, 0,
238 0, 0, 0, -17, 0, 0, -17, 27, 128, 0,
239 -17, -1, -30, -41, -189, 0, 0, -121, 0, 0,
240 -31, -34, 0, -87, 0, -25, 0, -17, 0, -109,
241 -41, -108, 0, 0, 0, 60, 60, 0, 0, 0,
242 0, 46, 107, 0, 0, 0, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
245 -30, -36, -39, 0, 0, 0, -104, 0, -219, 0,
246 -238, 0, -144, 0, -143, 0, 0, 0,
248 static const short yyrindex[] = { 0,
249 0, -141, 0, 0, 0, 0, 0, 0, 0, 0,
250 0, -134, 9, 0, 0, -125, 0, 0, 0, 0,
251 0, 0, 0, -178, 0, 22, 0, 0, 0, 0,
252 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
253 0, 0, 0, 0, 0, 0, 0, 0, -21, 0,
254 0, 0, 0, 0, 0, 0, 0, 85, 0, 0,
255 0, 144, 47, 4, -10, 0, 0, 0, 0, 0,
256 0, 0, 0, 0, 0, 146, 0, 0, 0, 0,
257 18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
258 0, 0, 124, 0, 0, 0, 0, 0, 0, 0,
259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
261 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262 0, 0, 0, 0, 0, 0, 0, 0,
264 static const short yygindex[] = { 0,
265 0, 0, 0, 121, 133, 0, 0, 0, 0, 0,
266 0, 0, 106, 0, 0, 93, 0, 32, 84, -45,
267 0, 0, 25, 90, 0,
269 #define YYTABLESIZE 419
270 static const short yytable[] = { 57,
271 83, 84, 90, 56, 131, 118, 91, 129, 25, 57,
272 120, 24, 33, 46, 56, 55, 56, 81, 33, 135,
273 57, 85, 57, 57, 33, 57, 55, 45, 55, 57,
274 57, 57, 57, 3, 77, 57, 57, 46, 133, 46,
275 14, 45, 33, 46, 46, 79, 15, 46, 33, 46,
276 46, 45, 57, 45, 33, 25, 43, 45, 45, 42,
277 58, 25, 136, 45, 45, 24, 68, 25, 27, 33,
278 28, 58, 33, 58, 54, 81, 69, 30, 36, 134,
279 57, 29, 43, 30, 67, 42, 30, 43, 72, 78,
280 42, 31, 76, 43, 46, 32, 42, 33, 78, 33,
281 34, 33, 33, 5, 6, 7, 86, 87, 45, 8,
282 124, 125, 25, 57, 38, 25, 39, 5, 5, 5,
283 73, 40, 78, 5, 13, 13, 13, 46, 41, 42,
284 13, 33, 43, 3, 3, 3, 44, 75, 126, 3,
285 46, 45, 17, 18, 19, 20, 21, 22, 122, 123,
286 58, 127, 132, 41, 137, 38, 49, 138, 37, 70,
287 88, 121, 92, 0, 0, 0, 0, 0, 0, 93,
288 43, 0, 0, 42, 0, 0, 0, 70, 0, 0,
289 0, 0, 0, 0, 94, 95, 96, 97, 98, 99,
290 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
291 110, 111, 112, 113, 114, 115, 116, 117, 0, 0,
292 0, 0, 0, 0, 0, 0, 68, 0, 0, 0,
293 0, 0, 0, 0, 0, 89, 51, 0, 0, 0,
294 0, 0, 52, 0, 33, 33, 50, 51, 0, 51,
295 0, 33, 33, 52, 53, 52, 57, 0, 0, 0,
296 0, 0, 57, 0, 0, 0, 0, 0, 82, 0,
297 46, 130, 128, 0, 33, 33, 46, 80, 0, 0,
298 0, 33, 33, 0, 45, 0, 0, 25, 25, 0,
299 45, 0, 0, 0, 25, 25, 0, 57, 0, 57,
300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
301 0, 46, 93, 0, 0, 0, 0, 0, 0, 0,
302 0, 0, 0, 0, 0, 45, 0, 94, 95, 96,
303 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
304 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
305 117, 70, 0, 0, 0, 0, 0, 0, 0, 0,
306 0, 0, 0, 0, 0, 0, 70, 70, 70, 70,
307 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
308 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
309 68, 0, 0, 0, 0, 0, 0, 0, 0, 0,
310 0, 0, 0, 0, 0, 68, 68, 68, 68, 68,
311 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
312 68, 68, 68, 68, 68, 68, 68, 68, 68,
314 static const short yycheck[] = { 10,
315 42, 43, 34, 34, 44, 93, 41, 44, 0, 40,
316 36, 60, 34, 10, 34, 46, 34, 63, 40, 258,
317 40, 63, 40, 34, 46, 36, 46, 10, 46, 40,
318 41, 42, 43, 256, 36, 46, 47, 34, 258, 36,
319 256, 256, 34, 40, 41, 47, 262, 262, 40, 46,
320 47, 34, 63, 36, 46, 34, 10, 40, 41, 10,
321 91, 40, 301, 46, 47, 60, 44, 46, 262, 91,
322 61, 91, 94, 91, 94, 121, 125, 256, 123, 299,
323 91, 61, 36, 262, 62, 36, 61, 41, 57, 124,
324 41, 61, 61, 47, 91, 61, 47, 61, 124, 91,
325 42, 123, 94, 259, 260, 261, 296, 297, 91, 265,
326 86, 87, 91, 124, 262, 94, 262, 259, 260, 261,
327 94, 262, 124, 265, 259, 260, 261, 124, 262, 262,
328 265, 123, 262, 259, 260, 261, 62, 10, 93, 265,
329 262, 124, 266, 267, 268, 269, 270, 271, 258, 258,
330 91, 45, 257, 10, 299, 10, 36, 301, 26, 54,
331 68, 78, 73, -1, -1, -1, -1, -1, -1, 257,
332 124, -1, -1, 124, -1, -1, -1, 93, -1, -1,
333 -1, -1, -1, -1, 272, 273, 274, 275, 276, 277,
334 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
335 288, 289, 290, 291, 292, 293, 294, 295, -1, -1,
336 -1, -1, -1, -1, -1, -1, 93, -1, -1, -1,
337 -1, -1, -1, -1, -1, 257, 257, -1, -1, -1,
338 -1, -1, 263, -1, 256, 257, 256, 257, -1, 257,
339 -1, 263, 264, 263, 264, 263, 257, -1, -1, -1,
340 -1, -1, 263, -1, -1, -1, -1, -1, 300, -1,
341 257, 301, 299, -1, 256, 257, 263, 298, -1, -1,
342 -1, 263, 264, -1, 257, -1, -1, 256, 257, -1,
343 263, -1, -1, -1, 263, 264, -1, 298, -1, 300,
344 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
345 -1, 298, 257, -1, -1, -1, -1, -1, -1, -1,
346 -1, -1, -1, -1, -1, 298, -1, 272, 273, 274,
347 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
348 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
349 295, 257, -1, -1, -1, -1, -1, -1, -1, -1,
350 -1, -1, -1, -1, -1, -1, 272, 273, 274, 275,
351 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
352 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
353 257, -1, -1, -1, -1, -1, -1, -1, -1, -1,
354 -1, -1, -1, -1, -1, 272, 273, 274, 275, 276,
355 277, 278, 279, 280, 281, 282, 283, 284, 285, 286,
356 287, 288, 289, 290, 291, 292, 293, 294, 295,
358 #define YYFINAL 1
359 #ifndef YYDEBUG
360 #define YYDEBUG 0
361 #endif
362 #define YYMAXTOKEN 301
363 #if YYDEBUG
364 static const char *yyname[] = {
366 "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,
367 0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,
368 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,
369 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,
370 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,
371 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,
372 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,
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,"CHAR","NUMBER","SECTEND",
374 "SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE",
375 "OPT_PREFIX","OPT_YYCLASS","OPT_HEADER","OPT_EXTRA_TYPE","OPT_TABLES",
376 "CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL","CCE_DIGIT","CCE_GRAPH",
377 "CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE","CCE_UPPER","CCE_XDIGIT",
378 "CCE_NEG_ALNUM","CCE_NEG_ALPHA","CCE_NEG_BLANK","CCE_NEG_CNTRL","CCE_NEG_DIGIT",
379 "CCE_NEG_GRAPH","CCE_NEG_LOWER","CCE_NEG_PRINT","CCE_NEG_PUNCT","CCE_NEG_SPACE",
380 "CCE_NEG_UPPER","CCE_NEG_XDIGIT","CCL_OP_DIFF","CCL_OP_UNION",
381 "BEGIN_REPEAT_POSIX","END_REPEAT_POSIX","BEGIN_REPEAT_FLEX","END_REPEAT_FLEX",
383 static const char *yyrule[] = {
384 "$accept : goal",
385 "goal : initlex sect1 sect1end sect2 initforrule",
386 "initlex :",
387 "sect1 : sect1 startconddecl namelist1",
388 "sect1 : sect1 options",
389 "sect1 :",
390 "sect1 : error",
391 "sect1end : SECTEND",
392 "startconddecl : SCDECL",
393 "startconddecl : XSCDECL",
394 "namelist1 : namelist1 NAME",
395 "namelist1 : NAME",
396 "namelist1 : error",
397 "options : OPTION_OP optionlist",
398 "optionlist : optionlist option",
399 "optionlist :",
400 "option : OPT_OUTFILE '=' NAME",
401 "option : OPT_EXTRA_TYPE '=' NAME",
402 "option : OPT_PREFIX '=' NAME",
403 "option : OPT_YYCLASS '=' NAME",
404 "option : OPT_HEADER '=' NAME",
405 "option : OPT_TABLES '=' NAME",
406 "sect2 : sect2 scon initforrule flexrule '\\n'",
407 "sect2 : sect2 scon '{' sect2 '}'",
408 "sect2 :",
409 "initforrule :",
410 "flexrule : '^' rule",
411 "flexrule : rule",
412 "flexrule : EOF_OP",
413 "flexrule : error",
414 "scon_stk_ptr :",
415 "scon : '<' scon_stk_ptr namelist2 '>'",
416 "scon : '<' '*' '>'",
417 "scon :",
418 "namelist2 : namelist2 ',' sconname",
419 "namelist2 : sconname",
420 "namelist2 : error",
421 "sconname : NAME",
422 "rule : re2 re",
423 "rule : re2 re '$'",
424 "rule : re '$'",
425 "rule : re",
426 "re : re '|' series",
427 "re : series",
428 "re2 : re '/'",
429 "series : series singleton",
430 "series : singleton",
431 "series : series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX",
432 "series : series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX",
433 "series : series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX",
434 "singleton : singleton '*'",
435 "singleton : singleton '+'",
436 "singleton : singleton '?'",
437 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX",
438 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX",
439 "singleton : singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX",
440 "singleton : '.'",
441 "singleton : fullccl",
442 "singleton : PREVCCL",
443 "singleton : '\"' string '\"'",
444 "singleton : '(' re ')'",
445 "singleton : CHAR",
446 "fullccl : fullccl CCL_OP_DIFF braceccl",
447 "fullccl : fullccl CCL_OP_UNION braceccl",
448 "fullccl : braceccl",
449 "braceccl : '[' ccl ']'",
450 "braceccl : '[' '^' ccl ']'",
451 "ccl : ccl CHAR '-' CHAR",
452 "ccl : ccl CHAR",
453 "ccl : ccl ccl_expr",
454 "ccl :",
455 "ccl_expr : CCE_ALNUM",
456 "ccl_expr : CCE_ALPHA",
457 "ccl_expr : CCE_BLANK",
458 "ccl_expr : CCE_CNTRL",
459 "ccl_expr : CCE_DIGIT",
460 "ccl_expr : CCE_GRAPH",
461 "ccl_expr : CCE_LOWER",
462 "ccl_expr : CCE_PRINT",
463 "ccl_expr : CCE_PUNCT",
464 "ccl_expr : CCE_SPACE",
465 "ccl_expr : CCE_XDIGIT",
466 "ccl_expr : CCE_UPPER",
467 "ccl_expr : CCE_NEG_ALNUM",
468 "ccl_expr : CCE_NEG_ALPHA",
469 "ccl_expr : CCE_NEG_BLANK",
470 "ccl_expr : CCE_NEG_CNTRL",
471 "ccl_expr : CCE_NEG_DIGIT",
472 "ccl_expr : CCE_NEG_GRAPH",
473 "ccl_expr : CCE_NEG_PRINT",
474 "ccl_expr : CCE_NEG_PUNCT",
475 "ccl_expr : CCE_NEG_SPACE",
476 "ccl_expr : CCE_NEG_XDIGIT",
477 "ccl_expr : CCE_NEG_LOWER",
478 "ccl_expr : CCE_NEG_UPPER",
479 "string : string CHAR",
480 "string :",
483 #endif
485 int yydebug;
486 int yynerrs;
488 int yyerrflag;
489 int yychar;
490 YYSTYPE yyval;
491 YYSTYPE yylval;
493 /* define the initial stack-sizes */
494 #ifdef YYSTACKSIZE
495 #undef YYMAXDEPTH
496 #define YYMAXDEPTH YYSTACKSIZE
497 #else
498 #ifdef YYMAXDEPTH
499 #define YYSTACKSIZE YYMAXDEPTH
500 #else
501 #define YYSTACKSIZE 500
502 #define YYMAXDEPTH 500
503 #endif
504 #endif
506 #define YYINITSTACKSIZE 500
508 typedef struct {
509 unsigned stacksize;
510 short *s_base;
511 short *s_mark;
512 short *s_last;
513 YYSTYPE *l_base;
514 YYSTYPE *l_mark;
515 } YYSTACKDATA;
516 /* variables for the parser stack */
517 static YYSTACKDATA yystack;
520 /* build_eof_action - build the "<<EOF>>" action for the active start
521 * conditions
524 void build_eof_action()
526 register int i;
527 char action_text[MAXLINE];
529 for ( i = 1; i <= scon_stk_ptr; ++i )
531 if ( sceof[scon_stk[i]] )
532 format_pinpoint_message(
533 "multiple <<EOF>> rules for start condition %s",
534 scname[scon_stk[i]] );
536 else
538 sceof[scon_stk[i]] = true;
540 if (previous_continued_action /* && previous action was regular */)
541 add_action("YY_RULE_SETUP\n");
543 snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n",
544 scname[scon_stk[i]] );
545 add_action( action_text );
549 line_directive_out( (FILE *) 0, 1 );
551 /* This isn't a normal rule after all - don't count it as
552 * such, so we don't have any holes in the rule numbering
553 * (which make generating "rule can never match" warnings
554 * more difficult.
556 --num_rules;
557 ++num_eof_rules;
561 /* format_synerr - write out formatted syntax error */
563 void format_synerr( msg, arg )
564 const char *msg, arg[];
566 char errmsg[MAXLINE];
568 (void) snprintf( errmsg, sizeof(errmsg), msg, arg );
569 synerr( errmsg );
573 /* synerr - report a syntax error */
575 void synerr( str )
576 const char *str;
578 syntaxerror = true;
579 pinpoint_message( str );
583 /* format_warn - write out formatted warning */
585 void format_warn( msg, arg )
586 const char *msg, arg[];
588 char warn_msg[MAXLINE];
590 snprintf( warn_msg, sizeof(warn_msg), msg, arg );
591 lwarn( warn_msg );
595 /* lwarn - report a warning, unless -w was given */
597 void lwarn( str )
598 const char *str;
600 line_warning( str, linenum );
603 /* format_pinpoint_message - write out a message formatted with one string,
604 * pinpointing its location
607 void format_pinpoint_message( msg, arg )
608 const char *msg, arg[];
610 char errmsg[MAXLINE];
612 snprintf( errmsg, sizeof(errmsg), msg, arg );
613 pinpoint_message( errmsg );
617 /* pinpoint_message - write out a message, pinpointing its location */
619 void pinpoint_message( str )
620 const char *str;
622 line_pinpoint( str, linenum );
626 /* line_warning - report a warning at a given line, unless -w was given */
628 void line_warning( str, line )
629 const char *str;
630 int line;
632 char warning[MAXLINE];
634 if ( ! nowarn )
636 snprintf( warning, sizeof(warning), "warning, %s", str );
637 line_pinpoint( warning, line );
642 /* line_pinpoint - write out a message, pinpointing it at the given line */
644 void line_pinpoint( str, line )
645 const char *str;
646 int line;
648 fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
652 /* yyerror - eat up an error message from the parser;
653 * currently, messages are ignore
656 void yyerror( msg )
657 const char *msg;
661 #if YYDEBUG
662 #include <stdio.h> /* needed for printf */
663 #endif
665 #include <stdlib.h> /* needed for malloc, etc */
666 #include <string.h> /* needed for memset */
668 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
669 static int yygrowstack(YYSTACKDATA *data)
671 int i;
672 unsigned newsize;
673 short *newss;
674 YYSTYPE *newvs;
676 if ((newsize = data->stacksize) == 0)
677 newsize = YYINITSTACKSIZE;
678 else if (newsize >= YYMAXDEPTH)
679 return -1;
680 else if ((newsize *= 2) > YYMAXDEPTH)
681 newsize = YYMAXDEPTH;
683 i = (int) (data->s_mark - data->s_base);
684 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
685 if (newss == 0)
686 return -1;
688 data->s_base = newss;
689 data->s_mark = newss + i;
691 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
692 if (newvs == 0)
693 return -1;
695 data->l_base = newvs;
696 data->l_mark = newvs + i;
698 data->stacksize = newsize;
699 data->s_last = data->s_base + newsize - 1;
700 return 0;
703 #if YYPURE || defined(YY_NO_LEAKS)
704 static void yyfreestack(YYSTACKDATA *data)
706 free(data->s_base);
707 free(data->l_base);
708 memset(data, 0, sizeof(*data));
710 #else
711 #define yyfreestack(data) /* nothing */
712 #endif
714 #define YYABORT goto yyabort
715 #define YYREJECT goto yyabort
716 #define YYACCEPT goto yyaccept
717 #define YYERROR goto yyerrlab
720 YYPARSE_DECL()
722 int yym, yyn, yystate;
723 #if YYDEBUG
724 const char *yys;
726 if ((yys = getenv("YYDEBUG")) != 0)
728 yyn = *yys;
729 if (yyn >= '0' && yyn <= '9')
730 yydebug = yyn - '0';
732 #endif
734 yynerrs = 0;
735 yyerrflag = 0;
736 yychar = YYEMPTY;
737 yystate = 0;
739 #if YYPURE
740 memset(&yystack, 0, sizeof(yystack));
741 #endif
743 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
744 yystack.s_mark = yystack.s_base;
745 yystack.l_mark = yystack.l_base;
746 yystate = 0;
747 *yystack.s_mark = 0;
749 yyloop:
750 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
751 if (yychar < 0)
753 if ((yychar = YYLEX) < 0) yychar = 0;
754 #if YYDEBUG
755 if (yydebug)
757 yys = 0;
758 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
759 if (!yys) yys = "illegal-symbol";
760 printf("%sdebug: state %d, reading %d (%s)\n",
761 YYPREFIX, yystate, yychar, yys);
763 #endif
765 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
766 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
768 #if YYDEBUG
769 if (yydebug)
770 printf("%sdebug: state %d, shifting to state %d\n",
771 YYPREFIX, yystate, yytable[yyn]);
772 #endif
773 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
775 goto yyoverflow;
777 yystate = yytable[yyn];
778 *++yystack.s_mark = yytable[yyn];
779 *++yystack.l_mark = yylval;
780 yychar = YYEMPTY;
781 if (yyerrflag > 0) --yyerrflag;
782 goto yyloop;
784 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
785 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
787 yyn = yytable[yyn];
788 goto yyreduce;
790 if (yyerrflag) goto yyinrecovery;
792 yyerror("syntax error");
794 goto yyerrlab;
796 yyerrlab:
797 ++yynerrs;
799 yyinrecovery:
800 if (yyerrflag < 3)
802 yyerrflag = 3;
803 for (;;)
805 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
806 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
808 #if YYDEBUG
809 if (yydebug)
810 printf("%sdebug: state %d, error recovery shifting\
811 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
812 #endif
813 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
815 goto yyoverflow;
817 yystate = yytable[yyn];
818 *++yystack.s_mark = yytable[yyn];
819 *++yystack.l_mark = yylval;
820 goto yyloop;
822 else
824 #if YYDEBUG
825 if (yydebug)
826 printf("%sdebug: error recovery discarding state %d\n",
827 YYPREFIX, *yystack.s_mark);
828 #endif
829 if (yystack.s_mark <= yystack.s_base) goto yyabort;
830 --yystack.s_mark;
831 --yystack.l_mark;
835 else
837 if (yychar == 0) goto yyabort;
838 #if YYDEBUG
839 if (yydebug)
841 yys = 0;
842 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
843 if (!yys) yys = "illegal-symbol";
844 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
845 YYPREFIX, yystate, yychar, yys);
847 #endif
848 yychar = YYEMPTY;
849 goto yyloop;
852 yyreduce:
853 #if YYDEBUG
854 if (yydebug)
855 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
856 YYPREFIX, yystate, yyn, yyrule[yyn]);
857 #endif
858 yym = yylen[yyn];
859 if (yym)
860 yyval = yystack.l_mark[1-yym];
861 else
862 memset(&yyval, 0, sizeof yyval);
863 switch (yyn)
865 case 1:
866 { /* add default rule */
867 int def_rule;
869 pat = cclinit();
870 cclnegate( pat );
872 def_rule = mkstate( -pat );
874 /* Remember the number of the default rule so we
875 * don't generate "can't match" warnings for it.
877 default_rule = num_rules;
879 finish_rule( def_rule, false, 0, 0, 0);
881 for ( i = 1; i <= lastsc; ++i )
882 scset[i] = mkbranch( scset[i], def_rule );
884 if ( spprdflt )
885 add_action(
886 "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
887 else
888 add_action( "ECHO" );
890 add_action( ";\n\tYY_BREAK\n" );
892 break;
893 case 2:
894 { /* initialize for processing rules */
896 /* Create default DFA start condition. */
897 scinstal( "INITIAL", false );
899 break;
900 case 6:
901 { synerr( _("unknown error processing section 1") ); }
902 break;
903 case 7:
905 check_options();
906 scon_stk = allocate_integer_array( lastsc + 1 );
907 scon_stk_ptr = 0;
909 break;
910 case 8:
911 { xcluflg = false; }
912 break;
913 case 9:
914 { xcluflg = true; }
915 break;
916 case 10:
917 { scinstal( nmstr, xcluflg ); }
918 break;
919 case 11:
920 { scinstal( nmstr, xcluflg ); }
921 break;
922 case 12:
923 { synerr( _("bad start condition list") ); }
924 break;
925 case 16:
927 outfilename = copy_string( nmstr );
928 did_outfilename = 1;
930 break;
931 case 17:
932 { extra_type = copy_string( nmstr ); }
933 break;
934 case 18:
935 { prefix = copy_string( nmstr ); }
936 break;
937 case 19:
938 { yyclass = copy_string( nmstr ); }
939 break;
940 case 20:
941 { headerfilename = copy_string( nmstr ); }
942 break;
943 case 21:
944 { tablesext = true; tablesfilename = copy_string( nmstr ); }
945 break;
946 case 22:
947 { scon_stk_ptr = yystack.l_mark[-3]; }
948 break;
949 case 23:
950 { scon_stk_ptr = yystack.l_mark[-3]; }
951 break;
952 case 25:
954 /* Initialize for a parse of one rule. */
955 trlcontxt = variable_trail_rule = varlength = false;
956 trailcnt = headcnt = rulelen = 0;
957 current_state_type = STATE_NORMAL;
958 previous_continued_action = continued_action;
959 in_rule = true;
961 new_rule();
963 break;
964 case 26:
966 pat = yystack.l_mark[0];
967 finish_rule( pat, variable_trail_rule,
968 headcnt, trailcnt , previous_continued_action);
970 if ( scon_stk_ptr > 0 )
972 for ( i = 1; i <= scon_stk_ptr; ++i )
973 scbol[scon_stk[i]] =
974 mkbranch( scbol[scon_stk[i]],
975 pat );
978 else
980 /* Add to all non-exclusive start conditions,
981 * including the default (0) start condition.
984 for ( i = 1; i <= lastsc; ++i )
985 if ( ! scxclu[i] )
986 scbol[i] = mkbranch( scbol[i],
987 pat );
990 if ( ! bol_needed )
992 bol_needed = true;
994 if ( performance_report > 1 )
995 pinpoint_message(
996 "'^' operator results in sub-optimal performance" );
999 break;
1000 case 27:
1002 pat = yystack.l_mark[0];
1003 finish_rule( pat, variable_trail_rule,
1004 headcnt, trailcnt , previous_continued_action);
1006 if ( scon_stk_ptr > 0 )
1008 for ( i = 1; i <= scon_stk_ptr; ++i )
1009 scset[scon_stk[i]] =
1010 mkbranch( scset[scon_stk[i]],
1011 pat );
1014 else
1016 for ( i = 1; i <= lastsc; ++i )
1017 if ( ! scxclu[i] )
1018 scset[i] =
1019 mkbranch( scset[i],
1020 pat );
1023 break;
1024 case 28:
1026 if ( scon_stk_ptr > 0 )
1027 build_eof_action();
1029 else
1031 /* This EOF applies to all start conditions
1032 * which don't already have EOF actions.
1034 for ( i = 1; i <= lastsc; ++i )
1035 if ( ! sceof[i] )
1036 scon_stk[++scon_stk_ptr] = i;
1038 if ( scon_stk_ptr == 0 )
1039 lwarn(
1040 "all start conditions already have <<EOF>> rules" );
1042 else
1043 build_eof_action();
1046 break;
1047 case 29:
1048 { synerr( _("unrecognized rule") ); }
1049 break;
1050 case 30:
1051 { yyval = scon_stk_ptr; }
1052 break;
1053 case 31:
1054 { yyval = yystack.l_mark[-2]; }
1055 break;
1056 case 32:
1058 yyval = scon_stk_ptr;
1060 for ( i = 1; i <= lastsc; ++i )
1062 int j;
1064 for ( j = 1; j <= scon_stk_ptr; ++j )
1065 if ( scon_stk[j] == i )
1066 break;
1068 if ( j > scon_stk_ptr )
1069 scon_stk[++scon_stk_ptr] = i;
1072 break;
1073 case 33:
1074 { yyval = scon_stk_ptr; }
1075 break;
1076 case 36:
1077 { synerr( _("bad start condition list") ); }
1078 break;
1079 case 37:
1081 if ( (scnum = sclookup( nmstr )) == 0 )
1082 format_pinpoint_message(
1083 "undeclared start condition %s",
1084 nmstr );
1085 else
1087 for ( i = 1; i <= scon_stk_ptr; ++i )
1088 if ( scon_stk[i] == scnum )
1090 format_warn(
1091 "<%s> specified twice",
1092 scname[scnum] );
1093 break;
1096 if ( i > scon_stk_ptr )
1097 scon_stk[++scon_stk_ptr] = scnum;
1100 break;
1101 case 38:
1103 if ( transchar[lastst[yystack.l_mark[0]]] != SYM_EPSILON )
1104 /* Provide final transition \now/ so it
1105 * will be marked as a trailing context
1106 * state.
1108 yystack.l_mark[0] = link_machines( yystack.l_mark[0],
1109 mkstate( SYM_EPSILON ) );
1111 mark_beginning_as_normal( yystack.l_mark[0] );
1112 current_state_type = STATE_NORMAL;
1114 if ( previous_continued_action )
1116 /* We need to treat this as variable trailing
1117 * context so that the backup does not happen
1118 * in the action but before the action switch
1119 * statement. If the backup happens in the
1120 * action, then the rules "falling into" this
1121 * one's action will *also* do the backup,
1122 * erroneously.
1124 if ( ! varlength || headcnt != 0 )
1125 lwarn(
1126 "trailing context made variable due to preceding '|' action" );
1128 /* Mark as variable. */
1129 varlength = true;
1130 headcnt = 0;
1134 if ( lex_compat || (varlength && headcnt == 0) )
1135 { /* variable trailing context rule */
1136 /* Mark the first part of the rule as the
1137 * accepting "head" part of a trailing
1138 * context rule.
1140 * By the way, we didn't do this at the
1141 * beginning of this production because back
1142 * then current_state_type was set up for a
1143 * trail rule, and add_accept() can create
1144 * a new state ...
1146 add_accept( yystack.l_mark[-1],
1147 num_rules | YY_TRAILING_HEAD_MASK );
1148 variable_trail_rule = true;
1151 else
1152 trailcnt = rulelen;
1154 yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1156 break;
1157 case 39:
1158 { synerr( _("trailing context used twice") ); }
1159 break;
1160 case 40:
1162 headcnt = 0;
1163 trailcnt = 1;
1164 rulelen = 1;
1165 varlength = false;
1167 current_state_type = STATE_TRAILING_CONTEXT;
1169 if ( trlcontxt )
1171 synerr( _("trailing context used twice") );
1172 yyval = mkstate( SYM_EPSILON );
1175 else if ( previous_continued_action )
1177 /* See the comment in the rule for "re2 re"
1178 * above.
1180 lwarn(
1181 "trailing context made variable due to preceding '|' action" );
1183 varlength = true;
1186 if ( lex_compat || varlength )
1188 /* Again, see the comment in the rule for
1189 * "re2 re" above.
1191 add_accept( yystack.l_mark[-1],
1192 num_rules | YY_TRAILING_HEAD_MASK );
1193 variable_trail_rule = true;
1196 trlcontxt = true;
1198 eps = mkstate( SYM_EPSILON );
1199 yyval = link_machines( yystack.l_mark[-1],
1200 link_machines( eps, mkstate( '\n' ) ) );
1202 break;
1203 case 41:
1205 yyval = yystack.l_mark[0];
1207 if ( trlcontxt )
1209 if ( lex_compat || (varlength && headcnt == 0) )
1210 /* Both head and trail are
1211 * variable-length.
1213 variable_trail_rule = true;
1214 else
1215 trailcnt = rulelen;
1218 break;
1219 case 42:
1221 varlength = true;
1222 yyval = mkor( yystack.l_mark[-2], yystack.l_mark[0] );
1224 break;
1225 case 43:
1226 { yyval = yystack.l_mark[0]; }
1227 break;
1228 case 44:
1230 /* This rule is written separately so the
1231 * reduction will occur before the trailing
1232 * series is parsed.
1235 if ( trlcontxt )
1236 synerr( _("trailing context used twice") );
1237 else
1238 trlcontxt = true;
1240 if ( varlength )
1241 /* We hope the trailing context is
1242 * fixed-length.
1244 varlength = false;
1245 else
1246 headcnt = rulelen;
1248 rulelen = 0;
1250 current_state_type = STATE_TRAILING_CONTEXT;
1251 yyval = yystack.l_mark[-1];
1253 break;
1254 case 45:
1256 /* This is where concatenation of adjacent patterns
1257 * gets done.
1259 yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1261 break;
1262 case 46:
1263 { yyval = yystack.l_mark[0]; }
1264 break;
1265 case 47:
1267 varlength = true;
1269 if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1271 synerr( _("bad iteration values") );
1272 yyval = yystack.l_mark[-5];
1274 else
1276 if ( yystack.l_mark[-3] == 0 )
1278 if ( yystack.l_mark[-1] <= 0 )
1280 synerr(
1281 _("bad iteration values") );
1282 yyval = yystack.l_mark[-5];
1284 else
1285 yyval = mkopt(
1286 mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1288 else
1289 yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1292 break;
1293 case 48:
1295 varlength = true;
1297 if ( yystack.l_mark[-2] <= 0 )
1299 synerr( _("iteration value must be positive") );
1300 yyval = yystack.l_mark[-4];
1303 else
1304 yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1306 break;
1307 case 49:
1309 /* The series could be something like "(foo)",
1310 * in which case we have no idea what its length
1311 * is, so we punt here.
1313 varlength = true;
1315 if ( yystack.l_mark[-1] <= 0 )
1317 synerr( _("iteration value must be positive")
1319 yyval = yystack.l_mark[-3];
1322 else
1323 yyval = link_machines( yystack.l_mark[-3],
1324 copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1326 break;
1327 case 50:
1329 varlength = true;
1331 yyval = mkclos( yystack.l_mark[-1] );
1333 break;
1334 case 51:
1336 varlength = true;
1337 yyval = mkposcl( yystack.l_mark[-1] );
1339 break;
1340 case 52:
1342 varlength = true;
1343 yyval = mkopt( yystack.l_mark[-1] );
1345 break;
1346 case 53:
1348 varlength = true;
1350 if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1352 synerr( _("bad iteration values") );
1353 yyval = yystack.l_mark[-5];
1355 else
1357 if ( yystack.l_mark[-3] == 0 )
1359 if ( yystack.l_mark[-1] <= 0 )
1361 synerr(
1362 _("bad iteration values") );
1363 yyval = yystack.l_mark[-5];
1365 else
1366 yyval = mkopt(
1367 mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1369 else
1370 yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1373 break;
1374 case 54:
1376 varlength = true;
1378 if ( yystack.l_mark[-2] <= 0 )
1380 synerr( _("iteration value must be positive") );
1381 yyval = yystack.l_mark[-4];
1384 else
1385 yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1387 break;
1388 case 55:
1390 /* The singleton could be something like "(foo)",
1391 * in which case we have no idea what its length
1392 * is, so we punt here.
1394 varlength = true;
1396 if ( yystack.l_mark[-1] <= 0 )
1398 synerr( _("iteration value must be positive") );
1399 yyval = yystack.l_mark[-3];
1402 else
1403 yyval = link_machines( yystack.l_mark[-3],
1404 copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1406 break;
1407 case 56:
1409 if ( ! madeany )
1411 /* Create the '.' character class. */
1412 ccldot = cclinit();
1413 ccladd( ccldot, '\n' );
1414 cclnegate( ccldot );
1416 if ( useecs )
1417 mkeccl( ccltbl + cclmap[ccldot],
1418 ccllen[ccldot], nextecm,
1419 ecgroup, csize, csize );
1421 /* Create the (?s:'.') character class. */
1422 cclany = cclinit();
1423 cclnegate( cclany );
1425 if ( useecs )
1426 mkeccl( ccltbl + cclmap[cclany],
1427 ccllen[cclany], nextecm,
1428 ecgroup, csize, csize );
1430 madeany = true;
1433 ++rulelen;
1435 if (sf_dot_all())
1436 yyval = mkstate( -cclany );
1437 else
1438 yyval = mkstate( -ccldot );
1440 break;
1441 case 57:
1443 /* Sort characters for fast searching.
1445 qsort( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]], sizeof (*ccltbl), cclcmp );
1447 if ( useecs )
1448 mkeccl( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]],
1449 nextecm, ecgroup, csize, csize );
1451 ++rulelen;
1453 if (ccl_has_nl[yystack.l_mark[0]])
1454 rule_has_nl[num_rules] = true;
1456 yyval = mkstate( -yystack.l_mark[0] );
1458 break;
1459 case 58:
1461 ++rulelen;
1463 if (ccl_has_nl[yystack.l_mark[0]])
1464 rule_has_nl[num_rules] = true;
1466 yyval = mkstate( -yystack.l_mark[0] );
1468 break;
1469 case 59:
1470 { yyval = yystack.l_mark[-1]; }
1471 break;
1472 case 60:
1473 { yyval = yystack.l_mark[-1]; }
1474 break;
1475 case 61:
1477 ++rulelen;
1479 if (yystack.l_mark[0] == nlch)
1480 rule_has_nl[num_rules] = true;
1482 if (sf_case_ins() && has_case(yystack.l_mark[0]))
1483 /* create an alternation, as in (a|A) */
1484 yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1485 else
1486 yyval = mkstate( yystack.l_mark[0] );
1488 break;
1489 case 62:
1490 { yyval = ccl_set_diff (yystack.l_mark[-2], yystack.l_mark[0]); }
1491 break;
1492 case 63:
1493 { yyval = ccl_set_union (yystack.l_mark[-2], yystack.l_mark[0]); }
1494 break;
1495 case 65:
1496 { yyval = yystack.l_mark[-1]; }
1497 break;
1498 case 66:
1500 cclnegate( yystack.l_mark[-1] );
1501 yyval = yystack.l_mark[-1];
1503 break;
1504 case 67:
1507 if (sf_case_ins())
1510 /* If one end of the range has case and the other
1511 * does not, or the cases are different, then we're not
1512 * sure what range the user is trying to express.
1513 * Examples: [@-z] or [S-t]
1515 if (has_case (yystack.l_mark[-2]) != has_case (yystack.l_mark[0])
1516 || (has_case (yystack.l_mark[-2]) && (b_islower (yystack.l_mark[-2]) != b_islower (yystack.l_mark[0])))
1517 || (has_case (yystack.l_mark[-2]) && (b_isupper (yystack.l_mark[-2]) != b_isupper (yystack.l_mark[0]))))
1518 format_warn3 (
1519 _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
1520 yystack.l_mark[-2], yystack.l_mark[0]);
1522 /* If the range spans uppercase characters but not
1523 * lowercase (or vice-versa), then should we automatically
1524 * include lowercase characters in the range?
1525 * Example: [@-_] spans [a-z] but not [A-Z]
1527 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]))
1528 format_warn3 (
1529 _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
1530 yystack.l_mark[-2], yystack.l_mark[0]);
1533 if ( yystack.l_mark[-2] > yystack.l_mark[0] )
1534 synerr( _("negative range in character class") );
1536 else
1538 for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
1539 ccladd( yystack.l_mark[-3], i );
1541 /* Keep track if this ccl is staying in
1542 * alphabetical order.
1544 cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
1545 lastchar = yystack.l_mark[0];
1547 /* Do it again for upper/lowercase */
1548 if (sf_case_ins() && has_case(yystack.l_mark[-2]) && has_case(yystack.l_mark[0])){
1549 yystack.l_mark[-2] = reverse_case (yystack.l_mark[-2]);
1550 yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
1552 for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
1553 ccladd( yystack.l_mark[-3], i );
1555 cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
1556 lastchar = yystack.l_mark[0];
1561 yyval = yystack.l_mark[-3];
1563 break;
1564 case 68:
1566 ccladd( yystack.l_mark[-1], yystack.l_mark[0] );
1567 cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
1568 lastchar = yystack.l_mark[0];
1570 /* Do it again for upper/lowercase */
1571 if (sf_case_ins() && has_case(yystack.l_mark[0])){
1572 yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
1573 ccladd (yystack.l_mark[-1], yystack.l_mark[0]);
1575 cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
1576 lastchar = yystack.l_mark[0];
1579 yyval = yystack.l_mark[-1];
1581 break;
1582 case 69:
1584 /* Too hard to properly maintain cclsorted. */
1585 cclsorted = false;
1586 yyval = yystack.l_mark[-1];
1588 break;
1589 case 70:
1591 cclsorted = true;
1592 lastchar = 0;
1593 currccl = yyval = cclinit();
1595 break;
1596 case 71:
1597 { CCL_EXPR(isalnum); }
1598 break;
1599 case 72:
1600 { CCL_EXPR(isalpha); }
1601 break;
1602 case 73:
1603 { CCL_EXPR(IS_BLANK); }
1604 break;
1605 case 74:
1606 { CCL_EXPR(iscntrl); }
1607 break;
1608 case 75:
1609 { CCL_EXPR(isdigit); }
1610 break;
1611 case 76:
1612 { CCL_EXPR(isgraph); }
1613 break;
1614 case 77:
1616 CCL_EXPR(islower);
1617 if (sf_case_ins())
1618 CCL_EXPR(isupper);
1620 break;
1621 case 78:
1622 { CCL_EXPR(isprint); }
1623 break;
1624 case 79:
1625 { CCL_EXPR(ispunct); }
1626 break;
1627 case 80:
1628 { CCL_EXPR(isspace); }
1629 break;
1630 case 81:
1631 { CCL_EXPR(isxdigit); }
1632 break;
1633 case 82:
1635 CCL_EXPR(isupper);
1636 if (sf_case_ins())
1637 CCL_EXPR(islower);
1639 break;
1640 case 83:
1641 { CCL_NEG_EXPR(isalnum); }
1642 break;
1643 case 84:
1644 { CCL_NEG_EXPR(isalpha); }
1645 break;
1646 case 85:
1647 { CCL_NEG_EXPR(IS_BLANK); }
1648 break;
1649 case 86:
1650 { CCL_NEG_EXPR(iscntrl); }
1651 break;
1652 case 87:
1653 { CCL_NEG_EXPR(isdigit); }
1654 break;
1655 case 88:
1656 { CCL_NEG_EXPR(isgraph); }
1657 break;
1658 case 89:
1659 { CCL_NEG_EXPR(isprint); }
1660 break;
1661 case 90:
1662 { CCL_NEG_EXPR(ispunct); }
1663 break;
1664 case 91:
1665 { CCL_NEG_EXPR(isspace); }
1666 break;
1667 case 92:
1668 { CCL_NEG_EXPR(isxdigit); }
1669 break;
1670 case 93:
1672 if ( sf_case_ins() )
1673 lwarn(_("[:^lower:] is ambiguous in case insensitive scanner"));
1674 else
1675 CCL_NEG_EXPR(islower);
1677 break;
1678 case 94:
1680 if ( sf_case_ins() )
1681 lwarn(_("[:^upper:] ambiguous in case insensitive scanner"));
1682 else
1683 CCL_NEG_EXPR(isupper);
1685 break;
1686 case 95:
1688 if ( yystack.l_mark[0] == nlch )
1689 rule_has_nl[num_rules] = true;
1691 ++rulelen;
1693 if (sf_case_ins() && has_case(yystack.l_mark[0]))
1694 yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1695 else
1696 yyval = mkstate (yystack.l_mark[0]);
1698 yyval = link_machines( yystack.l_mark[-1], yyval);
1700 break;
1701 case 96:
1702 { yyval = mkstate( SYM_EPSILON ); }
1703 break;
1705 yystack.s_mark -= yym;
1706 yystate = *yystack.s_mark;
1707 yystack.l_mark -= yym;
1708 yym = yylhs[yyn];
1709 if (yystate == 0 && yym == 0)
1711 #if YYDEBUG
1712 if (yydebug)
1713 printf("%sdebug: after reduction, shifting from state 0 to\
1714 state %d\n", YYPREFIX, YYFINAL);
1715 #endif
1716 yystate = YYFINAL;
1717 *++yystack.s_mark = YYFINAL;
1718 *++yystack.l_mark = yyval;
1719 if (yychar < 0)
1721 if ((yychar = YYLEX) < 0) yychar = 0;
1722 #if YYDEBUG
1723 if (yydebug)
1725 yys = 0;
1726 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1727 if (!yys) yys = "illegal-symbol";
1728 printf("%sdebug: state %d, reading %d (%s)\n",
1729 YYPREFIX, YYFINAL, yychar, yys);
1731 #endif
1733 if (yychar == 0) goto yyaccept;
1734 goto yyloop;
1736 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1737 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1738 yystate = yytable[yyn];
1739 else
1740 yystate = yydgoto[yym];
1741 #if YYDEBUG
1742 if (yydebug)
1743 printf("%sdebug: after reduction, shifting from state %d \
1744 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1745 #endif
1746 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1748 goto yyoverflow;
1750 *++yystack.s_mark = (short) yystate;
1751 *++yystack.l_mark = yyval;
1752 goto yyloop;
1754 yyoverflow:
1755 yyerror("yacc stack overflow");
1757 yyabort:
1758 yyfreestack(&yystack);
1759 return (1);
1761 yyaccept:
1762 yyfreestack(&yystack);
1763 return (0);