2 static char yysccsid
[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
7 #define yyclearin (yychar=(-1))
8 #define yyerrok (yyerrflag=0)
9 #define YYRECOVERING (yyerrflag!=0)
13 * Copyright (c) 1990 The Regents of the University of California.
14 * All rights reserved.
16 * This code is derived from software contributed to Berkeley by
19 * The United States Government has rights in this work pursuant
20 * to contract no. DE-AC03-76SF00098 between the United States
21 * Department of Energy and the University of California.
23 * Redistribution and use in source and binary forms with or without
24 * modification are permitted provided that: (1) source distributions retain
25 * this entire copyright notice and comment, and (2) distributions including
26 * binaries display the following acknowledgement: ``This product includes
27 * software developed by the University of California, Berkeley and its
28 * contributors'' in the documentation or other materials provided with the
29 * distribution and in all advertising materials mentioning features or use
30 * of this software. Neither the name of the University nor the names of
31 * its contributors may be used to endorse or promote products derived from
32 * this software without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
34 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
35 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
41 /* Some versions of bison are broken in that they use alloca() but don't
42 * declare it properly. The following is the patented (just kidding!)
43 * #ifdef chud to fix the problem, courtesy of Francois Pinard.
46 /* AIX requires this to be the first thing in the file. What a piece. */
54 /* The remainder of the alloca() cruft has to come after including flexdef.h,
55 * so HAVE_ALLOCA_H is (possibly) defined.
60 # define alloca __builtin_alloca
79 /* Bletch, ^^^^ that was ugly! */
82 int pat
, scnum
, eps
, headcnt
, trailcnt
, anyccl
, lastchar
, i
, rulelen
;
83 int trlcontxt
, xcluflg
, currccl
, cclsorted
, varlength
, variable_trail_rule
;
88 static int madeany
= false; /* whether we've made the '.' character class */
89 int previous_continued_action
; /* whether the previous rule's action was '|' */
91 /* Expand a POSIX character class expression. */
92 #define CCL_EXPR(func) \
95 for ( c = 0; c < csize; ++c ) \
96 if ( isascii(c) && func(c) ) \
97 ccladd( currccl, c ); \
100 /* While POSIX defines isblank(), it's not ANSI C. */
101 #define IS_BLANK(c) ((c) == ' ' || (c) == '\t')
103 /* On some over-ambitious machines, such as DEC Alpha's, the default
104 * token type is "long" instead of "int"; this leads to problems with
105 * declaring yylval in flexdef.h. But so far, all the yacc's I've seen
106 * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
107 * following should ensure that the default token type is "int".
120 #define OPTION_OP 265
121 #define OPT_OUTFILE 266
122 #define OPT_PREFIX 267
123 #define OPT_YYCLASS 268
124 #define CCE_ALNUM 269
125 #define CCE_ALPHA 270
126 #define CCE_BLANK 271
127 #define CCE_CNTRL 272
128 #define CCE_DIGIT 273
129 #define CCE_GRAPH 274
130 #define CCE_LOWER 275
131 #define CCE_PRINT 276
132 #define CCE_PUNCT 277
133 #define CCE_SPACE 278
134 #define CCE_UPPER 279
135 #define CCE_XDIGIT 280
136 #define YYERRCODE 256
137 short yylhs
[] = { -1,
138 0, 1, 2, 2, 2, 2, 3, 6, 6, 7,
139 7, 7, 8, 9, 9, 10, 10, 10, 4, 4,
140 4, 5, 12, 12, 12, 12, 14, 11, 11, 11,
141 15, 15, 15, 16, 13, 13, 13, 13, 18, 18,
142 17, 19, 19, 20, 20, 20, 20, 20, 20, 20,
143 20, 20, 20, 20, 20, 21, 21, 23, 23, 23,
144 23, 24, 24, 24, 24, 24, 24, 24, 24, 24,
148 5, 0, 3, 2, 0, 1, 1, 1, 1, 2,
149 1, 1, 2, 2, 0, 3, 3, 3, 5, 5,
150 0, 0, 2, 1, 1, 1, 0, 4, 3, 0,
151 3, 1, 1, 1, 2, 3, 2, 1, 3, 1,
152 2, 2, 1, 2, 2, 2, 6, 5, 4, 1,
153 1, 1, 3, 3, 1, 3, 4, 4, 2, 2,
154 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
157 short yydefred
[] = { 2,
158 0, 0, 6, 0, 7, 8, 9, 15, 21, 0,
159 4, 0, 0, 12, 11, 0, 0, 0, 0, 14,
160 0, 1, 0, 10, 0, 0, 0, 0, 0, 21,
161 0, 16, 17, 18, 29, 33, 34, 0, 32, 0,
162 26, 55, 52, 25, 0, 50, 75, 0, 0, 0,
163 24, 0, 0, 0, 0, 51, 28, 0, 20, 23,
164 0, 0, 61, 0, 19, 0, 37, 0, 41, 0,
165 0, 44, 45, 46, 31, 74, 53, 54, 0, 0,
166 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
167 72, 73, 56, 60, 36, 0, 0, 57, 0, 49,
170 short yydgoto
[] = { 1,
171 2, 4, 9, 13, 22, 10, 16, 11, 12, 20,
172 23, 50, 51, 29, 38, 39, 52, 53, 54, 55,
175 short yysindex
[] = { 0,
176 0, -235, 0, -191, 0, 0, 0, 0, 0, -207,
177 0, -215, -18, 0, 0, -202, 4, 26, 32, 0,
178 41, 0, -35, 0, -168, -166, -165, 38, -180, 0,
179 -30, 0, 0, 0, 0, 0, 0, -16, 0, -40,
180 0, 0, 0, 0, -2, 0, 0, -2, 8, 93,
181 0, -2, -25, -2, 15, 0, 0, -153, 0, 0,
182 -27, -26, 0, -88, 0, -23, 0, -2, 0, 15,
183 -150, 0, 0, 0, 0, 0, 0, 0, -3, 65,
184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, -2, -21, 0, -145, 0,
188 short yyrindex
[] = { 0,
189 0, -188, 0, 0, 0, 0, 0, 0, 0, 0,
190 0, -154, 1, 0, 0, -140, 0, 0, 0, 0,
191 -176, 0, -28, 0, 0, 0, 0, 0, 0, 0,
192 0, 0, 0, 0, 0, 0, 0, 0, 0, -32,
193 0, 0, 0, 0, 0, 0, 0, 0, 22, 0,
194 0, 0, 106, 7, -10, 0, 0, 0, 0, 0,
195 0, 0, 0, 0, 0, 108, 0, 0, 0, -7,
196 0, 0, 0, 0, 0, 0, 0, 0, 0, 46,
197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
198 0, 0, 0, 0, 0, 9, 0, 0, 0, 0,
201 short yygindex
[] = { 0,
202 0, 0, 0, 92, 100, 0, 0, 0, 0, 0,
203 0, 0, 81, 0, 0, 69, 0, 27, 60, -29,
206 #define YYTABLESIZE 326
207 short yytable
[] = { 43,
208 22, 30, 42, 47, 93, 22, 77, 30, 104, 48,
209 67, 22, 95, 30, 78, 46, 40, 22, 39, 21,
210 3, 69, 101, 43, 70, 43, 42, 58, 42, 43,
211 43, 47, 42, 42, 30, 43, 43, 48, 42, 42,
212 30, 21, 40, 46, 39, 57, 30, 40, 14, 39,
213 17, 18, 19, 40, 15, 39, 72, 73, 30, 24,
214 49, 30, 22, 45, 25, 22, 70, 5, 6, 7,
215 5, 5, 5, 8, 62, 36, 5, 74, 66, 27,
216 43, 37, 28, 42, 59, 27, 26, 30, 49, 98,
217 30, 30, 27, 32, 30, 33, 34, 68, 68, 35,
218 68, 63, 65, 100, 13, 13, 13, 97, 37, 99,
219 13, 102, 105, 43, 61, 38, 42, 35, 3, 3,
220 3, 40, 31, 30, 3, 60, 75, 96, 79, 0,
221 40, 0, 39, 0, 0, 0, 0, 71, 59, 0,
222 0, 103, 0, 0, 0, 0, 0, 0, 0, 0,
223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
224 0, 0, 0, 0, 0, 0, 0, 0, 80, 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
226 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
227 91, 92, 0, 0, 0, 0, 0, 0, 0, 0,
228 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
229 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
230 0, 0, 0, 30, 30, 41, 42, 22, 22, 76,
231 30, 30, 43, 44, 22, 22, 0, 0, 0, 0,
232 0, 0, 0, 0, 0, 0, 43, 0, 0, 42,
233 0, 0, 43, 80, 42, 42, 30, 30, 0, 0,
234 43, 0, 0, 30, 30, 81, 82, 83, 84, 85,
235 86, 87, 88, 89, 90, 91, 92, 0, 61, 0,
236 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
237 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
238 61, 61, 59, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 59, 59, 59, 59, 59, 59,
240 59, 59, 59, 59, 59, 59,
242 short yycheck
[] = { 10,
243 0, 34, 10, 34, 93, 34, 34, 40, 125, 40,
244 36, 40, 36, 46, 41, 46, 10, 46, 10, 60,
245 256, 47, 44, 34, 54, 36, 34, 44, 36, 40,
246 41, 34, 40, 41, 34, 46, 47, 40, 46, 47,
247 40, 60, 36, 46, 36, 62, 46, 41, 256, 41,
248 266, 267, 268, 47, 262, 47, 42, 43, 91, 262,
249 91, 94, 91, 94, 61, 94, 96, 259, 260, 261,
250 259, 260, 261, 265, 48, 256, 265, 63, 52, 256,
251 91, 262, 42, 91, 125, 262, 61, 123, 91, 93,
252 123, 91, 61, 262, 94, 262, 262, 124, 124, 62,
253 124, 94, 10, 125, 259, 260, 261, 258, 262, 45,
254 265, 257, 125, 124, 93, 10, 124, 10, 259, 260,
255 261, 30, 23, 123, 265, 45, 58, 68, 63, -1,
256 124, -1, 124, -1, -1, -1, -1, 123, 93, -1,
257 -1, 258, -1, -1, -1, -1, -1, -1, -1, -1,
258 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
259 -1, -1, -1, -1, -1, -1, -1, -1, 257, -1,
260 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
261 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
262 279, 280, -1, -1, -1, -1, -1, -1, -1, -1,
263 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
264 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
265 -1, -1, -1, 256, 257, 256, 257, 256, 257, 257,
266 263, 264, 263, 264, 263, 264, -1, -1, -1, -1,
267 -1, -1, -1, -1, -1, -1, 257, -1, -1, 257,
268 -1, -1, 263, 257, 257, 263, 256, 257, -1, -1,
269 263, -1, -1, 263, 264, 269, 270, 271, 272, 273,
270 274, 275, 276, 277, 278, 279, 280, -1, 257, -1,
271 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
272 269, 270, 271, 272, 273, 274, 275, 276, 277, 278,
273 279, 280, 257, -1, -1, -1, -1, -1, -1, -1,
274 -1, -1, -1, -1, 269, 270, 271, 272, 273, 274,
275 275, 276, 277, 278, 279, 280,
281 #define YYMAXTOKEN 280
284 "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,
285 0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,
286 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,
287 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,
288 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,
289 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,
290 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,
291 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",
292 "SCDECL","XSCDECL","NAME","PREVCCL","EOF_OP","OPTION_OP","OPT_OUTFILE",
293 "OPT_PREFIX","OPT_YYCLASS","CCE_ALNUM","CCE_ALPHA","CCE_BLANK","CCE_CNTRL",
294 "CCE_DIGIT","CCE_GRAPH","CCE_LOWER","CCE_PRINT","CCE_PUNCT","CCE_SPACE",
295 "CCE_UPPER","CCE_XDIGIT",
299 "goal : initlex sect1 sect1end sect2 initforrule",
301 "sect1 : sect1 startconddecl namelist1",
302 "sect1 : sect1 options",
305 "sect1end : SECTEND",
306 "startconddecl : SCDECL",
307 "startconddecl : XSCDECL",
308 "namelist1 : namelist1 NAME",
311 "options : OPTION_OP optionlist",
312 "optionlist : optionlist option",
314 "option : OPT_OUTFILE '=' NAME",
315 "option : OPT_PREFIX '=' NAME",
316 "option : OPT_YYCLASS '=' NAME",
317 "sect2 : sect2 scon initforrule flexrule '\\n'",
318 "sect2 : sect2 scon '{' sect2 '}'",
321 "flexrule : '^' rule",
326 "scon : '<' scon_stk_ptr namelist2 '>'",
327 "scon : '<' '*' '>'",
329 "namelist2 : namelist2 ',' sconname",
330 "namelist2 : sconname",
337 "re : re '|' series",
340 "series : series singleton",
341 "series : singleton",
342 "singleton : singleton '*'",
343 "singleton : singleton '+'",
344 "singleton : singleton '?'",
345 "singleton : singleton '{' NUMBER ',' NUMBER '}'",
346 "singleton : singleton '{' NUMBER ',' '}'",
347 "singleton : singleton '{' NUMBER '}'",
349 "singleton : fullccl",
350 "singleton : PREVCCL",
351 "singleton : '\"' string '\"'",
352 "singleton : '(' re ')'",
354 "fullccl : '[' ccl ']'",
355 "fullccl : '[' '^' ccl ']'",
356 "ccl : ccl CHAR '-' CHAR",
358 "ccl : ccl ccl_expr",
360 "ccl_expr : CCE_ALNUM",
361 "ccl_expr : CCE_ALPHA",
362 "ccl_expr : CCE_BLANK",
363 "ccl_expr : CCE_CNTRL",
364 "ccl_expr : CCE_DIGIT",
365 "ccl_expr : CCE_GRAPH",
366 "ccl_expr : CCE_LOWER",
367 "ccl_expr : CCE_PRINT",
368 "ccl_expr : CCE_PUNCT",
369 "ccl_expr : CCE_SPACE",
370 "ccl_expr : CCE_UPPER",
371 "ccl_expr : CCE_XDIGIT",
372 "string : string CHAR",
381 #define YYMAXDEPTH YYSTACKSIZE
384 #define YYSTACKSIZE YYMAXDEPTH
386 #define YYSTACKSIZE 500
387 #define YYMAXDEPTH 500
398 short yyss
[YYSTACKSIZE
];
399 YYSTYPE yyvs
[YYSTACKSIZE
];
400 #define yystacksize YYSTACKSIZE
401 #line 776 "./parse.y"
404 /* build_eof_action - build the "<<EOF>>" action for the active start
408 void build_eof_action()
411 char action_text
[MAXLINE
];
413 for ( i
= 1; i
<= scon_stk_ptr
; ++i
)
415 if ( sceof
[scon_stk
[i
]] )
416 format_pinpoint_message(
417 "multiple <<EOF>> rules for start condition %s",
418 scname
[scon_stk
[i
]] );
422 sceof
[scon_stk
[i
]] = true;
423 sprintf( action_text
, "case YY_STATE_EOF(%s):\n",
424 scname
[scon_stk
[i
]] );
425 add_action( action_text
);
429 line_directive_out( (FILE *) 0, 1 );
431 /* This isn't a normal rule after all - don't count it as
432 * such, so we don't have any holes in the rule numbering
433 * (which make generating "rule can never match" warnings
441 /* format_synerr - write out formatted syntax error */
443 void format_synerr( msg
, arg
)
446 char errmsg
[MAXLINE
];
448 (void) sprintf( errmsg
, msg
, arg
);
453 /* synerr - report a syntax error */
459 pinpoint_message( str
);
463 /* format_warn - write out formatted warning */
465 void format_warn( msg
, arg
)
468 char warn_msg
[MAXLINE
];
470 (void) sprintf( warn_msg
, msg
, arg
);
475 /* warn - report a warning, unless -w was given */
480 line_warning( str
, linenum
);
483 /* format_pinpoint_message - write out a message formatted with one string,
484 * pinpointing its location
487 void format_pinpoint_message( msg
, arg
)
490 char errmsg
[MAXLINE
];
492 (void) sprintf( errmsg
, msg
, arg
);
493 pinpoint_message( errmsg
);
497 /* pinpoint_message - write out a message, pinpointing its location */
499 void pinpoint_message( str
)
502 line_pinpoint( str
, linenum
);
506 /* line_warning - report a warning at a given line, unless -w was given */
508 void line_warning( str
, line
)
512 char warning
[MAXLINE
];
516 sprintf( warning
, "warning, %s", str
);
517 line_pinpoint( warning
, line
);
522 /* line_pinpoint - write out a message, pinpointing it at the given line */
524 void line_pinpoint( str
, line
)
528 fprintf( stderr
, "\"%s\", line %d: %s\n", infilename
, line
, str
);
532 /* yyerror - eat up an error message from the parser;
533 * currently, messages are ignore
541 #define YYABORT goto yyabort
542 #define YYREJECT goto yyabort
543 #define YYACCEPT goto yyaccept
544 #define YYERROR goto yyerrlab
548 register int yym
, yyn
, yystate
;
551 extern char *getenv();
553 if (yys
= getenv("YYDEBUG"))
556 if (yyn
>= '0' && yyn
<= '9')
567 *yyssp
= yystate
= 0;
570 if (yyn
= yydefred
[yystate
]) goto yyreduce
;
573 if ((yychar
= yylex()) < 0) yychar
= 0;
578 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
579 if (!yys
) yys
= "illegal-symbol";
580 printf("%sdebug: state %d, reading %d (%s)\n",
581 YYPREFIX
, yystate
, yychar
, yys
);
585 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
586 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
590 printf("%sdebug: state %d, shifting to state %d\n",
591 YYPREFIX
, yystate
, yytable
[yyn
]);
593 if (yyssp
>= yyss
+ yystacksize
- 1)
597 *++yyssp
= yystate
= yytable
[yyn
];
600 if (yyerrflag
> 0) --yyerrflag
;
603 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
604 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
609 if (yyerrflag
) goto yyinrecovery
;
614 yyerror("syntax error");
626 if ((yyn
= yysindex
[*yyssp
]) && (yyn
+= YYERRCODE
) >= 0 &&
627 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
631 printf("%sdebug: state %d, error recovery shifting\
632 to state %d\n", YYPREFIX
, *yyssp
, yytable
[yyn
]);
634 if (yyssp
>= yyss
+ yystacksize
- 1)
638 *++yyssp
= yystate
= yytable
[yyn
];
646 printf("%sdebug: error recovery discarding state %d\n",
649 if (yyssp
<= yyss
) goto yyabort
;
657 if (yychar
== 0) goto yyabort
;
662 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
663 if (!yys
) yys
= "illegal-symbol";
664 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
665 YYPREFIX
, yystate
, yychar
, yys
);
674 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
675 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
678 yyval
= yyvsp
[1-yym
];
682 #line 113 "./parse.y"
683 { /* add default rule */
689 def_rule
= mkstate( -pat
);
691 /* Remember the number of the default rule so we
692 * don't generate "can't match" warnings for it.
694 default_rule
= num_rules
;
696 finish_rule( def_rule
, false, 0, 0 );
698 for ( i
= 1; i
<= lastsc
; ++i
)
699 scset
[i
] = mkbranch( scset
[i
], def_rule
);
703 "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
705 add_action( "ECHO" );
707 add_action( ";\n\tYY_BREAK\n" );
711 #line 142 "./parse.y"
712 { /* initialize for processing rules */
714 /* Create default DFA start condition. */
715 scinstal( "INITIAL", false );
719 #line 153 "./parse.y"
720 { synerr( "unknown error processing section 1" ); }
723 #line 157 "./parse.y"
726 scon_stk
= allocate_integer_array( lastsc
+ 1 );
731 #line 165 "./parse.y"
735 #line 168 "./parse.y"
739 #line 172 "./parse.y"
740 { scinstal( nmstr
, xcluflg
); }
743 #line 175 "./parse.y"
744 { scinstal( nmstr
, xcluflg
); }
747 #line 178 "./parse.y"
748 { synerr( "bad start condition list" ); }
751 #line 189 "./parse.y"
753 outfilename
= copy_string( nmstr
);
758 #line 194 "./parse.y"
759 { prefix
= copy_string( nmstr
); }
762 #line 196 "./parse.y"
763 { yyclass
= copy_string( nmstr
); }
766 #line 200 "./parse.y"
767 { scon_stk_ptr
= yyvsp
[-3]; }
770 #line 202 "./parse.y"
771 { scon_stk_ptr
= yyvsp
[-3]; }
774 #line 207 "./parse.y"
776 /* Initialize for a parse of one rule. */
777 trlcontxt
= variable_trail_rule
= varlength
= false;
778 trailcnt
= headcnt
= rulelen
= 0;
779 current_state_type
= STATE_NORMAL
;
780 previous_continued_action
= continued_action
;
787 #line 220 "./parse.y"
790 finish_rule( pat
, variable_trail_rule
,
793 if ( scon_stk_ptr
> 0 )
795 for ( i
= 1; i
<= scon_stk_ptr
; ++i
)
797 mkbranch( scbol
[scon_stk
[i
]],
803 /* Add to all non-exclusive start conditions,
804 * including the default (0) start condition.
807 for ( i
= 1; i
<= lastsc
; ++i
)
809 scbol
[i
] = mkbranch( scbol
[i
],
817 if ( performance_report
> 1 )
819 "'^' operator results in sub-optimal performance" );
824 #line 256 "./parse.y"
827 finish_rule( pat
, variable_trail_rule
,
830 if ( scon_stk_ptr
> 0 )
832 for ( i
= 1; i
<= scon_stk_ptr
; ++i
)
834 mkbranch( scset
[scon_stk
[i
]],
840 for ( i
= 1; i
<= lastsc
; ++i
)
849 #line 280 "./parse.y"
851 if ( scon_stk_ptr
> 0 )
856 /* This EOF applies to all start conditions
857 * which don't already have EOF actions.
859 for ( i
= 1; i
<= lastsc
; ++i
)
861 scon_stk
[++scon_stk_ptr
] = i
;
863 if ( scon_stk_ptr
== 0 )
865 "all start conditions already have <<EOF>> rules" );
873 #line 303 "./parse.y"
874 { synerr( "unrecognized rule" ); }
877 #line 307 "./parse.y"
878 { yyval
= scon_stk_ptr
; }
881 #line 311 "./parse.y"
882 { yyval
= yyvsp
[-2]; }
885 #line 314 "./parse.y"
887 yyval
= scon_stk_ptr
;
889 for ( i
= 1; i
<= lastsc
; ++i
)
893 for ( j
= 1; j
<= scon_stk_ptr
; ++j
)
894 if ( scon_stk
[j
] == i
)
897 if ( j
> scon_stk_ptr
)
898 scon_stk
[++scon_stk_ptr
] = i
;
903 #line 331 "./parse.y"
904 { yyval
= scon_stk_ptr
; }
907 #line 339 "./parse.y"
908 { synerr( "bad start condition list" ); }
911 #line 343 "./parse.y"
913 if ( (scnum
= sclookup( nmstr
)) == 0 )
914 format_pinpoint_message(
915 "undeclared start condition %s",
919 for ( i
= 1; i
<= scon_stk_ptr
; ++i
)
920 if ( scon_stk
[i
] == scnum
)
923 "<%s> specified twice",
928 if ( i
> scon_stk_ptr
)
929 scon_stk
[++scon_stk_ptr
] = scnum
;
934 #line 366 "./parse.y"
936 if ( transchar
[lastst
[yyvsp
[0]]] != SYM_EPSILON
)
937 /* Provide final transition \now/ so it
938 * will be marked as a trailing context
941 yyvsp
[0] = link_machines( yyvsp
[0],
942 mkstate( SYM_EPSILON
) );
944 mark_beginning_as_normal( yyvsp
[0] );
945 current_state_type
= STATE_NORMAL
;
947 if ( previous_continued_action
)
949 /* We need to treat this as variable trailing
950 * context so that the backup does not happen
951 * in the action but before the action switch
952 * statement. If the backup happens in the
953 * action, then the rules "falling into" this
954 * one's action will *also* do the backup,
957 if ( ! varlength
|| headcnt
!= 0 )
959 "trailing context made variable due to preceding '|' action" );
961 /* Mark as variable. */
966 if ( lex_compat
|| (varlength
&& headcnt
== 0) )
967 { /* variable trailing context rule */
968 /* Mark the first part of the rule as the
969 * accepting "head" part of a trailing
972 * By the way, we didn't do this at the
973 * beginning of this production because back
974 * then current_state_type was set up for a
975 * trail rule, and add_accept() can create
978 add_accept( yyvsp
[-1],
979 num_rules
| YY_TRAILING_HEAD_MASK
);
980 variable_trail_rule
= true;
986 yyval
= link_machines( yyvsp
[-1], yyvsp
[0] );
990 #line 421 "./parse.y"
991 { synerr( "trailing context used twice" ); }
994 #line 424 "./parse.y"
1001 current_state_type
= STATE_TRAILING_CONTEXT
;
1005 synerr( "trailing context used twice" );
1006 yyval
= mkstate( SYM_EPSILON
);
1009 else if ( previous_continued_action
)
1011 /* See the comment in the rule for "re2 re"
1015 "trailing context made variable due to preceding '|' action" );
1020 if ( lex_compat
|| varlength
)
1022 /* Again, see the comment in the rule for
1025 add_accept( yyvsp
[-1],
1026 num_rules
| YY_TRAILING_HEAD_MASK
);
1027 variable_trail_rule
= true;
1032 eps
= mkstate( SYM_EPSILON
);
1033 yyval
= link_machines( yyvsp
[-1],
1034 link_machines( eps
, mkstate( '\n' ) ) );
1038 #line 467 "./parse.y"
1044 if ( lex_compat
|| (varlength
&& headcnt
== 0) )
1045 /* Both head and trail are
1048 variable_trail_rule
= true;
1055 #line 485 "./parse.y"
1058 yyval
= mkor( yyvsp
[-2], yyvsp
[0] );
1062 #line 491 "./parse.y"
1063 { yyval
= yyvsp
[0]; }
1066 #line 496 "./parse.y"
1068 /* This rule is written separately so the
1069 * reduction will occur before the trailing
1074 synerr( "trailing context used twice" );
1079 /* We hope the trailing context is
1088 current_state_type
= STATE_TRAILING_CONTEXT
;
1093 #line 523 "./parse.y"
1095 /* This is where concatenation of adjacent patterns
1098 yyval
= link_machines( yyvsp
[-1], yyvsp
[0] );
1102 #line 531 "./parse.y"
1103 { yyval
= yyvsp
[0]; }
1106 #line 535 "./parse.y"
1110 yyval
= mkclos( yyvsp
[-1] );
1114 #line 542 "./parse.y"
1117 yyval
= mkposcl( yyvsp
[-1] );
1121 #line 548 "./parse.y"
1124 yyval
= mkopt( yyvsp
[-1] );
1128 #line 554 "./parse.y"
1132 if ( yyvsp
[-3] > yyvsp
[-1] || yyvsp
[-3] < 0 )
1134 synerr( "bad iteration values" );
1139 if ( yyvsp
[-3] == 0 )
1141 if ( yyvsp
[-1] <= 0 )
1144 "bad iteration values" );
1149 mkrep( yyvsp
[-5], 1, yyvsp
[-1] ) );
1152 yyval
= mkrep( yyvsp
[-5], yyvsp
[-3], yyvsp
[-1] );
1157 #line 582 "./parse.y"
1161 if ( yyvsp
[-2] <= 0 )
1163 synerr( "iteration value must be positive" );
1168 yyval
= mkrep( yyvsp
[-4], yyvsp
[-2], INFINITY
);
1172 #line 596 "./parse.y"
1174 /* The singleton could be something like "(foo)",
1175 * in which case we have no idea what its length
1176 * is, so we punt here.
1180 if ( yyvsp
[-1] <= 0 )
1182 synerr( "iteration value must be positive" );
1187 yyval
= link_machines( yyvsp
[-3],
1188 copysingl( yyvsp
[-3], yyvsp
[-1] - 1 ) );
1192 #line 615 "./parse.y"
1196 /* Create the '.' character class. */
1198 ccladd( anyccl
, '\n' );
1199 cclnegate( anyccl
);
1202 mkeccl( ccltbl
+ cclmap
[anyccl
],
1203 ccllen
[anyccl
], nextecm
,
1204 ecgroup
, csize
, csize
);
1211 yyval
= mkstate( -anyccl
);
1215 #line 637 "./parse.y"
1218 /* Sort characters for fast searching. We
1219 * use a shell sort since this list could
1222 cshell( ccltbl
+ cclmap
[yyvsp
[0]], ccllen
[yyvsp
[0]], true );
1225 mkeccl( ccltbl
+ cclmap
[yyvsp
[0]], ccllen
[yyvsp
[0]],
1226 nextecm
, ecgroup
, csize
, csize
);
1230 yyval
= mkstate( -yyvsp
[0] );
1234 #line 655 "./parse.y"
1238 yyval
= mkstate( -yyvsp
[0] );
1242 #line 662 "./parse.y"
1243 { yyval
= yyvsp
[-1]; }
1246 #line 665 "./parse.y"
1247 { yyval
= yyvsp
[-1]; }
1250 #line 668 "./parse.y"
1254 if ( caseins
&& yyvsp
[0] >= 'A' && yyvsp
[0] <= 'Z' )
1255 yyvsp
[0] = clower( yyvsp
[0] );
1257 yyval
= mkstate( yyvsp
[0] );
1261 #line 679 "./parse.y"
1262 { yyval
= yyvsp
[-1]; }
1265 #line 682 "./parse.y"
1267 cclnegate( yyvsp
[-1] );
1272 #line 689 "./parse.y"
1276 if ( yyvsp
[-2] >= 'A' && yyvsp
[-2] <= 'Z' )
1277 yyvsp
[-2] = clower( yyvsp
[-2] );
1278 if ( yyvsp
[0] >= 'A' && yyvsp
[0] <= 'Z' )
1279 yyvsp
[0] = clower( yyvsp
[0] );
1282 if ( yyvsp
[-2] > yyvsp
[0] )
1283 synerr( "negative range in character class" );
1287 for ( i
= yyvsp
[-2]; i
<= yyvsp
[0]; ++i
)
1288 ccladd( yyvsp
[-3], i
);
1290 /* Keep track if this ccl is staying in
1291 * alphabetical order.
1293 cclsorted
= cclsorted
&& (yyvsp
[-2] > lastchar
);
1294 lastchar
= yyvsp
[0];
1301 #line 717 "./parse.y"
1303 if ( caseins
&& yyvsp
[0] >= 'A' && yyvsp
[0] <= 'Z' )
1304 yyvsp
[0] = clower( yyvsp
[0] );
1306 ccladd( yyvsp
[-1], yyvsp
[0] );
1307 cclsorted
= cclsorted
&& (yyvsp
[0] > lastchar
);
1308 lastchar
= yyvsp
[0];
1313 #line 728 "./parse.y"
1315 /* Too hard to properly maintain cclsorted. */
1321 #line 735 "./parse.y"
1325 currccl
= yyval
= cclinit();
1329 #line 742 "./parse.y"
1330 { CCL_EXPR(isalnum
) }
1333 #line 743 "./parse.y"
1334 { CCL_EXPR(isalpha
) }
1337 #line 744 "./parse.y"
1338 { CCL_EXPR(IS_BLANK
) }
1341 #line 745 "./parse.y"
1342 { CCL_EXPR(iscntrl
) }
1345 #line 746 "./parse.y"
1346 { CCL_EXPR(isdigit
) }
1349 #line 747 "./parse.y"
1350 { CCL_EXPR(isgraph
) }
1353 #line 748 "./parse.y"
1354 { CCL_EXPR(islower
) }
1357 #line 749 "./parse.y"
1358 { CCL_EXPR(isprint
) }
1361 #line 750 "./parse.y"
1362 { CCL_EXPR(ispunct
) }
1365 #line 751 "./parse.y"
1366 { CCL_EXPR(isspace
) }
1369 #line 752 "./parse.y"
1378 #line 758 "./parse.y"
1379 { CCL_EXPR(isxdigit
) }
1382 #line 762 "./parse.y"
1384 if ( caseins
&& yyvsp
[0] >= 'A' && yyvsp
[0] <= 'Z' )
1385 yyvsp
[0] = clower( yyvsp
[0] );
1389 yyval
= link_machines( yyvsp
[-1], mkstate( yyvsp
[0] ) );
1393 #line 772 "./parse.y"
1394 { yyval
= mkstate( SYM_EPSILON
); }
1396 #line 1397 "y.tab.c"
1402 if (yystate
== 0 && yym
== 0)
1406 printf("%sdebug: after reduction, shifting from state 0 to\
1407 state %d\n", YYPREFIX
, YYFINAL
);
1414 if ((yychar
= yylex()) < 0) yychar
= 0;
1419 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1420 if (!yys
) yys
= "illegal-symbol";
1421 printf("%sdebug: state %d, reading %d (%s)\n",
1422 YYPREFIX
, YYFINAL
, yychar
, yys
);
1426 if (yychar
== 0) goto yyaccept
;
1429 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
1430 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
1431 yystate
= yytable
[yyn
];
1433 yystate
= yydgoto
[yym
];
1436 printf("%sdebug: after reduction, shifting from state %d \
1437 to state %d\n", YYPREFIX
, *yyssp
, yystate
);
1439 if (yyssp
>= yyss
+ yystacksize
- 1)
1447 yyerror("yacc stack overflow");