1*0a6a1f1dSLionel Sambuc /* $NetBSD: initparse.c,v 1.5 2014/10/30 18:44:05 christos Exp $ */
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc #include "flexdef.h"
4*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: initparse.c,v 1.5 2014/10/30 18:44:05 christos Exp $");
5*0a6a1f1dSLionel Sambuc
6357f1050SThomas Veerman #ifndef lint
7357f1050SThomas Veerman static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
8357f1050SThomas Veerman #endif
9357f1050SThomas Veerman
10357f1050SThomas Veerman #ifdef _LIBC
11357f1050SThomas Veerman #include "namespace.h"
12357f1050SThomas Veerman #endif
13357f1050SThomas Veerman #include <stdlib.h>
14357f1050SThomas Veerman #include <string.h>
15357f1050SThomas Veerman
16357f1050SThomas Veerman #define YYBYACC 1
17357f1050SThomas Veerman #define YYMAJOR 1
18357f1050SThomas Veerman #define YYMINOR 9
19357f1050SThomas Veerman
20357f1050SThomas Veerman #define YYEMPTY (-1)
21357f1050SThomas Veerman #define yyclearin (yychar = YYEMPTY)
22357f1050SThomas Veerman #define yyerrok (yyerrflag = 0)
23357f1050SThomas Veerman #define YYRECOVERING() (yyerrflag != 0)
24357f1050SThomas Veerman
25357f1050SThomas Veerman #define YYPREFIX "yy"
2684d9c625SLionel Sambuc
2784d9c625SLionel Sambuc #define YYPURE 0
2884d9c625SLionel Sambuc
29357f1050SThomas Veerman /* Copyright (c) 1990 The Regents of the University of California. */
30357f1050SThomas Veerman /* All rights reserved. */
31357f1050SThomas Veerman
32357f1050SThomas Veerman /* This code is derived from software contributed to Berkeley by */
33357f1050SThomas Veerman /* Vern Paxson. */
34357f1050SThomas Veerman
35357f1050SThomas Veerman /* The United States Government has rights in this work pursuant */
36357f1050SThomas Veerman /* to contract no. DE-AC03-76SF00098 between the United States */
37357f1050SThomas Veerman /* Department of Energy and the University of California. */
38357f1050SThomas Veerman
39357f1050SThomas Veerman /* This file is part of flex. */
40357f1050SThomas Veerman
41357f1050SThomas Veerman /* Redistribution and use in source and binary forms, with or without */
42357f1050SThomas Veerman /* modification, are permitted provided that the following conditions */
43357f1050SThomas Veerman /* are met: */
44357f1050SThomas Veerman
45357f1050SThomas Veerman /* 1. Redistributions of source code must retain the above copyright */
46357f1050SThomas Veerman /* notice, this list of conditions and the following disclaimer. */
47357f1050SThomas Veerman /* 2. Redistributions in binary form must reproduce the above copyright */
48357f1050SThomas Veerman /* notice, this list of conditions and the following disclaimer in the */
49357f1050SThomas Veerman /* documentation and/or other materials provided with the distribution. */
50357f1050SThomas Veerman
51357f1050SThomas Veerman /* Neither the name of the University nor the names of its contributors */
52357f1050SThomas Veerman /* may be used to endorse or promote products derived from this software */
53357f1050SThomas Veerman /* without specific prior written permission. */
54357f1050SThomas Veerman
55357f1050SThomas Veerman /* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
56357f1050SThomas Veerman /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
57357f1050SThomas Veerman /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
58357f1050SThomas Veerman /* PURPOSE. */
59357f1050SThomas Veerman
60357f1050SThomas Veerman #include "tables.h"
61357f1050SThomas Veerman
62357f1050SThomas Veerman int pat, scnum, eps, headcnt, trailcnt, lastchar, i, rulelen;
63357f1050SThomas Veerman int trlcontxt, xcluflg, currccl, cclsorted, varlength, variable_trail_rule;
64357f1050SThomas Veerman
65357f1050SThomas Veerman int *scon_stk;
66357f1050SThomas Veerman int scon_stk_ptr;
67357f1050SThomas Veerman
68357f1050SThomas Veerman static int madeany = false; /* whether we've made the '.' character class */
69357f1050SThomas Veerman static int ccldot, cclany;
70357f1050SThomas Veerman int previous_continued_action; /* whether the previous rule's action was '|' */
71357f1050SThomas Veerman
72357f1050SThomas Veerman #define format_warn3(fmt, a1, a2) \
73357f1050SThomas Veerman do{ \
74357f1050SThomas Veerman char fw3_msg[MAXLINE];\
75357f1050SThomas Veerman snprintf( fw3_msg, MAXLINE,(fmt), (a1), (a2) );\
76357f1050SThomas Veerman lwarn( fw3_msg );\
77357f1050SThomas Veerman }while(0)
78357f1050SThomas Veerman
79357f1050SThomas Veerman /* Expand a POSIX character class expression. */
80357f1050SThomas Veerman #define CCL_EXPR(func) \
81357f1050SThomas Veerman do{ \
82357f1050SThomas Veerman int c; \
83357f1050SThomas Veerman for ( c = 0; c < csize; ++c ) \
84357f1050SThomas Veerman if ( isascii(c) && func(c) ) \
85357f1050SThomas Veerman ccladd( currccl, c ); \
86357f1050SThomas Veerman }while(0)
87357f1050SThomas Veerman
88357f1050SThomas Veerman /* negated class */
89357f1050SThomas Veerman #define CCL_NEG_EXPR(func) \
90357f1050SThomas Veerman do{ \
91357f1050SThomas Veerman int c; \
92357f1050SThomas Veerman for ( c = 0; c < csize; ++c ) \
93357f1050SThomas Veerman if ( !func(c) ) \
94357f1050SThomas Veerman ccladd( currccl, c ); \
95357f1050SThomas Veerman }while(0)
96357f1050SThomas Veerman
97357f1050SThomas Veerman /* While POSIX defines isblank(), it's not ANSI C. */
98357f1050SThomas Veerman #define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
99357f1050SThomas Veerman
100357f1050SThomas Veerman /* On some over-ambitious machines, such as DEC Alpha's, the default
101357f1050SThomas Veerman * token type is "long" instead of "int"; this leads to problems with
102357f1050SThomas Veerman * declaring yylval in flexdef.h. But so far, all the yacc's I've seen
103357f1050SThomas Veerman * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
104357f1050SThomas Veerman * following should ensure that the default token type is "int".
105357f1050SThomas Veerman */
106357f1050SThomas Veerman #define YYSTYPE int
107357f1050SThomas Veerman
10884d9c625SLionel Sambuc
10984d9c625SLionel Sambuc #ifndef YYSTYPE
11084d9c625SLionel Sambuc typedef int YYSTYPE;
11184d9c625SLionel Sambuc #endif
11284d9c625SLionel Sambuc
11384d9c625SLionel Sambuc /* compatibility with bison */
11484d9c625SLionel Sambuc #ifdef YYPARSE_PARAM
11584d9c625SLionel Sambuc /* compatibility with FreeBSD */
11684d9c625SLionel Sambuc # ifdef YYPARSE_PARAM_TYPE
11784d9c625SLionel Sambuc # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
11884d9c625SLionel Sambuc # else
11984d9c625SLionel Sambuc # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
12084d9c625SLionel Sambuc # endif
12184d9c625SLionel Sambuc #else
12284d9c625SLionel Sambuc # define YYPARSE_DECL() yyparse(void)
12384d9c625SLionel Sambuc #endif
12484d9c625SLionel Sambuc
12584d9c625SLionel Sambuc /* Parameters sent to lex. */
12684d9c625SLionel Sambuc #ifdef YYLEX_PARAM
12784d9c625SLionel Sambuc # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
12884d9c625SLionel Sambuc # define YYLEX yylex(YYLEX_PARAM)
12984d9c625SLionel Sambuc #else
13084d9c625SLionel Sambuc # define YYLEX_DECL() yylex(void)
13184d9c625SLionel Sambuc # define YYLEX yylex()
13284d9c625SLionel Sambuc #endif
13384d9c625SLionel Sambuc
13484d9c625SLionel Sambuc /* Parameters sent to yyerror. */
13584d9c625SLionel Sambuc #ifndef YYERROR_DECL
13684d9c625SLionel Sambuc #define YYERROR_DECL() yyerror(const char *s)
13784d9c625SLionel Sambuc #endif
13884d9c625SLionel Sambuc #ifndef YYERROR_CALL
13984d9c625SLionel Sambuc #define YYERROR_CALL(msg) yyerror(msg)
14084d9c625SLionel Sambuc #endif
14184d9c625SLionel Sambuc
14284d9c625SLionel Sambuc extern int YYPARSE_DECL();
14384d9c625SLionel Sambuc
14484d9c625SLionel Sambuc
145357f1050SThomas Veerman #define CHAR 257
146357f1050SThomas Veerman #define NUMBER 258
147357f1050SThomas Veerman #define SECTEND 259
148357f1050SThomas Veerman #define SCDECL 260
149357f1050SThomas Veerman #define XSCDECL 261
150357f1050SThomas Veerman #define NAME 262
151357f1050SThomas Veerman #define PREVCCL 263
152357f1050SThomas Veerman #define EOF_OP 264
153357f1050SThomas Veerman #define OPTION_OP 265
154357f1050SThomas Veerman #define OPT_OUTFILE 266
155357f1050SThomas Veerman #define OPT_PREFIX 267
156357f1050SThomas Veerman #define OPT_YYCLASS 268
157357f1050SThomas Veerman #define OPT_HEADER 269
158357f1050SThomas Veerman #define OPT_EXTRA_TYPE 270
159357f1050SThomas Veerman #define OPT_TABLES 271
160357f1050SThomas Veerman #define CCE_ALNUM 272
161357f1050SThomas Veerman #define CCE_ALPHA 273
162357f1050SThomas Veerman #define CCE_BLANK 274
163357f1050SThomas Veerman #define CCE_CNTRL 275
164357f1050SThomas Veerman #define CCE_DIGIT 276
165357f1050SThomas Veerman #define CCE_GRAPH 277
166357f1050SThomas Veerman #define CCE_LOWER 278
167357f1050SThomas Veerman #define CCE_PRINT 279
168357f1050SThomas Veerman #define CCE_PUNCT 280
169357f1050SThomas Veerman #define CCE_SPACE 281
170357f1050SThomas Veerman #define CCE_UPPER 282
171357f1050SThomas Veerman #define CCE_XDIGIT 283
172357f1050SThomas Veerman #define CCE_NEG_ALNUM 284
173357f1050SThomas Veerman #define CCE_NEG_ALPHA 285
174357f1050SThomas Veerman #define CCE_NEG_BLANK 286
175357f1050SThomas Veerman #define CCE_NEG_CNTRL 287
176357f1050SThomas Veerman #define CCE_NEG_DIGIT 288
177357f1050SThomas Veerman #define CCE_NEG_GRAPH 289
178357f1050SThomas Veerman #define CCE_NEG_LOWER 290
179357f1050SThomas Veerman #define CCE_NEG_PRINT 291
180357f1050SThomas Veerman #define CCE_NEG_PUNCT 292
181357f1050SThomas Veerman #define CCE_NEG_SPACE 293
182357f1050SThomas Veerman #define CCE_NEG_UPPER 294
183357f1050SThomas Veerman #define CCE_NEG_XDIGIT 295
184357f1050SThomas Veerman #define CCL_OP_DIFF 296
185357f1050SThomas Veerman #define CCL_OP_UNION 297
186357f1050SThomas Veerman #define BEGIN_REPEAT_POSIX 298
187357f1050SThomas Veerman #define END_REPEAT_POSIX 299
188357f1050SThomas Veerman #define BEGIN_REPEAT_FLEX 300
189357f1050SThomas Veerman #define END_REPEAT_FLEX 301
190357f1050SThomas Veerman #define YYERRCODE 256
191357f1050SThomas Veerman static const short yylhs[] = { -1,
192357f1050SThomas Veerman 0, 1, 2, 2, 2, 2, 3, 6, 6, 7,
193357f1050SThomas Veerman 7, 7, 8, 9, 9, 10, 10, 10, 10, 10,
194357f1050SThomas Veerman 10, 4, 4, 4, 5, 12, 12, 12, 12, 14,
195357f1050SThomas Veerman 11, 11, 11, 15, 15, 15, 16, 13, 13, 13,
196357f1050SThomas Veerman 13, 18, 18, 17, 19, 19, 19, 19, 19, 20,
197357f1050SThomas Veerman 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
198357f1050SThomas Veerman 20, 21, 21, 21, 23, 23, 24, 24, 24, 24,
199357f1050SThomas Veerman 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
200357f1050SThomas Veerman 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
201357f1050SThomas Veerman 25, 25, 25, 25, 22, 22,
202357f1050SThomas Veerman };
203357f1050SThomas Veerman static const short yylen[] = { 2,
204357f1050SThomas Veerman 5, 0, 3, 2, 0, 1, 1, 1, 1, 2,
205357f1050SThomas Veerman 1, 1, 2, 2, 0, 3, 3, 3, 3, 3,
206357f1050SThomas Veerman 3, 5, 5, 0, 0, 2, 1, 1, 1, 0,
207357f1050SThomas Veerman 4, 3, 0, 3, 1, 1, 1, 2, 3, 2,
208357f1050SThomas Veerman 1, 3, 1, 2, 2, 1, 6, 5, 4, 2,
209357f1050SThomas Veerman 2, 2, 6, 5, 4, 1, 1, 1, 3, 3,
210357f1050SThomas Veerman 1, 3, 3, 1, 3, 4, 4, 2, 2, 0,
211357f1050SThomas Veerman 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
212357f1050SThomas Veerman 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
213357f1050SThomas Veerman 1, 1, 1, 1, 2, 0,
214357f1050SThomas Veerman };
215357f1050SThomas Veerman static const short yydefred[] = { 2,
216357f1050SThomas Veerman 0, 0, 6, 0, 7, 8, 9, 15, 24, 0,
217357f1050SThomas Veerman 4, 0, 0, 12, 11, 0, 0, 0, 0, 0,
218357f1050SThomas Veerman 0, 0, 14, 0, 1, 0, 10, 0, 0, 0,
219357f1050SThomas Veerman 0, 0, 0, 0, 0, 24, 0, 16, 18, 19,
220357f1050SThomas Veerman 20, 17, 21, 32, 36, 37, 0, 35, 0, 29,
221357f1050SThomas Veerman 61, 58, 28, 0, 56, 96, 0, 0, 0, 27,
222357f1050SThomas Veerman 0, 0, 0, 0, 0, 64, 31, 0, 23, 26,
223357f1050SThomas Veerman 0, 0, 70, 0, 22, 0, 40, 0, 44, 0,
224357f1050SThomas Veerman 0, 0, 50, 51, 52, 0, 0, 34, 95, 59,
225357f1050SThomas Veerman 60, 0, 0, 71, 72, 73, 74, 75, 76, 77,
226357f1050SThomas Veerman 78, 79, 80, 82, 81, 83, 84, 85, 86, 87,
227357f1050SThomas Veerman 88, 93, 89, 90, 91, 94, 92, 65, 69, 39,
228357f1050SThomas Veerman 0, 0, 0, 62, 63, 66, 0, 49, 0, 55,
229357f1050SThomas Veerman 0, 67, 0, 48, 0, 54, 47, 53,
230357f1050SThomas Veerman };
231357f1050SThomas Veerman static const short yydgoto[] = { 1,
232357f1050SThomas Veerman 2, 4, 9, 13, 25, 10, 16, 11, 12, 23,
233357f1050SThomas Veerman 26, 59, 60, 35, 47, 48, 61, 62, 63, 64,
234357f1050SThomas Veerman 65, 71, 66, 74, 119,
235357f1050SThomas Veerman };
236357f1050SThomas Veerman static const short yysindex[] = { 0,
237357f1050SThomas Veerman 0, -222, 0, -155, 0, 0, 0, 0, 0, -215,
238357f1050SThomas Veerman 0, -123, 6, 0, 0, -193, 10, 21, 26, 31,
239357f1050SThomas Veerman 35, 37, 0, 59, 0, -44, 0, -147, -145, -140,
240357f1050SThomas Veerman -133, -132, -129, 75, -214, 0, -19, 0, 0, 0,
241357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 23, 0, -48, 0,
242357f1050SThomas Veerman 0, 0, 0, -17, 0, 0, -17, 27, 128, 0,
243357f1050SThomas Veerman -17, -1, -30, -41, -189, 0, 0, -121, 0, 0,
244357f1050SThomas Veerman -31, -34, 0, -87, 0, -25, 0, -17, 0, -109,
245357f1050SThomas Veerman -41, -108, 0, 0, 0, 60, 60, 0, 0, 0,
246357f1050SThomas Veerman 0, 46, 107, 0, 0, 0, 0, 0, 0, 0,
247357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
248357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249357f1050SThomas Veerman -30, -36, -39, 0, 0, 0, -104, 0, -219, 0,
250357f1050SThomas Veerman -238, 0, -144, 0, -143, 0, 0, 0,
251357f1050SThomas Veerman };
252357f1050SThomas Veerman static const short yyrindex[] = { 0,
253357f1050SThomas Veerman 0, -141, 0, 0, 0, 0, 0, 0, 0, 0,
254357f1050SThomas Veerman 0, -134, 9, 0, 0, -125, 0, 0, 0, 0,
255357f1050SThomas Veerman 0, 0, 0, -178, 0, 22, 0, 0, 0, 0,
256357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
257357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, -21, 0,
258357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 85, 0, 0,
259357f1050SThomas Veerman 0, 144, 47, 4, -10, 0, 0, 0, 0, 0,
260357f1050SThomas Veerman 0, 0, 0, 0, 0, 146, 0, 0, 0, 0,
261357f1050SThomas Veerman 18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262357f1050SThomas Veerman 0, 0, 124, 0, 0, 0, 0, 0, 0, 0,
263357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265357f1050SThomas Veerman 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
266357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0,
267357f1050SThomas Veerman };
268357f1050SThomas Veerman static const short yygindex[] = { 0,
269357f1050SThomas Veerman 0, 0, 0, 121, 133, 0, 0, 0, 0, 0,
270357f1050SThomas Veerman 0, 0, 106, 0, 0, 93, 0, 32, 84, -45,
271357f1050SThomas Veerman 0, 0, 25, 90, 0,
272357f1050SThomas Veerman };
273357f1050SThomas Veerman #define YYTABLESIZE 419
274357f1050SThomas Veerman static const short yytable[] = { 57,
275357f1050SThomas Veerman 83, 84, 90, 56, 131, 118, 91, 129, 25, 57,
276357f1050SThomas Veerman 120, 24, 33, 46, 56, 55, 56, 81, 33, 135,
277357f1050SThomas Veerman 57, 85, 57, 57, 33, 57, 55, 45, 55, 57,
278357f1050SThomas Veerman 57, 57, 57, 3, 77, 57, 57, 46, 133, 46,
279357f1050SThomas Veerman 14, 45, 33, 46, 46, 79, 15, 46, 33, 46,
280357f1050SThomas Veerman 46, 45, 57, 45, 33, 25, 43, 45, 45, 42,
281357f1050SThomas Veerman 58, 25, 136, 45, 45, 24, 68, 25, 27, 33,
282357f1050SThomas Veerman 28, 58, 33, 58, 54, 81, 69, 30, 36, 134,
283357f1050SThomas Veerman 57, 29, 43, 30, 67, 42, 30, 43, 72, 78,
284357f1050SThomas Veerman 42, 31, 76, 43, 46, 32, 42, 33, 78, 33,
285357f1050SThomas Veerman 34, 33, 33, 5, 6, 7, 86, 87, 45, 8,
286357f1050SThomas Veerman 124, 125, 25, 57, 38, 25, 39, 5, 5, 5,
287357f1050SThomas Veerman 73, 40, 78, 5, 13, 13, 13, 46, 41, 42,
288357f1050SThomas Veerman 13, 33, 43, 3, 3, 3, 44, 75, 126, 3,
289357f1050SThomas Veerman 46, 45, 17, 18, 19, 20, 21, 22, 122, 123,
290357f1050SThomas Veerman 58, 127, 132, 41, 137, 38, 49, 138, 37, 70,
291357f1050SThomas Veerman 88, 121, 92, 0, 0, 0, 0, 0, 0, 93,
292357f1050SThomas Veerman 43, 0, 0, 42, 0, 0, 0, 70, 0, 0,
293357f1050SThomas Veerman 0, 0, 0, 0, 94, 95, 96, 97, 98, 99,
294357f1050SThomas Veerman 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
295357f1050SThomas Veerman 110, 111, 112, 113, 114, 115, 116, 117, 0, 0,
296357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 68, 0, 0, 0,
297357f1050SThomas Veerman 0, 0, 0, 0, 0, 89, 51, 0, 0, 0,
298357f1050SThomas Veerman 0, 0, 52, 0, 33, 33, 50, 51, 0, 51,
299357f1050SThomas Veerman 0, 33, 33, 52, 53, 52, 57, 0, 0, 0,
300357f1050SThomas Veerman 0, 0, 57, 0, 0, 0, 0, 0, 82, 0,
301357f1050SThomas Veerman 46, 130, 128, 0, 33, 33, 46, 80, 0, 0,
302357f1050SThomas Veerman 0, 33, 33, 0, 45, 0, 0, 25, 25, 0,
303357f1050SThomas Veerman 45, 0, 0, 0, 25, 25, 0, 57, 0, 57,
304357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
305357f1050SThomas Veerman 0, 46, 93, 0, 0, 0, 0, 0, 0, 0,
306357f1050SThomas Veerman 0, 0, 0, 0, 0, 45, 0, 94, 95, 96,
307357f1050SThomas Veerman 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
308357f1050SThomas Veerman 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
309357f1050SThomas Veerman 117, 70, 0, 0, 0, 0, 0, 0, 0, 0,
310357f1050SThomas Veerman 0, 0, 0, 0, 0, 0, 70, 70, 70, 70,
311357f1050SThomas Veerman 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
312357f1050SThomas Veerman 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
313357f1050SThomas Veerman 68, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314357f1050SThomas Veerman 0, 0, 0, 0, 0, 68, 68, 68, 68, 68,
315357f1050SThomas Veerman 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
316357f1050SThomas Veerman 68, 68, 68, 68, 68, 68, 68, 68, 68,
317357f1050SThomas Veerman };
318357f1050SThomas Veerman static const short yycheck[] = { 10,
319357f1050SThomas Veerman 42, 43, 34, 34, 44, 93, 41, 44, 0, 40,
320357f1050SThomas Veerman 36, 60, 34, 10, 34, 46, 34, 63, 40, 258,
321357f1050SThomas Veerman 40, 63, 40, 34, 46, 36, 46, 10, 46, 40,
322357f1050SThomas Veerman 41, 42, 43, 256, 36, 46, 47, 34, 258, 36,
323357f1050SThomas Veerman 256, 256, 34, 40, 41, 47, 262, 262, 40, 46,
324357f1050SThomas Veerman 47, 34, 63, 36, 46, 34, 10, 40, 41, 10,
325357f1050SThomas Veerman 91, 40, 301, 46, 47, 60, 44, 46, 262, 91,
326357f1050SThomas Veerman 61, 91, 94, 91, 94, 121, 125, 256, 123, 299,
327357f1050SThomas Veerman 91, 61, 36, 262, 62, 36, 61, 41, 57, 124,
328357f1050SThomas Veerman 41, 61, 61, 47, 91, 61, 47, 61, 124, 91,
329357f1050SThomas Veerman 42, 123, 94, 259, 260, 261, 296, 297, 91, 265,
330357f1050SThomas Veerman 86, 87, 91, 124, 262, 94, 262, 259, 260, 261,
331357f1050SThomas Veerman 94, 262, 124, 265, 259, 260, 261, 124, 262, 262,
332357f1050SThomas Veerman 265, 123, 262, 259, 260, 261, 62, 10, 93, 265,
333357f1050SThomas Veerman 262, 124, 266, 267, 268, 269, 270, 271, 258, 258,
334357f1050SThomas Veerman 91, 45, 257, 10, 299, 10, 36, 301, 26, 54,
335357f1050SThomas Veerman 68, 78, 73, -1, -1, -1, -1, -1, -1, 257,
336357f1050SThomas Veerman 124, -1, -1, 124, -1, -1, -1, 93, -1, -1,
337357f1050SThomas Veerman -1, -1, -1, -1, 272, 273, 274, 275, 276, 277,
338357f1050SThomas Veerman 278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
339357f1050SThomas Veerman 288, 289, 290, 291, 292, 293, 294, 295, -1, -1,
340357f1050SThomas Veerman -1, -1, -1, -1, -1, -1, 93, -1, -1, -1,
341357f1050SThomas Veerman -1, -1, -1, -1, -1, 257, 257, -1, -1, -1,
342357f1050SThomas Veerman -1, -1, 263, -1, 256, 257, 256, 257, -1, 257,
343357f1050SThomas Veerman -1, 263, 264, 263, 264, 263, 257, -1, -1, -1,
344357f1050SThomas Veerman -1, -1, 263, -1, -1, -1, -1, -1, 300, -1,
345357f1050SThomas Veerman 257, 301, 299, -1, 256, 257, 263, 298, -1, -1,
346357f1050SThomas Veerman -1, 263, 264, -1, 257, -1, -1, 256, 257, -1,
347357f1050SThomas Veerman 263, -1, -1, -1, 263, 264, -1, 298, -1, 300,
348357f1050SThomas Veerman -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
349357f1050SThomas Veerman -1, 298, 257, -1, -1, -1, -1, -1, -1, -1,
350357f1050SThomas Veerman -1, -1, -1, -1, -1, 298, -1, 272, 273, 274,
351357f1050SThomas Veerman 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
352357f1050SThomas Veerman 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
353357f1050SThomas Veerman 295, 257, -1, -1, -1, -1, -1, -1, -1, -1,
354357f1050SThomas Veerman -1, -1, -1, -1, -1, -1, 272, 273, 274, 275,
355357f1050SThomas Veerman 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
356357f1050SThomas Veerman 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
357357f1050SThomas Veerman 257, -1, -1, -1, -1, -1, -1, -1, -1, -1,
358357f1050SThomas Veerman -1, -1, -1, -1, -1, 272, 273, 274, 275, 276,
359357f1050SThomas Veerman 277, 278, 279, 280, 281, 282, 283, 284, 285, 286,
360357f1050SThomas Veerman 287, 288, 289, 290, 291, 292, 293, 294, 295,
361357f1050SThomas Veerman };
362357f1050SThomas Veerman #define YYFINAL 1
363357f1050SThomas Veerman #ifndef YYDEBUG
364357f1050SThomas Veerman #define YYDEBUG 0
365357f1050SThomas Veerman #endif
366357f1050SThomas Veerman #define YYMAXTOKEN 301
367357f1050SThomas Veerman #if YYDEBUG
368357f1050SThomas Veerman static const char *yyname[] = {
369357f1050SThomas Veerman
370357f1050SThomas Veerman "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,
371357f1050SThomas Veerman 0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,
372357f1050SThomas Veerman 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,
373357f1050SThomas Veerman 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,
374357f1050SThomas Veerman 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,
375357f1050SThomas Veerman 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,
376357f1050SThomas Veerman 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,
377357f1050SThomas Veerman 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",
378357f1050SThomas Veerman "SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE",
379357f1050SThomas Veerman "OPT_PREFIX","OPT_YYCLASS","OPT_HEADER","OPT_EXTRA_TYPE","OPT_TABLES",
380357f1050SThomas Veerman "CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL","CCE_DIGIT","CCE_GRAPH",
381357f1050SThomas Veerman "CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE","CCE_UPPER","CCE_XDIGIT",
382357f1050SThomas Veerman "CCE_NEG_ALNUM","CCE_NEG_ALPHA","CCE_NEG_BLANK","CCE_NEG_CNTRL","CCE_NEG_DIGIT",
383357f1050SThomas Veerman "CCE_NEG_GRAPH","CCE_NEG_LOWER","CCE_NEG_PRINT","CCE_NEG_PUNCT","CCE_NEG_SPACE",
384357f1050SThomas Veerman "CCE_NEG_UPPER","CCE_NEG_XDIGIT","CCL_OP_DIFF","CCL_OP_UNION",
385357f1050SThomas Veerman "BEGIN_REPEAT_POSIX","END_REPEAT_POSIX","BEGIN_REPEAT_FLEX","END_REPEAT_FLEX",
386357f1050SThomas Veerman };
387357f1050SThomas Veerman static const char *yyrule[] = {
388357f1050SThomas Veerman "$accept : goal",
389357f1050SThomas Veerman "goal : initlex sect1 sect1end sect2 initforrule",
390357f1050SThomas Veerman "initlex :",
391357f1050SThomas Veerman "sect1 : sect1 startconddecl namelist1",
392357f1050SThomas Veerman "sect1 : sect1 options",
393357f1050SThomas Veerman "sect1 :",
394357f1050SThomas Veerman "sect1 : error",
395357f1050SThomas Veerman "sect1end : SECTEND",
396357f1050SThomas Veerman "startconddecl : SCDECL",
397357f1050SThomas Veerman "startconddecl : XSCDECL",
398357f1050SThomas Veerman "namelist1 : namelist1 NAME",
399357f1050SThomas Veerman "namelist1 : NAME",
400357f1050SThomas Veerman "namelist1 : error",
401357f1050SThomas Veerman "options : OPTION_OP optionlist",
402357f1050SThomas Veerman "optionlist : optionlist option",
403357f1050SThomas Veerman "optionlist :",
404357f1050SThomas Veerman "option : OPT_OUTFILE '=' NAME",
405357f1050SThomas Veerman "option : OPT_EXTRA_TYPE '=' NAME",
406357f1050SThomas Veerman "option : OPT_PREFIX '=' NAME",
407357f1050SThomas Veerman "option : OPT_YYCLASS '=' NAME",
408357f1050SThomas Veerman "option : OPT_HEADER '=' NAME",
409357f1050SThomas Veerman "option : OPT_TABLES '=' NAME",
410357f1050SThomas Veerman "sect2 : sect2 scon initforrule flexrule '\\n'",
411357f1050SThomas Veerman "sect2 : sect2 scon '{' sect2 '}'",
412357f1050SThomas Veerman "sect2 :",
413357f1050SThomas Veerman "initforrule :",
414357f1050SThomas Veerman "flexrule : '^' rule",
415357f1050SThomas Veerman "flexrule : rule",
416357f1050SThomas Veerman "flexrule : EOF_OP",
417357f1050SThomas Veerman "flexrule : error",
418357f1050SThomas Veerman "scon_stk_ptr :",
419357f1050SThomas Veerman "scon : '<' scon_stk_ptr namelist2 '>'",
420357f1050SThomas Veerman "scon : '<' '*' '>'",
421357f1050SThomas Veerman "scon :",
422357f1050SThomas Veerman "namelist2 : namelist2 ',' sconname",
423357f1050SThomas Veerman "namelist2 : sconname",
424357f1050SThomas Veerman "namelist2 : error",
425357f1050SThomas Veerman "sconname : NAME",
426357f1050SThomas Veerman "rule : re2 re",
427357f1050SThomas Veerman "rule : re2 re '$'",
428357f1050SThomas Veerman "rule : re '$'",
429357f1050SThomas Veerman "rule : re",
430357f1050SThomas Veerman "re : re '|' series",
431357f1050SThomas Veerman "re : series",
432357f1050SThomas Veerman "re2 : re '/'",
433357f1050SThomas Veerman "series : series singleton",
434357f1050SThomas Veerman "series : singleton",
435357f1050SThomas Veerman "series : series BEGIN_REPEAT_POSIX NUMBER ',' NUMBER END_REPEAT_POSIX",
436357f1050SThomas Veerman "series : series BEGIN_REPEAT_POSIX NUMBER ',' END_REPEAT_POSIX",
437357f1050SThomas Veerman "series : series BEGIN_REPEAT_POSIX NUMBER END_REPEAT_POSIX",
438357f1050SThomas Veerman "singleton : singleton '*'",
439357f1050SThomas Veerman "singleton : singleton '+'",
440357f1050SThomas Veerman "singleton : singleton '?'",
441357f1050SThomas Veerman "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' NUMBER END_REPEAT_FLEX",
442357f1050SThomas Veerman "singleton : singleton BEGIN_REPEAT_FLEX NUMBER ',' END_REPEAT_FLEX",
443357f1050SThomas Veerman "singleton : singleton BEGIN_REPEAT_FLEX NUMBER END_REPEAT_FLEX",
444357f1050SThomas Veerman "singleton : '.'",
445357f1050SThomas Veerman "singleton : fullccl",
446357f1050SThomas Veerman "singleton : PREVCCL",
447357f1050SThomas Veerman "singleton : '\"' string '\"'",
448357f1050SThomas Veerman "singleton : '(' re ')'",
449357f1050SThomas Veerman "singleton : CHAR",
450357f1050SThomas Veerman "fullccl : fullccl CCL_OP_DIFF braceccl",
451357f1050SThomas Veerman "fullccl : fullccl CCL_OP_UNION braceccl",
452357f1050SThomas Veerman "fullccl : braceccl",
453357f1050SThomas Veerman "braceccl : '[' ccl ']'",
454357f1050SThomas Veerman "braceccl : '[' '^' ccl ']'",
455357f1050SThomas Veerman "ccl : ccl CHAR '-' CHAR",
456357f1050SThomas Veerman "ccl : ccl CHAR",
457357f1050SThomas Veerman "ccl : ccl ccl_expr",
458357f1050SThomas Veerman "ccl :",
459357f1050SThomas Veerman "ccl_expr : CCE_ALNUM",
460357f1050SThomas Veerman "ccl_expr : CCE_ALPHA",
461357f1050SThomas Veerman "ccl_expr : CCE_BLANK",
462357f1050SThomas Veerman "ccl_expr : CCE_CNTRL",
463357f1050SThomas Veerman "ccl_expr : CCE_DIGIT",
464357f1050SThomas Veerman "ccl_expr : CCE_GRAPH",
465357f1050SThomas Veerman "ccl_expr : CCE_LOWER",
466357f1050SThomas Veerman "ccl_expr : CCE_PRINT",
467357f1050SThomas Veerman "ccl_expr : CCE_PUNCT",
468357f1050SThomas Veerman "ccl_expr : CCE_SPACE",
469357f1050SThomas Veerman "ccl_expr : CCE_XDIGIT",
470357f1050SThomas Veerman "ccl_expr : CCE_UPPER",
471357f1050SThomas Veerman "ccl_expr : CCE_NEG_ALNUM",
472357f1050SThomas Veerman "ccl_expr : CCE_NEG_ALPHA",
473357f1050SThomas Veerman "ccl_expr : CCE_NEG_BLANK",
474357f1050SThomas Veerman "ccl_expr : CCE_NEG_CNTRL",
475357f1050SThomas Veerman "ccl_expr : CCE_NEG_DIGIT",
476357f1050SThomas Veerman "ccl_expr : CCE_NEG_GRAPH",
477357f1050SThomas Veerman "ccl_expr : CCE_NEG_PRINT",
478357f1050SThomas Veerman "ccl_expr : CCE_NEG_PUNCT",
479357f1050SThomas Veerman "ccl_expr : CCE_NEG_SPACE",
480357f1050SThomas Veerman "ccl_expr : CCE_NEG_XDIGIT",
481357f1050SThomas Veerman "ccl_expr : CCE_NEG_LOWER",
482357f1050SThomas Veerman "ccl_expr : CCE_NEG_UPPER",
483357f1050SThomas Veerman "string : string CHAR",
484357f1050SThomas Veerman "string :",
485357f1050SThomas Veerman
486357f1050SThomas Veerman };
487357f1050SThomas Veerman #endif
488357f1050SThomas Veerman
48984d9c625SLionel Sambuc int yydebug;
49084d9c625SLionel Sambuc int yynerrs;
49184d9c625SLionel Sambuc
49284d9c625SLionel Sambuc int yyerrflag;
49384d9c625SLionel Sambuc int yychar;
49484d9c625SLionel Sambuc YYSTYPE yyval;
49584d9c625SLionel Sambuc YYSTYPE yylval;
496357f1050SThomas Veerman
497357f1050SThomas Veerman /* define the initial stack-sizes */
498357f1050SThomas Veerman #ifdef YYSTACKSIZE
499357f1050SThomas Veerman #undef YYMAXDEPTH
500357f1050SThomas Veerman #define YYMAXDEPTH YYSTACKSIZE
501357f1050SThomas Veerman #else
502357f1050SThomas Veerman #ifdef YYMAXDEPTH
503357f1050SThomas Veerman #define YYSTACKSIZE YYMAXDEPTH
504357f1050SThomas Veerman #else
505357f1050SThomas Veerman #define YYSTACKSIZE 500
506357f1050SThomas Veerman #define YYMAXDEPTH 500
507357f1050SThomas Veerman #endif
508357f1050SThomas Veerman #endif
509357f1050SThomas Veerman
510357f1050SThomas Veerman #define YYINITSTACKSIZE 500
511357f1050SThomas Veerman
51284d9c625SLionel Sambuc typedef struct {
51384d9c625SLionel Sambuc unsigned stacksize;
51484d9c625SLionel Sambuc short *s_base;
51584d9c625SLionel Sambuc short *s_mark;
51684d9c625SLionel Sambuc short *s_last;
51784d9c625SLionel Sambuc YYSTYPE *l_base;
51884d9c625SLionel Sambuc YYSTYPE *l_mark;
51984d9c625SLionel Sambuc } YYSTACKDATA;
52084d9c625SLionel Sambuc /* variables for the parser stack */
52184d9c625SLionel Sambuc static YYSTACKDATA yystack;
522357f1050SThomas Veerman
523357f1050SThomas Veerman
524357f1050SThomas Veerman /* build_eof_action - build the "<<EOF>>" action for the active start
525357f1050SThomas Veerman * conditions
526357f1050SThomas Veerman */
527357f1050SThomas Veerman
build_eof_action()528357f1050SThomas Veerman void build_eof_action()
529357f1050SThomas Veerman {
530357f1050SThomas Veerman register int i;
531357f1050SThomas Veerman char action_text[MAXLINE];
532357f1050SThomas Veerman
533357f1050SThomas Veerman for ( i = 1; i <= scon_stk_ptr; ++i )
534357f1050SThomas Veerman {
535357f1050SThomas Veerman if ( sceof[scon_stk[i]] )
536357f1050SThomas Veerman format_pinpoint_message(
537357f1050SThomas Veerman "multiple <<EOF>> rules for start condition %s",
538357f1050SThomas Veerman scname[scon_stk[i]] );
539357f1050SThomas Veerman
540357f1050SThomas Veerman else
541357f1050SThomas Veerman {
542357f1050SThomas Veerman sceof[scon_stk[i]] = true;
54384d9c625SLionel Sambuc
54484d9c625SLionel Sambuc if (previous_continued_action /* && previous action was regular */)
54584d9c625SLionel Sambuc add_action("YY_RULE_SETUP\n");
54684d9c625SLionel Sambuc
547357f1050SThomas Veerman snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n",
548357f1050SThomas Veerman scname[scon_stk[i]] );
549357f1050SThomas Veerman add_action( action_text );
550357f1050SThomas Veerman }
551357f1050SThomas Veerman }
552357f1050SThomas Veerman
553357f1050SThomas Veerman line_directive_out( (FILE *) 0, 1 );
554357f1050SThomas Veerman
555357f1050SThomas Veerman /* This isn't a normal rule after all - don't count it as
556357f1050SThomas Veerman * such, so we don't have any holes in the rule numbering
557357f1050SThomas Veerman * (which make generating "rule can never match" warnings
558357f1050SThomas Veerman * more difficult.
559357f1050SThomas Veerman */
560357f1050SThomas Veerman --num_rules;
561357f1050SThomas Veerman ++num_eof_rules;
562357f1050SThomas Veerman }
563357f1050SThomas Veerman
564357f1050SThomas Veerman
565357f1050SThomas Veerman /* format_synerr - write out formatted syntax error */
566357f1050SThomas Veerman
format_synerr(msg,arg)567357f1050SThomas Veerman void format_synerr( msg, arg )
568357f1050SThomas Veerman const char *msg, arg[];
569357f1050SThomas Veerman {
570357f1050SThomas Veerman char errmsg[MAXLINE];
571357f1050SThomas Veerman
572357f1050SThomas Veerman (void) snprintf( errmsg, sizeof(errmsg), msg, arg );
573357f1050SThomas Veerman synerr( errmsg );
574357f1050SThomas Veerman }
575357f1050SThomas Veerman
576357f1050SThomas Veerman
577357f1050SThomas Veerman /* synerr - report a syntax error */
578357f1050SThomas Veerman
synerr(str)579357f1050SThomas Veerman void synerr( str )
580357f1050SThomas Veerman const char *str;
581357f1050SThomas Veerman {
582357f1050SThomas Veerman syntaxerror = true;
583357f1050SThomas Veerman pinpoint_message( str );
584357f1050SThomas Veerman }
585357f1050SThomas Veerman
586357f1050SThomas Veerman
587357f1050SThomas Veerman /* format_warn - write out formatted warning */
588357f1050SThomas Veerman
format_warn(msg,arg)589357f1050SThomas Veerman void format_warn( msg, arg )
590357f1050SThomas Veerman const char *msg, arg[];
591357f1050SThomas Veerman {
592357f1050SThomas Veerman char warn_msg[MAXLINE];
593357f1050SThomas Veerman
594357f1050SThomas Veerman snprintf( warn_msg, sizeof(warn_msg), msg, arg );
595357f1050SThomas Veerman lwarn( warn_msg );
596357f1050SThomas Veerman }
597357f1050SThomas Veerman
598357f1050SThomas Veerman
599357f1050SThomas Veerman /* lwarn - report a warning, unless -w was given */
600357f1050SThomas Veerman
lwarn(str)601357f1050SThomas Veerman void lwarn( str )
602357f1050SThomas Veerman const char *str;
603357f1050SThomas Veerman {
604357f1050SThomas Veerman line_warning( str, linenum );
605357f1050SThomas Veerman }
606357f1050SThomas Veerman
607357f1050SThomas Veerman /* format_pinpoint_message - write out a message formatted with one string,
608357f1050SThomas Veerman * pinpointing its location
609357f1050SThomas Veerman */
610357f1050SThomas Veerman
format_pinpoint_message(msg,arg)611357f1050SThomas Veerman void format_pinpoint_message( msg, arg )
612357f1050SThomas Veerman const char *msg, arg[];
613357f1050SThomas Veerman {
614357f1050SThomas Veerman char errmsg[MAXLINE];
615357f1050SThomas Veerman
616357f1050SThomas Veerman snprintf( errmsg, sizeof(errmsg), msg, arg );
617357f1050SThomas Veerman pinpoint_message( errmsg );
618357f1050SThomas Veerman }
619357f1050SThomas Veerman
620357f1050SThomas Veerman
621357f1050SThomas Veerman /* pinpoint_message - write out a message, pinpointing its location */
622357f1050SThomas Veerman
pinpoint_message(str)623357f1050SThomas Veerman void pinpoint_message( str )
624357f1050SThomas Veerman const char *str;
625357f1050SThomas Veerman {
626357f1050SThomas Veerman line_pinpoint( str, linenum );
627357f1050SThomas Veerman }
628357f1050SThomas Veerman
629357f1050SThomas Veerman
630357f1050SThomas Veerman /* line_warning - report a warning at a given line, unless -w was given */
631357f1050SThomas Veerman
line_warning(str,line)632357f1050SThomas Veerman void line_warning( str, line )
633357f1050SThomas Veerman const char *str;
634357f1050SThomas Veerman int line;
635357f1050SThomas Veerman {
636357f1050SThomas Veerman char warning[MAXLINE];
637357f1050SThomas Veerman
638357f1050SThomas Veerman if ( ! nowarn )
639357f1050SThomas Veerman {
640357f1050SThomas Veerman snprintf( warning, sizeof(warning), "warning, %s", str );
641357f1050SThomas Veerman line_pinpoint( warning, line );
642357f1050SThomas Veerman }
643357f1050SThomas Veerman }
644357f1050SThomas Veerman
645357f1050SThomas Veerman
646357f1050SThomas Veerman /* line_pinpoint - write out a message, pinpointing it at the given line */
647357f1050SThomas Veerman
line_pinpoint(str,line)648357f1050SThomas Veerman void line_pinpoint( str, line )
649357f1050SThomas Veerman const char *str;
650357f1050SThomas Veerman int line;
651357f1050SThomas Veerman {
652357f1050SThomas Veerman fprintf( stderr, "%s:%d: %s\n", infilename, line, str );
653357f1050SThomas Veerman }
654357f1050SThomas Veerman
655357f1050SThomas Veerman
656357f1050SThomas Veerman /* yyerror - eat up an error message from the parser;
657357f1050SThomas Veerman * currently, messages are ignore
658357f1050SThomas Veerman */
659357f1050SThomas Veerman
yyerror(msg)660357f1050SThomas Veerman void yyerror( msg )
661357f1050SThomas Veerman const char *msg;
662357f1050SThomas Veerman {
663357f1050SThomas Veerman }
66484d9c625SLionel Sambuc
66584d9c625SLionel Sambuc #if YYDEBUG
66684d9c625SLionel Sambuc #include <stdio.h> /* needed for printf */
66784d9c625SLionel Sambuc #endif
66884d9c625SLionel Sambuc
66984d9c625SLionel Sambuc #include <stdlib.h> /* needed for malloc, etc */
67084d9c625SLionel Sambuc #include <string.h> /* needed for memset */
67184d9c625SLionel Sambuc
672357f1050SThomas Veerman /* allocate initial stack or double stack size, up to YYMAXDEPTH */
yygrowstack(YYSTACKDATA * data)67384d9c625SLionel Sambuc static int yygrowstack(YYSTACKDATA *data)
674357f1050SThomas Veerman {
675357f1050SThomas Veerman int i;
676357f1050SThomas Veerman unsigned newsize;
677357f1050SThomas Veerman short *newss;
678357f1050SThomas Veerman YYSTYPE *newvs;
679357f1050SThomas Veerman
68084d9c625SLionel Sambuc if ((newsize = data->stacksize) == 0)
681357f1050SThomas Veerman newsize = YYINITSTACKSIZE;
682357f1050SThomas Veerman else if (newsize >= YYMAXDEPTH)
683357f1050SThomas Veerman return -1;
684357f1050SThomas Veerman else if ((newsize *= 2) > YYMAXDEPTH)
685357f1050SThomas Veerman newsize = YYMAXDEPTH;
686357f1050SThomas Veerman
68784d9c625SLionel Sambuc i = (int) (data->s_mark - data->s_base);
68884d9c625SLionel Sambuc newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
689357f1050SThomas Veerman if (newss == 0)
690357f1050SThomas Veerman return -1;
691357f1050SThomas Veerman
69284d9c625SLionel Sambuc data->s_base = newss;
69384d9c625SLionel Sambuc data->s_mark = newss + i;
69484d9c625SLionel Sambuc
69584d9c625SLionel Sambuc newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
696357f1050SThomas Veerman if (newvs == 0)
697357f1050SThomas Veerman return -1;
698357f1050SThomas Veerman
69984d9c625SLionel Sambuc data->l_base = newvs;
70084d9c625SLionel Sambuc data->l_mark = newvs + i;
70184d9c625SLionel Sambuc
70284d9c625SLionel Sambuc data->stacksize = newsize;
70384d9c625SLionel Sambuc data->s_last = data->s_base + newsize - 1;
704357f1050SThomas Veerman return 0;
705357f1050SThomas Veerman }
706357f1050SThomas Veerman
70784d9c625SLionel Sambuc #if YYPURE || defined(YY_NO_LEAKS)
yyfreestack(YYSTACKDATA * data)70884d9c625SLionel Sambuc static void yyfreestack(YYSTACKDATA *data)
70984d9c625SLionel Sambuc {
71084d9c625SLionel Sambuc free(data->s_base);
71184d9c625SLionel Sambuc free(data->l_base);
71284d9c625SLionel Sambuc memset(data, 0, sizeof(*data));
71384d9c625SLionel Sambuc }
71484d9c625SLionel Sambuc #else
71584d9c625SLionel Sambuc #define yyfreestack(data) /* nothing */
71684d9c625SLionel Sambuc #endif
71784d9c625SLionel Sambuc
718357f1050SThomas Veerman #define YYABORT goto yyabort
719357f1050SThomas Veerman #define YYREJECT goto yyabort
720357f1050SThomas Veerman #define YYACCEPT goto yyaccept
721357f1050SThomas Veerman #define YYERROR goto yyerrlab
722357f1050SThomas Veerman
723357f1050SThomas Veerman int
YYPARSE_DECL()724357f1050SThomas Veerman YYPARSE_DECL()
725357f1050SThomas Veerman {
726357f1050SThomas Veerman int yym, yyn, yystate;
727357f1050SThomas Veerman #if YYDEBUG
728357f1050SThomas Veerman const char *yys;
729357f1050SThomas Veerman
730357f1050SThomas Veerman if ((yys = getenv("YYDEBUG")) != 0)
731357f1050SThomas Veerman {
732357f1050SThomas Veerman yyn = *yys;
733357f1050SThomas Veerman if (yyn >= '0' && yyn <= '9')
734357f1050SThomas Veerman yydebug = yyn - '0';
735357f1050SThomas Veerman }
736357f1050SThomas Veerman #endif
737357f1050SThomas Veerman
738357f1050SThomas Veerman yynerrs = 0;
739357f1050SThomas Veerman yyerrflag = 0;
740357f1050SThomas Veerman yychar = YYEMPTY;
741357f1050SThomas Veerman yystate = 0;
742357f1050SThomas Veerman
74384d9c625SLionel Sambuc #if YYPURE
74484d9c625SLionel Sambuc memset(&yystack, 0, sizeof(yystack));
74584d9c625SLionel Sambuc #endif
74684d9c625SLionel Sambuc
74784d9c625SLionel Sambuc if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
74884d9c625SLionel Sambuc yystack.s_mark = yystack.s_base;
74984d9c625SLionel Sambuc yystack.l_mark = yystack.l_base;
750357f1050SThomas Veerman yystate = 0;
75184d9c625SLionel Sambuc *yystack.s_mark = 0;
752357f1050SThomas Veerman
753357f1050SThomas Veerman yyloop:
754357f1050SThomas Veerman if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
755357f1050SThomas Veerman if (yychar < 0)
756357f1050SThomas Veerman {
75784d9c625SLionel Sambuc if ((yychar = YYLEX) < 0) yychar = 0;
758357f1050SThomas Veerman #if YYDEBUG
759357f1050SThomas Veerman if (yydebug)
760357f1050SThomas Veerman {
761357f1050SThomas Veerman yys = 0;
762357f1050SThomas Veerman if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
763357f1050SThomas Veerman if (!yys) yys = "illegal-symbol";
764357f1050SThomas Veerman printf("%sdebug: state %d, reading %d (%s)\n",
765357f1050SThomas Veerman YYPREFIX, yystate, yychar, yys);
766357f1050SThomas Veerman }
767357f1050SThomas Veerman #endif
768357f1050SThomas Veerman }
769357f1050SThomas Veerman if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
770357f1050SThomas Veerman yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
771357f1050SThomas Veerman {
772357f1050SThomas Veerman #if YYDEBUG
773357f1050SThomas Veerman if (yydebug)
774357f1050SThomas Veerman printf("%sdebug: state %d, shifting to state %d\n",
775357f1050SThomas Veerman YYPREFIX, yystate, yytable[yyn]);
776357f1050SThomas Veerman #endif
77784d9c625SLionel Sambuc if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
778357f1050SThomas Veerman {
779357f1050SThomas Veerman goto yyoverflow;
780357f1050SThomas Veerman }
781357f1050SThomas Veerman yystate = yytable[yyn];
78284d9c625SLionel Sambuc *++yystack.s_mark = yytable[yyn];
78384d9c625SLionel Sambuc *++yystack.l_mark = yylval;
784357f1050SThomas Veerman yychar = YYEMPTY;
785357f1050SThomas Veerman if (yyerrflag > 0) --yyerrflag;
786357f1050SThomas Veerman goto yyloop;
787357f1050SThomas Veerman }
788357f1050SThomas Veerman if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
789357f1050SThomas Veerman yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
790357f1050SThomas Veerman {
791357f1050SThomas Veerman yyn = yytable[yyn];
792357f1050SThomas Veerman goto yyreduce;
793357f1050SThomas Veerman }
794357f1050SThomas Veerman if (yyerrflag) goto yyinrecovery;
795357f1050SThomas Veerman
796357f1050SThomas Veerman yyerror("syntax error");
797357f1050SThomas Veerman
798357f1050SThomas Veerman goto yyerrlab;
799357f1050SThomas Veerman
800357f1050SThomas Veerman yyerrlab:
801357f1050SThomas Veerman ++yynerrs;
802357f1050SThomas Veerman
803357f1050SThomas Veerman yyinrecovery:
804357f1050SThomas Veerman if (yyerrflag < 3)
805357f1050SThomas Veerman {
806357f1050SThomas Veerman yyerrflag = 3;
807357f1050SThomas Veerman for (;;)
808357f1050SThomas Veerman {
80984d9c625SLionel Sambuc if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
810357f1050SThomas Veerman yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
811357f1050SThomas Veerman {
812357f1050SThomas Veerman #if YYDEBUG
813357f1050SThomas Veerman if (yydebug)
814357f1050SThomas Veerman printf("%sdebug: state %d, error recovery shifting\
81584d9c625SLionel Sambuc to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
816357f1050SThomas Veerman #endif
81784d9c625SLionel Sambuc if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
818357f1050SThomas Veerman {
819357f1050SThomas Veerman goto yyoverflow;
820357f1050SThomas Veerman }
821357f1050SThomas Veerman yystate = yytable[yyn];
82284d9c625SLionel Sambuc *++yystack.s_mark = yytable[yyn];
82384d9c625SLionel Sambuc *++yystack.l_mark = yylval;
824357f1050SThomas Veerman goto yyloop;
825357f1050SThomas Veerman }
826357f1050SThomas Veerman else
827357f1050SThomas Veerman {
828357f1050SThomas Veerman #if YYDEBUG
829357f1050SThomas Veerman if (yydebug)
830357f1050SThomas Veerman printf("%sdebug: error recovery discarding state %d\n",
83184d9c625SLionel Sambuc YYPREFIX, *yystack.s_mark);
832357f1050SThomas Veerman #endif
83384d9c625SLionel Sambuc if (yystack.s_mark <= yystack.s_base) goto yyabort;
83484d9c625SLionel Sambuc --yystack.s_mark;
83584d9c625SLionel Sambuc --yystack.l_mark;
836357f1050SThomas Veerman }
837357f1050SThomas Veerman }
838357f1050SThomas Veerman }
839357f1050SThomas Veerman else
840357f1050SThomas Veerman {
841357f1050SThomas Veerman if (yychar == 0) goto yyabort;
842357f1050SThomas Veerman #if YYDEBUG
843357f1050SThomas Veerman if (yydebug)
844357f1050SThomas Veerman {
845357f1050SThomas Veerman yys = 0;
846357f1050SThomas Veerman if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
847357f1050SThomas Veerman if (!yys) yys = "illegal-symbol";
848357f1050SThomas Veerman printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
849357f1050SThomas Veerman YYPREFIX, yystate, yychar, yys);
850357f1050SThomas Veerman }
851357f1050SThomas Veerman #endif
852357f1050SThomas Veerman yychar = YYEMPTY;
853357f1050SThomas Veerman goto yyloop;
854357f1050SThomas Veerman }
855357f1050SThomas Veerman
856357f1050SThomas Veerman yyreduce:
857357f1050SThomas Veerman #if YYDEBUG
858357f1050SThomas Veerman if (yydebug)
859357f1050SThomas Veerman printf("%sdebug: state %d, reducing by rule %d (%s)\n",
860357f1050SThomas Veerman YYPREFIX, yystate, yyn, yyrule[yyn]);
861357f1050SThomas Veerman #endif
862357f1050SThomas Veerman yym = yylen[yyn];
863357f1050SThomas Veerman if (yym)
86484d9c625SLionel Sambuc yyval = yystack.l_mark[1-yym];
865357f1050SThomas Veerman else
866357f1050SThomas Veerman memset(&yyval, 0, sizeof yyval);
867357f1050SThomas Veerman switch (yyn)
868357f1050SThomas Veerman {
869357f1050SThomas Veerman case 1:
870357f1050SThomas Veerman { /* add default rule */
871357f1050SThomas Veerman int def_rule;
872357f1050SThomas Veerman
873357f1050SThomas Veerman pat = cclinit();
874357f1050SThomas Veerman cclnegate( pat );
875357f1050SThomas Veerman
876357f1050SThomas Veerman def_rule = mkstate( -pat );
877357f1050SThomas Veerman
878357f1050SThomas Veerman /* Remember the number of the default rule so we
879357f1050SThomas Veerman * don't generate "can't match" warnings for it.
880357f1050SThomas Veerman */
881357f1050SThomas Veerman default_rule = num_rules;
882357f1050SThomas Veerman
883357f1050SThomas Veerman finish_rule( def_rule, false, 0, 0, 0);
884357f1050SThomas Veerman
885357f1050SThomas Veerman for ( i = 1; i <= lastsc; ++i )
886357f1050SThomas Veerman scset[i] = mkbranch( scset[i], def_rule );
887357f1050SThomas Veerman
888357f1050SThomas Veerman if ( spprdflt )
889357f1050SThomas Veerman add_action(
890357f1050SThomas Veerman "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
891357f1050SThomas Veerman else
892357f1050SThomas Veerman add_action( "ECHO" );
893357f1050SThomas Veerman
894357f1050SThomas Veerman add_action( ";\n\tYY_BREAK\n" );
895357f1050SThomas Veerman }
896357f1050SThomas Veerman break;
897357f1050SThomas Veerman case 2:
898357f1050SThomas Veerman { /* initialize for processing rules */
899357f1050SThomas Veerman
900357f1050SThomas Veerman /* Create default DFA start condition. */
901357f1050SThomas Veerman scinstal( "INITIAL", false );
902357f1050SThomas Veerman }
903357f1050SThomas Veerman break;
904357f1050SThomas Veerman case 6:
905357f1050SThomas Veerman { synerr( _("unknown error processing section 1") ); }
906357f1050SThomas Veerman break;
907357f1050SThomas Veerman case 7:
908357f1050SThomas Veerman {
909357f1050SThomas Veerman check_options();
910357f1050SThomas Veerman scon_stk = allocate_integer_array( lastsc + 1 );
911357f1050SThomas Veerman scon_stk_ptr = 0;
912357f1050SThomas Veerman }
913357f1050SThomas Veerman break;
914357f1050SThomas Veerman case 8:
915357f1050SThomas Veerman { xcluflg = false; }
916357f1050SThomas Veerman break;
917357f1050SThomas Veerman case 9:
918357f1050SThomas Veerman { xcluflg = true; }
919357f1050SThomas Veerman break;
920357f1050SThomas Veerman case 10:
921357f1050SThomas Veerman { scinstal( nmstr, xcluflg ); }
922357f1050SThomas Veerman break;
923357f1050SThomas Veerman case 11:
924357f1050SThomas Veerman { scinstal( nmstr, xcluflg ); }
925357f1050SThomas Veerman break;
926357f1050SThomas Veerman case 12:
927357f1050SThomas Veerman { synerr( _("bad start condition list") ); }
928357f1050SThomas Veerman break;
929357f1050SThomas Veerman case 16:
930357f1050SThomas Veerman {
931357f1050SThomas Veerman outfilename = copy_string( nmstr );
932357f1050SThomas Veerman did_outfilename = 1;
933357f1050SThomas Veerman }
934357f1050SThomas Veerman break;
935357f1050SThomas Veerman case 17:
936357f1050SThomas Veerman { extra_type = copy_string( nmstr ); }
937357f1050SThomas Veerman break;
938357f1050SThomas Veerman case 18:
939357f1050SThomas Veerman { prefix = copy_string( nmstr ); }
940357f1050SThomas Veerman break;
941357f1050SThomas Veerman case 19:
942357f1050SThomas Veerman { yyclass = copy_string( nmstr ); }
943357f1050SThomas Veerman break;
944357f1050SThomas Veerman case 20:
945357f1050SThomas Veerman { headerfilename = copy_string( nmstr ); }
946357f1050SThomas Veerman break;
947357f1050SThomas Veerman case 21:
948357f1050SThomas Veerman { tablesext = true; tablesfilename = copy_string( nmstr ); }
949357f1050SThomas Veerman break;
950357f1050SThomas Veerman case 22:
95184d9c625SLionel Sambuc { scon_stk_ptr = yystack.l_mark[-3]; }
952357f1050SThomas Veerman break;
953357f1050SThomas Veerman case 23:
95484d9c625SLionel Sambuc { scon_stk_ptr = yystack.l_mark[-3]; }
955357f1050SThomas Veerman break;
956357f1050SThomas Veerman case 25:
957357f1050SThomas Veerman {
958357f1050SThomas Veerman /* Initialize for a parse of one rule. */
959357f1050SThomas Veerman trlcontxt = variable_trail_rule = varlength = false;
960357f1050SThomas Veerman trailcnt = headcnt = rulelen = 0;
961357f1050SThomas Veerman current_state_type = STATE_NORMAL;
962357f1050SThomas Veerman previous_continued_action = continued_action;
963357f1050SThomas Veerman in_rule = true;
964357f1050SThomas Veerman
965357f1050SThomas Veerman new_rule();
966357f1050SThomas Veerman }
967357f1050SThomas Veerman break;
968357f1050SThomas Veerman case 26:
969357f1050SThomas Veerman {
97084d9c625SLionel Sambuc pat = yystack.l_mark[0];
971357f1050SThomas Veerman finish_rule( pat, variable_trail_rule,
972357f1050SThomas Veerman headcnt, trailcnt , previous_continued_action);
973357f1050SThomas Veerman
974357f1050SThomas Veerman if ( scon_stk_ptr > 0 )
975357f1050SThomas Veerman {
976357f1050SThomas Veerman for ( i = 1; i <= scon_stk_ptr; ++i )
977357f1050SThomas Veerman scbol[scon_stk[i]] =
978357f1050SThomas Veerman mkbranch( scbol[scon_stk[i]],
979357f1050SThomas Veerman pat );
980357f1050SThomas Veerman }
981357f1050SThomas Veerman
982357f1050SThomas Veerman else
983357f1050SThomas Veerman {
984357f1050SThomas Veerman /* Add to all non-exclusive start conditions,
985357f1050SThomas Veerman * including the default (0) start condition.
986357f1050SThomas Veerman */
987357f1050SThomas Veerman
988357f1050SThomas Veerman for ( i = 1; i <= lastsc; ++i )
989357f1050SThomas Veerman if ( ! scxclu[i] )
990357f1050SThomas Veerman scbol[i] = mkbranch( scbol[i],
991357f1050SThomas Veerman pat );
992357f1050SThomas Veerman }
993357f1050SThomas Veerman
994357f1050SThomas Veerman if ( ! bol_needed )
995357f1050SThomas Veerman {
996357f1050SThomas Veerman bol_needed = true;
997357f1050SThomas Veerman
998357f1050SThomas Veerman if ( performance_report > 1 )
999357f1050SThomas Veerman pinpoint_message(
1000357f1050SThomas Veerman "'^' operator results in sub-optimal performance" );
1001357f1050SThomas Veerman }
1002357f1050SThomas Veerman }
1003357f1050SThomas Veerman break;
1004357f1050SThomas Veerman case 27:
1005357f1050SThomas Veerman {
100684d9c625SLionel Sambuc pat = yystack.l_mark[0];
1007357f1050SThomas Veerman finish_rule( pat, variable_trail_rule,
1008357f1050SThomas Veerman headcnt, trailcnt , previous_continued_action);
1009357f1050SThomas Veerman
1010357f1050SThomas Veerman if ( scon_stk_ptr > 0 )
1011357f1050SThomas Veerman {
1012357f1050SThomas Veerman for ( i = 1; i <= scon_stk_ptr; ++i )
1013357f1050SThomas Veerman scset[scon_stk[i]] =
1014357f1050SThomas Veerman mkbranch( scset[scon_stk[i]],
1015357f1050SThomas Veerman pat );
1016357f1050SThomas Veerman }
1017357f1050SThomas Veerman
1018357f1050SThomas Veerman else
1019357f1050SThomas Veerman {
1020357f1050SThomas Veerman for ( i = 1; i <= lastsc; ++i )
1021357f1050SThomas Veerman if ( ! scxclu[i] )
1022357f1050SThomas Veerman scset[i] =
1023357f1050SThomas Veerman mkbranch( scset[i],
1024357f1050SThomas Veerman pat );
1025357f1050SThomas Veerman }
1026357f1050SThomas Veerman }
1027357f1050SThomas Veerman break;
1028357f1050SThomas Veerman case 28:
1029357f1050SThomas Veerman {
1030357f1050SThomas Veerman if ( scon_stk_ptr > 0 )
1031357f1050SThomas Veerman build_eof_action();
1032357f1050SThomas Veerman
1033357f1050SThomas Veerman else
1034357f1050SThomas Veerman {
1035357f1050SThomas Veerman /* This EOF applies to all start conditions
1036357f1050SThomas Veerman * which don't already have EOF actions.
1037357f1050SThomas Veerman */
1038357f1050SThomas Veerman for ( i = 1; i <= lastsc; ++i )
1039357f1050SThomas Veerman if ( ! sceof[i] )
1040357f1050SThomas Veerman scon_stk[++scon_stk_ptr] = i;
1041357f1050SThomas Veerman
1042357f1050SThomas Veerman if ( scon_stk_ptr == 0 )
1043357f1050SThomas Veerman lwarn(
1044357f1050SThomas Veerman "all start conditions already have <<EOF>> rules" );
1045357f1050SThomas Veerman
1046357f1050SThomas Veerman else
1047357f1050SThomas Veerman build_eof_action();
1048357f1050SThomas Veerman }
1049357f1050SThomas Veerman }
1050357f1050SThomas Veerman break;
1051357f1050SThomas Veerman case 29:
1052357f1050SThomas Veerman { synerr( _("unrecognized rule") ); }
1053357f1050SThomas Veerman break;
1054357f1050SThomas Veerman case 30:
1055357f1050SThomas Veerman { yyval = scon_stk_ptr; }
1056357f1050SThomas Veerman break;
1057357f1050SThomas Veerman case 31:
105884d9c625SLionel Sambuc { yyval = yystack.l_mark[-2]; }
1059357f1050SThomas Veerman break;
1060357f1050SThomas Veerman case 32:
1061357f1050SThomas Veerman {
1062357f1050SThomas Veerman yyval = scon_stk_ptr;
1063357f1050SThomas Veerman
1064357f1050SThomas Veerman for ( i = 1; i <= lastsc; ++i )
1065357f1050SThomas Veerman {
1066357f1050SThomas Veerman int j;
1067357f1050SThomas Veerman
1068357f1050SThomas Veerman for ( j = 1; j <= scon_stk_ptr; ++j )
1069357f1050SThomas Veerman if ( scon_stk[j] == i )
1070357f1050SThomas Veerman break;
1071357f1050SThomas Veerman
1072357f1050SThomas Veerman if ( j > scon_stk_ptr )
1073357f1050SThomas Veerman scon_stk[++scon_stk_ptr] = i;
1074357f1050SThomas Veerman }
1075357f1050SThomas Veerman }
1076357f1050SThomas Veerman break;
1077357f1050SThomas Veerman case 33:
1078357f1050SThomas Veerman { yyval = scon_stk_ptr; }
1079357f1050SThomas Veerman break;
1080357f1050SThomas Veerman case 36:
1081357f1050SThomas Veerman { synerr( _("bad start condition list") ); }
1082357f1050SThomas Veerman break;
1083357f1050SThomas Veerman case 37:
1084357f1050SThomas Veerman {
1085357f1050SThomas Veerman if ( (scnum = sclookup( nmstr )) == 0 )
1086357f1050SThomas Veerman format_pinpoint_message(
1087357f1050SThomas Veerman "undeclared start condition %s",
1088357f1050SThomas Veerman nmstr );
1089357f1050SThomas Veerman else
1090357f1050SThomas Veerman {
1091357f1050SThomas Veerman for ( i = 1; i <= scon_stk_ptr; ++i )
1092357f1050SThomas Veerman if ( scon_stk[i] == scnum )
1093357f1050SThomas Veerman {
1094357f1050SThomas Veerman format_warn(
1095357f1050SThomas Veerman "<%s> specified twice",
1096357f1050SThomas Veerman scname[scnum] );
1097357f1050SThomas Veerman break;
1098357f1050SThomas Veerman }
1099357f1050SThomas Veerman
1100357f1050SThomas Veerman if ( i > scon_stk_ptr )
1101357f1050SThomas Veerman scon_stk[++scon_stk_ptr] = scnum;
1102357f1050SThomas Veerman }
1103357f1050SThomas Veerman }
1104357f1050SThomas Veerman break;
1105357f1050SThomas Veerman case 38:
1106357f1050SThomas Veerman {
110784d9c625SLionel Sambuc if ( transchar[lastst[yystack.l_mark[0]]] != SYM_EPSILON )
1108357f1050SThomas Veerman /* Provide final transition \now/ so it
1109357f1050SThomas Veerman * will be marked as a trailing context
1110357f1050SThomas Veerman * state.
1111357f1050SThomas Veerman */
111284d9c625SLionel Sambuc yystack.l_mark[0] = link_machines( yystack.l_mark[0],
1113357f1050SThomas Veerman mkstate( SYM_EPSILON ) );
1114357f1050SThomas Veerman
111584d9c625SLionel Sambuc mark_beginning_as_normal( yystack.l_mark[0] );
1116357f1050SThomas Veerman current_state_type = STATE_NORMAL;
1117357f1050SThomas Veerman
1118357f1050SThomas Veerman if ( previous_continued_action )
1119357f1050SThomas Veerman {
1120357f1050SThomas Veerman /* We need to treat this as variable trailing
1121357f1050SThomas Veerman * context so that the backup does not happen
1122357f1050SThomas Veerman * in the action but before the action switch
1123357f1050SThomas Veerman * statement. If the backup happens in the
1124357f1050SThomas Veerman * action, then the rules "falling into" this
1125357f1050SThomas Veerman * one's action will *also* do the backup,
1126357f1050SThomas Veerman * erroneously.
1127357f1050SThomas Veerman */
1128357f1050SThomas Veerman if ( ! varlength || headcnt != 0 )
1129357f1050SThomas Veerman lwarn(
1130357f1050SThomas Veerman "trailing context made variable due to preceding '|' action" );
1131357f1050SThomas Veerman
1132357f1050SThomas Veerman /* Mark as variable. */
1133357f1050SThomas Veerman varlength = true;
1134357f1050SThomas Veerman headcnt = 0;
1135357f1050SThomas Veerman
1136357f1050SThomas Veerman }
1137357f1050SThomas Veerman
1138357f1050SThomas Veerman if ( lex_compat || (varlength && headcnt == 0) )
1139357f1050SThomas Veerman { /* variable trailing context rule */
1140357f1050SThomas Veerman /* Mark the first part of the rule as the
1141357f1050SThomas Veerman * accepting "head" part of a trailing
1142357f1050SThomas Veerman * context rule.
1143357f1050SThomas Veerman *
1144357f1050SThomas Veerman * By the way, we didn't do this at the
1145357f1050SThomas Veerman * beginning of this production because back
1146357f1050SThomas Veerman * then current_state_type was set up for a
1147357f1050SThomas Veerman * trail rule, and add_accept() can create
1148357f1050SThomas Veerman * a new state ...
1149357f1050SThomas Veerman */
115084d9c625SLionel Sambuc add_accept( yystack.l_mark[-1],
1151357f1050SThomas Veerman num_rules | YY_TRAILING_HEAD_MASK );
1152357f1050SThomas Veerman variable_trail_rule = true;
1153357f1050SThomas Veerman }
1154357f1050SThomas Veerman
1155357f1050SThomas Veerman else
1156357f1050SThomas Veerman trailcnt = rulelen;
1157357f1050SThomas Veerman
115884d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1159357f1050SThomas Veerman }
1160357f1050SThomas Veerman break;
1161357f1050SThomas Veerman case 39:
1162357f1050SThomas Veerman { synerr( _("trailing context used twice") ); }
1163357f1050SThomas Veerman break;
1164357f1050SThomas Veerman case 40:
1165357f1050SThomas Veerman {
1166357f1050SThomas Veerman headcnt = 0;
1167357f1050SThomas Veerman trailcnt = 1;
1168357f1050SThomas Veerman rulelen = 1;
1169357f1050SThomas Veerman varlength = false;
1170357f1050SThomas Veerman
1171357f1050SThomas Veerman current_state_type = STATE_TRAILING_CONTEXT;
1172357f1050SThomas Veerman
1173357f1050SThomas Veerman if ( trlcontxt )
1174357f1050SThomas Veerman {
1175357f1050SThomas Veerman synerr( _("trailing context used twice") );
1176357f1050SThomas Veerman yyval = mkstate( SYM_EPSILON );
1177357f1050SThomas Veerman }
1178357f1050SThomas Veerman
1179357f1050SThomas Veerman else if ( previous_continued_action )
1180357f1050SThomas Veerman {
1181357f1050SThomas Veerman /* See the comment in the rule for "re2 re"
1182357f1050SThomas Veerman * above.
1183357f1050SThomas Veerman */
1184357f1050SThomas Veerman lwarn(
1185357f1050SThomas Veerman "trailing context made variable due to preceding '|' action" );
1186357f1050SThomas Veerman
1187357f1050SThomas Veerman varlength = true;
1188357f1050SThomas Veerman }
1189357f1050SThomas Veerman
1190357f1050SThomas Veerman if ( lex_compat || varlength )
1191357f1050SThomas Veerman {
1192357f1050SThomas Veerman /* Again, see the comment in the rule for
1193357f1050SThomas Veerman * "re2 re" above.
1194357f1050SThomas Veerman */
119584d9c625SLionel Sambuc add_accept( yystack.l_mark[-1],
1196357f1050SThomas Veerman num_rules | YY_TRAILING_HEAD_MASK );
1197357f1050SThomas Veerman variable_trail_rule = true;
1198357f1050SThomas Veerman }
1199357f1050SThomas Veerman
1200357f1050SThomas Veerman trlcontxt = true;
1201357f1050SThomas Veerman
1202357f1050SThomas Veerman eps = mkstate( SYM_EPSILON );
120384d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-1],
1204357f1050SThomas Veerman link_machines( eps, mkstate( '\n' ) ) );
1205357f1050SThomas Veerman }
1206357f1050SThomas Veerman break;
1207357f1050SThomas Veerman case 41:
1208357f1050SThomas Veerman {
120984d9c625SLionel Sambuc yyval = yystack.l_mark[0];
1210357f1050SThomas Veerman
1211357f1050SThomas Veerman if ( trlcontxt )
1212357f1050SThomas Veerman {
1213357f1050SThomas Veerman if ( lex_compat || (varlength && headcnt == 0) )
1214357f1050SThomas Veerman /* Both head and trail are
1215357f1050SThomas Veerman * variable-length.
1216357f1050SThomas Veerman */
1217357f1050SThomas Veerman variable_trail_rule = true;
1218357f1050SThomas Veerman else
1219357f1050SThomas Veerman trailcnt = rulelen;
1220357f1050SThomas Veerman }
1221357f1050SThomas Veerman }
1222357f1050SThomas Veerman break;
1223357f1050SThomas Veerman case 42:
1224357f1050SThomas Veerman {
1225357f1050SThomas Veerman varlength = true;
122684d9c625SLionel Sambuc yyval = mkor( yystack.l_mark[-2], yystack.l_mark[0] );
1227357f1050SThomas Veerman }
1228357f1050SThomas Veerman break;
1229357f1050SThomas Veerman case 43:
123084d9c625SLionel Sambuc { yyval = yystack.l_mark[0]; }
1231357f1050SThomas Veerman break;
1232357f1050SThomas Veerman case 44:
1233357f1050SThomas Veerman {
1234357f1050SThomas Veerman /* This rule is written separately so the
1235357f1050SThomas Veerman * reduction will occur before the trailing
1236357f1050SThomas Veerman * series is parsed.
1237357f1050SThomas Veerman */
1238357f1050SThomas Veerman
1239357f1050SThomas Veerman if ( trlcontxt )
1240357f1050SThomas Veerman synerr( _("trailing context used twice") );
1241357f1050SThomas Veerman else
1242357f1050SThomas Veerman trlcontxt = true;
1243357f1050SThomas Veerman
1244357f1050SThomas Veerman if ( varlength )
1245357f1050SThomas Veerman /* We hope the trailing context is
1246357f1050SThomas Veerman * fixed-length.
1247357f1050SThomas Veerman */
1248357f1050SThomas Veerman varlength = false;
1249357f1050SThomas Veerman else
1250357f1050SThomas Veerman headcnt = rulelen;
1251357f1050SThomas Veerman
1252357f1050SThomas Veerman rulelen = 0;
1253357f1050SThomas Veerman
1254357f1050SThomas Veerman current_state_type = STATE_TRAILING_CONTEXT;
125584d9c625SLionel Sambuc yyval = yystack.l_mark[-1];
1256357f1050SThomas Veerman }
1257357f1050SThomas Veerman break;
1258357f1050SThomas Veerman case 45:
1259357f1050SThomas Veerman {
1260357f1050SThomas Veerman /* This is where concatenation of adjacent patterns
1261357f1050SThomas Veerman * gets done.
1262357f1050SThomas Veerman */
126384d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
1264357f1050SThomas Veerman }
1265357f1050SThomas Veerman break;
1266357f1050SThomas Veerman case 46:
126784d9c625SLionel Sambuc { yyval = yystack.l_mark[0]; }
1268357f1050SThomas Veerman break;
1269357f1050SThomas Veerman case 47:
1270357f1050SThomas Veerman {
1271357f1050SThomas Veerman varlength = true;
1272357f1050SThomas Veerman
127384d9c625SLionel Sambuc if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1274357f1050SThomas Veerman {
1275357f1050SThomas Veerman synerr( _("bad iteration values") );
127684d9c625SLionel Sambuc yyval = yystack.l_mark[-5];
1277357f1050SThomas Veerman }
1278357f1050SThomas Veerman else
1279357f1050SThomas Veerman {
128084d9c625SLionel Sambuc if ( yystack.l_mark[-3] == 0 )
1281357f1050SThomas Veerman {
128284d9c625SLionel Sambuc if ( yystack.l_mark[-1] <= 0 )
1283357f1050SThomas Veerman {
1284357f1050SThomas Veerman synerr(
1285357f1050SThomas Veerman _("bad iteration values") );
128684d9c625SLionel Sambuc yyval = yystack.l_mark[-5];
1287357f1050SThomas Veerman }
1288357f1050SThomas Veerman else
1289357f1050SThomas Veerman yyval = mkopt(
129084d9c625SLionel Sambuc mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1291357f1050SThomas Veerman }
1292357f1050SThomas Veerman else
129384d9c625SLionel Sambuc yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1294357f1050SThomas Veerman }
1295357f1050SThomas Veerman }
1296357f1050SThomas Veerman break;
1297357f1050SThomas Veerman case 48:
1298357f1050SThomas Veerman {
1299357f1050SThomas Veerman varlength = true;
1300357f1050SThomas Veerman
130184d9c625SLionel Sambuc if ( yystack.l_mark[-2] <= 0 )
1302357f1050SThomas Veerman {
1303357f1050SThomas Veerman synerr( _("iteration value must be positive") );
130484d9c625SLionel Sambuc yyval = yystack.l_mark[-4];
1305357f1050SThomas Veerman }
1306357f1050SThomas Veerman
1307357f1050SThomas Veerman else
130884d9c625SLionel Sambuc yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1309357f1050SThomas Veerman }
1310357f1050SThomas Veerman break;
1311357f1050SThomas Veerman case 49:
1312357f1050SThomas Veerman {
1313357f1050SThomas Veerman /* The series could be something like "(foo)",
1314357f1050SThomas Veerman * in which case we have no idea what its length
1315357f1050SThomas Veerman * is, so we punt here.
1316357f1050SThomas Veerman */
1317357f1050SThomas Veerman varlength = true;
1318357f1050SThomas Veerman
131984d9c625SLionel Sambuc if ( yystack.l_mark[-1] <= 0 )
1320357f1050SThomas Veerman {
1321357f1050SThomas Veerman synerr( _("iteration value must be positive")
1322357f1050SThomas Veerman );
132384d9c625SLionel Sambuc yyval = yystack.l_mark[-3];
1324357f1050SThomas Veerman }
1325357f1050SThomas Veerman
1326357f1050SThomas Veerman else
132784d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-3],
132884d9c625SLionel Sambuc copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1329357f1050SThomas Veerman }
1330357f1050SThomas Veerman break;
1331357f1050SThomas Veerman case 50:
1332357f1050SThomas Veerman {
1333357f1050SThomas Veerman varlength = true;
1334357f1050SThomas Veerman
133584d9c625SLionel Sambuc yyval = mkclos( yystack.l_mark[-1] );
1336357f1050SThomas Veerman }
1337357f1050SThomas Veerman break;
1338357f1050SThomas Veerman case 51:
1339357f1050SThomas Veerman {
1340357f1050SThomas Veerman varlength = true;
134184d9c625SLionel Sambuc yyval = mkposcl( yystack.l_mark[-1] );
1342357f1050SThomas Veerman }
1343357f1050SThomas Veerman break;
1344357f1050SThomas Veerman case 52:
1345357f1050SThomas Veerman {
1346357f1050SThomas Veerman varlength = true;
134784d9c625SLionel Sambuc yyval = mkopt( yystack.l_mark[-1] );
1348357f1050SThomas Veerman }
1349357f1050SThomas Veerman break;
1350357f1050SThomas Veerman case 53:
1351357f1050SThomas Veerman {
1352357f1050SThomas Veerman varlength = true;
1353357f1050SThomas Veerman
135484d9c625SLionel Sambuc if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
1355357f1050SThomas Veerman {
1356357f1050SThomas Veerman synerr( _("bad iteration values") );
135784d9c625SLionel Sambuc yyval = yystack.l_mark[-5];
1358357f1050SThomas Veerman }
1359357f1050SThomas Veerman else
1360357f1050SThomas Veerman {
136184d9c625SLionel Sambuc if ( yystack.l_mark[-3] == 0 )
1362357f1050SThomas Veerman {
136384d9c625SLionel Sambuc if ( yystack.l_mark[-1] <= 0 )
1364357f1050SThomas Veerman {
1365357f1050SThomas Veerman synerr(
1366357f1050SThomas Veerman _("bad iteration values") );
136784d9c625SLionel Sambuc yyval = yystack.l_mark[-5];
1368357f1050SThomas Veerman }
1369357f1050SThomas Veerman else
1370357f1050SThomas Veerman yyval = mkopt(
137184d9c625SLionel Sambuc mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
1372357f1050SThomas Veerman }
1373357f1050SThomas Veerman else
137484d9c625SLionel Sambuc yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
1375357f1050SThomas Veerman }
1376357f1050SThomas Veerman }
1377357f1050SThomas Veerman break;
1378357f1050SThomas Veerman case 54:
1379357f1050SThomas Veerman {
1380357f1050SThomas Veerman varlength = true;
1381357f1050SThomas Veerman
138284d9c625SLionel Sambuc if ( yystack.l_mark[-2] <= 0 )
1383357f1050SThomas Veerman {
1384357f1050SThomas Veerman synerr( _("iteration value must be positive") );
138584d9c625SLionel Sambuc yyval = yystack.l_mark[-4];
1386357f1050SThomas Veerman }
1387357f1050SThomas Veerman
1388357f1050SThomas Veerman else
138984d9c625SLionel Sambuc yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
1390357f1050SThomas Veerman }
1391357f1050SThomas Veerman break;
1392357f1050SThomas Veerman case 55:
1393357f1050SThomas Veerman {
1394357f1050SThomas Veerman /* The singleton could be something like "(foo)",
1395357f1050SThomas Veerman * in which case we have no idea what its length
1396357f1050SThomas Veerman * is, so we punt here.
1397357f1050SThomas Veerman */
1398357f1050SThomas Veerman varlength = true;
1399357f1050SThomas Veerman
140084d9c625SLionel Sambuc if ( yystack.l_mark[-1] <= 0 )
1401357f1050SThomas Veerman {
1402357f1050SThomas Veerman synerr( _("iteration value must be positive") );
140384d9c625SLionel Sambuc yyval = yystack.l_mark[-3];
1404357f1050SThomas Veerman }
1405357f1050SThomas Veerman
1406357f1050SThomas Veerman else
140784d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-3],
140884d9c625SLionel Sambuc copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
1409357f1050SThomas Veerman }
1410357f1050SThomas Veerman break;
1411357f1050SThomas Veerman case 56:
1412357f1050SThomas Veerman {
1413357f1050SThomas Veerman if ( ! madeany )
1414357f1050SThomas Veerman {
1415357f1050SThomas Veerman /* Create the '.' character class. */
1416357f1050SThomas Veerman ccldot = cclinit();
1417357f1050SThomas Veerman ccladd( ccldot, '\n' );
1418357f1050SThomas Veerman cclnegate( ccldot );
1419357f1050SThomas Veerman
1420357f1050SThomas Veerman if ( useecs )
1421357f1050SThomas Veerman mkeccl( ccltbl + cclmap[ccldot],
1422357f1050SThomas Veerman ccllen[ccldot], nextecm,
1423357f1050SThomas Veerman ecgroup, csize, csize );
1424357f1050SThomas Veerman
1425357f1050SThomas Veerman /* Create the (?s:'.') character class. */
1426357f1050SThomas Veerman cclany = cclinit();
1427357f1050SThomas Veerman cclnegate( cclany );
1428357f1050SThomas Veerman
1429357f1050SThomas Veerman if ( useecs )
1430357f1050SThomas Veerman mkeccl( ccltbl + cclmap[cclany],
1431357f1050SThomas Veerman ccllen[cclany], nextecm,
1432357f1050SThomas Veerman ecgroup, csize, csize );
1433357f1050SThomas Veerman
1434357f1050SThomas Veerman madeany = true;
1435357f1050SThomas Veerman }
1436357f1050SThomas Veerman
1437357f1050SThomas Veerman ++rulelen;
1438357f1050SThomas Veerman
1439357f1050SThomas Veerman if (sf_dot_all())
1440357f1050SThomas Veerman yyval = mkstate( -cclany );
1441357f1050SThomas Veerman else
1442357f1050SThomas Veerman yyval = mkstate( -ccldot );
1443357f1050SThomas Veerman }
1444357f1050SThomas Veerman break;
1445357f1050SThomas Veerman case 57:
1446357f1050SThomas Veerman {
144784d9c625SLionel Sambuc /* Sort characters for fast searching.
1448357f1050SThomas Veerman */
144984d9c625SLionel Sambuc qsort( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]], sizeof (*ccltbl), cclcmp );
1450357f1050SThomas Veerman
1451357f1050SThomas Veerman if ( useecs )
145284d9c625SLionel Sambuc mkeccl( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]],
1453357f1050SThomas Veerman nextecm, ecgroup, csize, csize );
1454357f1050SThomas Veerman
1455357f1050SThomas Veerman ++rulelen;
1456357f1050SThomas Veerman
145784d9c625SLionel Sambuc if (ccl_has_nl[yystack.l_mark[0]])
1458357f1050SThomas Veerman rule_has_nl[num_rules] = true;
1459357f1050SThomas Veerman
146084d9c625SLionel Sambuc yyval = mkstate( -yystack.l_mark[0] );
1461357f1050SThomas Veerman }
1462357f1050SThomas Veerman break;
1463357f1050SThomas Veerman case 58:
1464357f1050SThomas Veerman {
1465357f1050SThomas Veerman ++rulelen;
1466357f1050SThomas Veerman
146784d9c625SLionel Sambuc if (ccl_has_nl[yystack.l_mark[0]])
1468357f1050SThomas Veerman rule_has_nl[num_rules] = true;
1469357f1050SThomas Veerman
147084d9c625SLionel Sambuc yyval = mkstate( -yystack.l_mark[0] );
1471357f1050SThomas Veerman }
1472357f1050SThomas Veerman break;
1473357f1050SThomas Veerman case 59:
147484d9c625SLionel Sambuc { yyval = yystack.l_mark[-1]; }
1475357f1050SThomas Veerman break;
1476357f1050SThomas Veerman case 60:
147784d9c625SLionel Sambuc { yyval = yystack.l_mark[-1]; }
1478357f1050SThomas Veerman break;
1479357f1050SThomas Veerman case 61:
1480357f1050SThomas Veerman {
1481357f1050SThomas Veerman ++rulelen;
1482357f1050SThomas Veerman
148384d9c625SLionel Sambuc if (yystack.l_mark[0] == nlch)
1484357f1050SThomas Veerman rule_has_nl[num_rules] = true;
1485357f1050SThomas Veerman
148684d9c625SLionel Sambuc if (sf_case_ins() && has_case(yystack.l_mark[0]))
1487357f1050SThomas Veerman /* create an alternation, as in (a|A) */
148884d9c625SLionel Sambuc yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1489357f1050SThomas Veerman else
149084d9c625SLionel Sambuc yyval = mkstate( yystack.l_mark[0] );
1491357f1050SThomas Veerman }
1492357f1050SThomas Veerman break;
1493357f1050SThomas Veerman case 62:
149484d9c625SLionel Sambuc { yyval = ccl_set_diff (yystack.l_mark[-2], yystack.l_mark[0]); }
1495357f1050SThomas Veerman break;
1496357f1050SThomas Veerman case 63:
149784d9c625SLionel Sambuc { yyval = ccl_set_union (yystack.l_mark[-2], yystack.l_mark[0]); }
1498357f1050SThomas Veerman break;
1499357f1050SThomas Veerman case 65:
150084d9c625SLionel Sambuc { yyval = yystack.l_mark[-1]; }
1501357f1050SThomas Veerman break;
1502357f1050SThomas Veerman case 66:
1503357f1050SThomas Veerman {
150484d9c625SLionel Sambuc cclnegate( yystack.l_mark[-1] );
150584d9c625SLionel Sambuc yyval = yystack.l_mark[-1];
1506357f1050SThomas Veerman }
1507357f1050SThomas Veerman break;
1508357f1050SThomas Veerman case 67:
1509357f1050SThomas Veerman {
1510357f1050SThomas Veerman
1511357f1050SThomas Veerman if (sf_case_ins())
1512357f1050SThomas Veerman {
1513357f1050SThomas Veerman
1514357f1050SThomas Veerman /* If one end of the range has case and the other
1515357f1050SThomas Veerman * does not, or the cases are different, then we're not
1516357f1050SThomas Veerman * sure what range the user is trying to express.
1517357f1050SThomas Veerman * Examples: [@-z] or [S-t]
1518357f1050SThomas Veerman */
151984d9c625SLionel Sambuc if (has_case (yystack.l_mark[-2]) != has_case (yystack.l_mark[0])
152084d9c625SLionel Sambuc || (has_case (yystack.l_mark[-2]) && (b_islower (yystack.l_mark[-2]) != b_islower (yystack.l_mark[0])))
152184d9c625SLionel Sambuc || (has_case (yystack.l_mark[-2]) && (b_isupper (yystack.l_mark[-2]) != b_isupper (yystack.l_mark[0]))))
1522357f1050SThomas Veerman format_warn3 (
1523357f1050SThomas Veerman _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
152484d9c625SLionel Sambuc yystack.l_mark[-2], yystack.l_mark[0]);
1525357f1050SThomas Veerman
1526357f1050SThomas Veerman /* If the range spans uppercase characters but not
1527357f1050SThomas Veerman * lowercase (or vice-versa), then should we automatically
1528357f1050SThomas Veerman * include lowercase characters in the range?
1529357f1050SThomas Veerman * Example: [@-_] spans [a-z] but not [A-Z]
1530357f1050SThomas Veerman */
153184d9c625SLionel Sambuc 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]))
1532357f1050SThomas Veerman format_warn3 (
1533357f1050SThomas Veerman _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
153484d9c625SLionel Sambuc yystack.l_mark[-2], yystack.l_mark[0]);
1535357f1050SThomas Veerman }
1536357f1050SThomas Veerman
153784d9c625SLionel Sambuc if ( yystack.l_mark[-2] > yystack.l_mark[0] )
1538357f1050SThomas Veerman synerr( _("negative range in character class") );
1539357f1050SThomas Veerman
1540357f1050SThomas Veerman else
1541357f1050SThomas Veerman {
154284d9c625SLionel Sambuc for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
154384d9c625SLionel Sambuc ccladd( yystack.l_mark[-3], i );
1544357f1050SThomas Veerman
1545357f1050SThomas Veerman /* Keep track if this ccl is staying in
1546357f1050SThomas Veerman * alphabetical order.
1547357f1050SThomas Veerman */
154884d9c625SLionel Sambuc cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
154984d9c625SLionel Sambuc lastchar = yystack.l_mark[0];
1550357f1050SThomas Veerman
1551357f1050SThomas Veerman /* Do it again for upper/lowercase */
155284d9c625SLionel Sambuc if (sf_case_ins() && has_case(yystack.l_mark[-2]) && has_case(yystack.l_mark[0])){
155384d9c625SLionel Sambuc yystack.l_mark[-2] = reverse_case (yystack.l_mark[-2]);
155484d9c625SLionel Sambuc yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
1555357f1050SThomas Veerman
155684d9c625SLionel Sambuc for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
155784d9c625SLionel Sambuc ccladd( yystack.l_mark[-3], i );
1558357f1050SThomas Veerman
155984d9c625SLionel Sambuc cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
156084d9c625SLionel Sambuc lastchar = yystack.l_mark[0];
1561357f1050SThomas Veerman }
1562357f1050SThomas Veerman
1563357f1050SThomas Veerman }
1564357f1050SThomas Veerman
156584d9c625SLionel Sambuc yyval = yystack.l_mark[-3];
1566357f1050SThomas Veerman }
1567357f1050SThomas Veerman break;
1568357f1050SThomas Veerman case 68:
1569357f1050SThomas Veerman {
157084d9c625SLionel Sambuc ccladd( yystack.l_mark[-1], yystack.l_mark[0] );
157184d9c625SLionel Sambuc cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
157284d9c625SLionel Sambuc lastchar = yystack.l_mark[0];
1573357f1050SThomas Veerman
1574357f1050SThomas Veerman /* Do it again for upper/lowercase */
157584d9c625SLionel Sambuc if (sf_case_ins() && has_case(yystack.l_mark[0])){
157684d9c625SLionel Sambuc yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
157784d9c625SLionel Sambuc ccladd (yystack.l_mark[-1], yystack.l_mark[0]);
1578357f1050SThomas Veerman
157984d9c625SLionel Sambuc cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
158084d9c625SLionel Sambuc lastchar = yystack.l_mark[0];
1581357f1050SThomas Veerman }
1582357f1050SThomas Veerman
158384d9c625SLionel Sambuc yyval = yystack.l_mark[-1];
1584357f1050SThomas Veerman }
1585357f1050SThomas Veerman break;
1586357f1050SThomas Veerman case 69:
1587357f1050SThomas Veerman {
1588357f1050SThomas Veerman /* Too hard to properly maintain cclsorted. */
1589357f1050SThomas Veerman cclsorted = false;
159084d9c625SLionel Sambuc yyval = yystack.l_mark[-1];
1591357f1050SThomas Veerman }
1592357f1050SThomas Veerman break;
1593357f1050SThomas Veerman case 70:
1594357f1050SThomas Veerman {
1595357f1050SThomas Veerman cclsorted = true;
1596357f1050SThomas Veerman lastchar = 0;
1597357f1050SThomas Veerman currccl = yyval = cclinit();
1598357f1050SThomas Veerman }
1599357f1050SThomas Veerman break;
1600357f1050SThomas Veerman case 71:
1601357f1050SThomas Veerman { CCL_EXPR(isalnum); }
1602357f1050SThomas Veerman break;
1603357f1050SThomas Veerman case 72:
1604357f1050SThomas Veerman { CCL_EXPR(isalpha); }
1605357f1050SThomas Veerman break;
1606357f1050SThomas Veerman case 73:
1607357f1050SThomas Veerman { CCL_EXPR(IS_BLANK); }
1608357f1050SThomas Veerman break;
1609357f1050SThomas Veerman case 74:
1610357f1050SThomas Veerman { CCL_EXPR(iscntrl); }
1611357f1050SThomas Veerman break;
1612357f1050SThomas Veerman case 75:
1613357f1050SThomas Veerman { CCL_EXPR(isdigit); }
1614357f1050SThomas Veerman break;
1615357f1050SThomas Veerman case 76:
1616357f1050SThomas Veerman { CCL_EXPR(isgraph); }
1617357f1050SThomas Veerman break;
1618357f1050SThomas Veerman case 77:
1619357f1050SThomas Veerman {
1620357f1050SThomas Veerman CCL_EXPR(islower);
1621357f1050SThomas Veerman if (sf_case_ins())
1622357f1050SThomas Veerman CCL_EXPR(isupper);
1623357f1050SThomas Veerman }
1624357f1050SThomas Veerman break;
1625357f1050SThomas Veerman case 78:
1626357f1050SThomas Veerman { CCL_EXPR(isprint); }
1627357f1050SThomas Veerman break;
1628357f1050SThomas Veerman case 79:
1629357f1050SThomas Veerman { CCL_EXPR(ispunct); }
1630357f1050SThomas Veerman break;
1631357f1050SThomas Veerman case 80:
1632357f1050SThomas Veerman { CCL_EXPR(isspace); }
1633357f1050SThomas Veerman break;
1634357f1050SThomas Veerman case 81:
1635357f1050SThomas Veerman { CCL_EXPR(isxdigit); }
1636357f1050SThomas Veerman break;
1637357f1050SThomas Veerman case 82:
1638357f1050SThomas Veerman {
1639357f1050SThomas Veerman CCL_EXPR(isupper);
1640357f1050SThomas Veerman if (sf_case_ins())
1641357f1050SThomas Veerman CCL_EXPR(islower);
1642357f1050SThomas Veerman }
1643357f1050SThomas Veerman break;
1644357f1050SThomas Veerman case 83:
1645357f1050SThomas Veerman { CCL_NEG_EXPR(isalnum); }
1646357f1050SThomas Veerman break;
1647357f1050SThomas Veerman case 84:
1648357f1050SThomas Veerman { CCL_NEG_EXPR(isalpha); }
1649357f1050SThomas Veerman break;
1650357f1050SThomas Veerman case 85:
1651357f1050SThomas Veerman { CCL_NEG_EXPR(IS_BLANK); }
1652357f1050SThomas Veerman break;
1653357f1050SThomas Veerman case 86:
1654357f1050SThomas Veerman { CCL_NEG_EXPR(iscntrl); }
1655357f1050SThomas Veerman break;
1656357f1050SThomas Veerman case 87:
1657357f1050SThomas Veerman { CCL_NEG_EXPR(isdigit); }
1658357f1050SThomas Veerman break;
1659357f1050SThomas Veerman case 88:
1660357f1050SThomas Veerman { CCL_NEG_EXPR(isgraph); }
1661357f1050SThomas Veerman break;
1662357f1050SThomas Veerman case 89:
1663357f1050SThomas Veerman { CCL_NEG_EXPR(isprint); }
1664357f1050SThomas Veerman break;
1665357f1050SThomas Veerman case 90:
1666357f1050SThomas Veerman { CCL_NEG_EXPR(ispunct); }
1667357f1050SThomas Veerman break;
1668357f1050SThomas Veerman case 91:
1669357f1050SThomas Veerman { CCL_NEG_EXPR(isspace); }
1670357f1050SThomas Veerman break;
1671357f1050SThomas Veerman case 92:
1672357f1050SThomas Veerman { CCL_NEG_EXPR(isxdigit); }
1673357f1050SThomas Veerman break;
1674357f1050SThomas Veerman case 93:
1675357f1050SThomas Veerman {
1676357f1050SThomas Veerman if ( sf_case_ins() )
1677357f1050SThomas Veerman lwarn(_("[:^lower:] is ambiguous in case insensitive scanner"));
1678357f1050SThomas Veerman else
1679357f1050SThomas Veerman CCL_NEG_EXPR(islower);
1680357f1050SThomas Veerman }
1681357f1050SThomas Veerman break;
1682357f1050SThomas Veerman case 94:
1683357f1050SThomas Veerman {
1684357f1050SThomas Veerman if ( sf_case_ins() )
1685357f1050SThomas Veerman lwarn(_("[:^upper:] ambiguous in case insensitive scanner"));
1686357f1050SThomas Veerman else
1687357f1050SThomas Veerman CCL_NEG_EXPR(isupper);
1688357f1050SThomas Veerman }
1689357f1050SThomas Veerman break;
1690357f1050SThomas Veerman case 95:
1691357f1050SThomas Veerman {
169284d9c625SLionel Sambuc if ( yystack.l_mark[0] == nlch )
1693357f1050SThomas Veerman rule_has_nl[num_rules] = true;
1694357f1050SThomas Veerman
1695357f1050SThomas Veerman ++rulelen;
1696357f1050SThomas Veerman
169784d9c625SLionel Sambuc if (sf_case_ins() && has_case(yystack.l_mark[0]))
169884d9c625SLionel Sambuc yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
1699357f1050SThomas Veerman else
170084d9c625SLionel Sambuc yyval = mkstate (yystack.l_mark[0]);
1701357f1050SThomas Veerman
170284d9c625SLionel Sambuc yyval = link_machines( yystack.l_mark[-1], yyval);
1703357f1050SThomas Veerman }
1704357f1050SThomas Veerman break;
1705357f1050SThomas Veerman case 96:
1706357f1050SThomas Veerman { yyval = mkstate( SYM_EPSILON ); }
1707357f1050SThomas Veerman break;
1708357f1050SThomas Veerman }
170984d9c625SLionel Sambuc yystack.s_mark -= yym;
171084d9c625SLionel Sambuc yystate = *yystack.s_mark;
171184d9c625SLionel Sambuc yystack.l_mark -= yym;
1712357f1050SThomas Veerman yym = yylhs[yyn];
1713357f1050SThomas Veerman if (yystate == 0 && yym == 0)
1714357f1050SThomas Veerman {
1715357f1050SThomas Veerman #if YYDEBUG
1716357f1050SThomas Veerman if (yydebug)
1717357f1050SThomas Veerman printf("%sdebug: after reduction, shifting from state 0 to\
1718357f1050SThomas Veerman state %d\n", YYPREFIX, YYFINAL);
1719357f1050SThomas Veerman #endif
1720357f1050SThomas Veerman yystate = YYFINAL;
172184d9c625SLionel Sambuc *++yystack.s_mark = YYFINAL;
172284d9c625SLionel Sambuc *++yystack.l_mark = yyval;
1723357f1050SThomas Veerman if (yychar < 0)
1724357f1050SThomas Veerman {
172584d9c625SLionel Sambuc if ((yychar = YYLEX) < 0) yychar = 0;
1726357f1050SThomas Veerman #if YYDEBUG
1727357f1050SThomas Veerman if (yydebug)
1728357f1050SThomas Veerman {
1729357f1050SThomas Veerman yys = 0;
1730357f1050SThomas Veerman if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1731357f1050SThomas Veerman if (!yys) yys = "illegal-symbol";
1732357f1050SThomas Veerman printf("%sdebug: state %d, reading %d (%s)\n",
1733357f1050SThomas Veerman YYPREFIX, YYFINAL, yychar, yys);
1734357f1050SThomas Veerman }
1735357f1050SThomas Veerman #endif
1736357f1050SThomas Veerman }
1737357f1050SThomas Veerman if (yychar == 0) goto yyaccept;
1738357f1050SThomas Veerman goto yyloop;
1739357f1050SThomas Veerman }
1740357f1050SThomas Veerman if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1741357f1050SThomas Veerman yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1742357f1050SThomas Veerman yystate = yytable[yyn];
1743357f1050SThomas Veerman else
1744357f1050SThomas Veerman yystate = yydgoto[yym];
1745357f1050SThomas Veerman #if YYDEBUG
1746357f1050SThomas Veerman if (yydebug)
1747357f1050SThomas Veerman printf("%sdebug: after reduction, shifting from state %d \
174884d9c625SLionel Sambuc to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1749357f1050SThomas Veerman #endif
175084d9c625SLionel Sambuc if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1751357f1050SThomas Veerman {
1752357f1050SThomas Veerman goto yyoverflow;
1753357f1050SThomas Veerman }
175484d9c625SLionel Sambuc *++yystack.s_mark = (short) yystate;
175584d9c625SLionel Sambuc *++yystack.l_mark = yyval;
1756357f1050SThomas Veerman goto yyloop;
1757357f1050SThomas Veerman
1758357f1050SThomas Veerman yyoverflow:
1759357f1050SThomas Veerman yyerror("yacc stack overflow");
1760357f1050SThomas Veerman
1761357f1050SThomas Veerman yyabort:
176284d9c625SLionel Sambuc yyfreestack(&yystack);
1763357f1050SThomas Veerman return (1);
1764357f1050SThomas Veerman
1765357f1050SThomas Veerman yyaccept:
176684d9c625SLionel Sambuc yyfreestack(&yystack);
1767357f1050SThomas Veerman return (0);
1768357f1050SThomas Veerman }
1769