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