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