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