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