1 /* A Bison parser, made by GNU Bison 2.4.2. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
44 /* Identify Bison output. */
48 #define YYBISON_VERSION "2.4.2"
51 #define YYSKELETON_NAME "yacc.c"
62 /* Using locations. */
63 #define YYLSP_NEEDED 0
67 /* Copy the first part of user declarations. */
69 /* Line 189 of yacc.c */
72 /*===========================================================================
73 Copyright (c) 1998-2000, The Santa Cruz Operation
76 Redistribution and use in source and binary forms, with or without
77 modification, are permitted provided that the following conditions are met:
79 *Redistributions of source code must retain the above copyright notice,
80 this list of conditions and the following disclaimer.
82 *Redistributions in binary form must reproduce the above copyright notice,
83 this list of conditions and the following disclaimer in the documentation
84 and/or other materials provided with the distribution.
86 *Neither name of The Santa Cruz Operation nor the names of its contributors
87 may be used to endorse or promote products derived from this software
88 without specific prior written permission.
90 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
91 IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
92 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
93 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
94 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
95 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
96 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
98 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
99 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
100 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
102 =========================================================================*/
104 /* $Id: egrep.y,v 1.11 2006/04/21 10:45:48 broeker Exp $ */
107 * egrep -- fine lines containing a regular expression
110 /* Line 189 of yacc.c */
117 #include <setjmp.h> /* jmp_buf */
119 #define nextch() (*input++)
126 static char gotofn[NSTATES][NCHARS];
127 static int state[NSTATES];
128 static char out[NSTATES];
129 static unsigned int line;
130 static int name[MAXLIN];
131 static unsigned int left[MAXLIN];
132 static unsigned int right[MAXLIN];
133 static unsigned int parent[MAXLIN];
134 static int foll[MAXLIN];
135 static int positions[MAXPOS];
136 static char chars[MAXLIN];
139 static int tmpstat[MAXLIN];
140 static int initstat[MAXLIN];
147 static jmp_buf env; /* setjmp/longjmp buffer */
148 static char *message; /* error message */
150 /* Internal prototypes: */
151 static void cfoll(int v);
152 static void cgotofn(void);
153 static int cstate(int v);
154 static int member(int symb, int set, int torf);
155 static int notin(int n);
156 static void synerror(void);
157 static void overflo(void);
158 static void add(int *array, int n);
159 static void follow(unsigned int v);
160 static int unary(int x, int d);
161 static int node(int x, int l, int r);
162 static unsigned int cclenter(int x);
163 static unsigned int enter(int x);
165 static int yylex(void);
166 static int yyerror(char *);
169 /* Line 189 of yacc.c */
172 /* Enabling traces. */
177 /* Enabling verbose error messages. */
178 #ifdef YYERROR_VERBOSE
179 # undef YYERROR_VERBOSE
180 # define YYERROR_VERBOSE 1
182 # define YYERROR_VERBOSE 0
185 /* Enabling the token table. */
186 #ifndef YYTOKEN_TABLE
187 # define YYTOKEN_TABLE 0
194 /* Put the tokens into the symbol table, so that GDB and other debuggers
222 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
224 # define YYSTYPE_IS_TRIVIAL 1
225 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
226 # define YYSTYPE_IS_DECLARED 1
230 /* Copy the second part of user declarations. */
233 /* Line 264 of yacc.c */
241 typedef YYTYPE_UINT8 yytype_uint8;
243 typedef unsigned char yytype_uint8;
247 typedef YYTYPE_INT8 yytype_int8;
248 #elif (defined __STDC__ || defined __C99__FUNC__ \
249 || defined __cplusplus || defined _MSC_VER)
250 typedef signed char yytype_int8;
252 typedef short int yytype_int8;
256 typedef YYTYPE_UINT16 yytype_uint16;
258 typedef unsigned short int yytype_uint16;
262 typedef YYTYPE_INT16 yytype_int16;
264 typedef short int yytype_int16;
268 # ifdef __SIZE_TYPE__
269 # define YYSIZE_T __SIZE_TYPE__
270 # elif defined size_t
271 # define YYSIZE_T size_t
272 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
273 || defined __cplusplus || defined _MSC_VER)
274 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
275 # define YYSIZE_T size_t
277 # define YYSIZE_T unsigned int
281 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
284 # if defined YYENABLE_NLS && YYENABLE_NLS
286 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
287 # define YY_(msgid) dgettext ("bison-runtime", msgid)
291 # define YY_(msgid) msgid
295 /* Suppress unused-variable warnings by "using" E. */
296 #if ! defined lint || defined __GNUC__
297 # define YYUSE(e) ((void) (e))
299 # define YYUSE(e) /* empty */
302 /* Identity function, used to suppress warnings about constant conditions. */
306 #if (defined __STDC__ || defined __C99__FUNC__ \
307 || defined __cplusplus || defined _MSC_VER)
320 #if ! defined yyoverflow || YYERROR_VERBOSE
322 /* The parser invokes alloca or malloc; define the necessary symbols. */
324 # ifdef YYSTACK_USE_ALLOCA
325 # if YYSTACK_USE_ALLOCA
327 # define YYSTACK_ALLOC __builtin_alloca
328 # elif defined __BUILTIN_VA_ARG_INCR
329 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
331 # define YYSTACK_ALLOC __alloca
332 # elif defined _MSC_VER
333 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
334 # define alloca _alloca
336 # define YYSTACK_ALLOC alloca
337 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
338 || defined __cplusplus || defined _MSC_VER)
339 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
348 # ifdef YYSTACK_ALLOC
349 /* Pacify GCC's `empty if-body' warning. */
350 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
351 # ifndef YYSTACK_ALLOC_MAXIMUM
352 /* The OS might guarantee only one guard page at the bottom of the stack,
353 and a page size can be as small as 4096 bytes. So we cannot safely
354 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
355 to allow for a few compiler-allocated temporary stack slots. */
356 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
359 # define YYSTACK_ALLOC YYMALLOC
360 # define YYSTACK_FREE YYFREE
361 # ifndef YYSTACK_ALLOC_MAXIMUM
362 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
364 # if (defined __cplusplus && ! defined _STDLIB_H \
365 && ! ((defined YYMALLOC || defined malloc) \
366 && (defined YYFREE || defined free)))
367 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
373 # define YYMALLOC malloc
374 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
375 || defined __cplusplus || defined _MSC_VER)
376 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
381 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
382 || defined __cplusplus || defined _MSC_VER)
383 void free (void *); /* INFRINGES ON USER NAME SPACE */
387 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
390 #if (! defined yyoverflow \
391 && (! defined __cplusplus \
392 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
394 /* A type that is properly aligned for any stack member. */
397 yytype_int16 yyss_alloc;
401 /* The size of the maximum gap between one aligned stack and the next. */
402 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
404 /* The size of an array large to enough to hold all stacks, each with
406 # define YYSTACK_BYTES(N) \
407 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
408 + YYSTACK_GAP_MAXIMUM)
410 /* Copy COUNT objects from FROM to TO. The source and destination do
413 # if defined __GNUC__ && 1 < __GNUC__
414 # define YYCOPY(To, From, Count) \
415 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
417 # define YYCOPY(To, From, Count) \
421 for (yyi = 0; yyi < (Count); yyi++) \
422 (To)[yyi] = (From)[yyi]; \
428 /* Relocate STACK from its old location to the new one. The
429 local variables YYSIZE and YYSTACKSIZE give the old and new number of
430 elements in the stack, and YYPTR gives the new location of the
431 stack. Advance YYPTR to a properly aligned location for the next
433 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
436 YYSIZE_T yynewbytes; \
437 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
438 Stack = &yyptr->Stack_alloc; \
439 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
440 yyptr += yynewbytes / sizeof (*yyptr); \
446 /* YYFINAL -- State number of the termination state. */
448 /* YYLAST -- Last index in YYTABLE. */
451 /* YYNTOKENS -- Number of terminals. */
453 /* YYNNTS -- Number of nonterminals. */
455 /* YYNRULES -- Number of rules. */
457 /* YYNRULES -- Number of states. */
460 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
462 #define YYMAXUTOK 266
464 #define YYTRANSLATE(YYX) \
465 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
467 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
468 static const yytype_uint8 yytranslate[] =
470 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 12, 13, 2, 2, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
496 5, 6, 7, 8, 9, 10, 11
500 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
502 static const yytype_uint8 yyprhs[] =
504 0, 0, 3, 5, 8, 13, 17, 21, 22, 24,
505 26, 28, 30, 34, 37, 40, 43, 46, 50
508 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
509 static const yytype_int8 yyrhs[] =
511 15, 0, -1, 16, -1, 17, 18, -1, 7, 17,
512 18, 7, -1, 7, 17, 18, -1, 17, 18, 7,
513 -1, -1, 3, -1, 4, -1, 5, -1, 6, -1,
514 18, 7, 18, -1, 18, 18, -1, 18, 9, -1,
515 18, 10, -1, 18, 11, -1, 12, 18, 13, -1,
519 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
520 static const yytype_uint8 yyrline[] =
522 0, 105, 105, 110, 112, 114, 116, 120, 123, 125,
523 127, 129, 133, 135, 137, 139, 141, 143, 145
527 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
528 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
529 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
530 static const char *const yytname[] =
532 "$end", "error", "$undefined", "CHAR", "DOT", "CCL", "NCCL", "OR",
533 "CAT", "STAR", "PLUS", "QUEST", "'('", "')'", "$accept", "s", "t", "b",
539 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
541 static const yytype_uint16 yytoknum[] =
543 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
548 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
549 static const yytype_uint8 yyr1[] =
551 0, 14, 15, 16, 16, 16, 16, 17, 18, 18,
552 18, 18, 18, 18, 18, 18, 18, 18, 18
555 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
556 static const yytype_uint8 yyr2[] =
558 0, 2, 1, 2, 4, 3, 3, 0, 1, 1,
559 1, 1, 3, 2, 2, 2, 2, 3, 1
562 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
563 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
564 means the default is an error. */
565 static const yytype_uint8 yydefact[] =
567 7, 7, 0, 2, 0, 0, 1, 18, 8, 9,
568 10, 11, 0, 0, 0, 0, 0, 14, 15, 16,
572 /* YYDEFGOTO[NTERM-NUM]. */
573 static const yytype_int8 yydefgoto[] =
578 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
580 #define YYPACT_NINF -5
581 static const yytype_int8 yypact[] =
583 2, -5, 3, -5, 1, 1, -5, -5, -5, -5,
584 -5, -5, 1, 47, 60, 72, 86, -5, -5, -5,
588 /* YYPGOTO[NTERM-NUM]. */
589 static const yytype_int8 yypgoto[] =
594 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
595 positive, shift that token. If negative, reduce the rule which
596 number is the opposite. If zero, do what YYDEFACT says.
597 If YYTABLE_NINF, syntax error. */
598 #define YYTABLE_NINF -14
599 static const yytype_int8 yytable[] =
601 13, 14, 7, 6, 8, 9, 10, 11, 15, 1,
602 5, 0, 24, 12, 0, 0, 0, 24, 24, -13,
603 7, 0, -13, -13, -13, -13, -13, 0, 17, 18,
604 19, -13, -13, -12, 7, 0, 8, 9, 10, 11,
605 -12, 0, 17, 18, 19, 12, -12, -3, 7, 0,
606 8, 9, 10, 11, 16, 0, 17, 18, 19, 12,
607 -5, 7, 0, 8, 9, 10, 11, 21, 0, 17,
608 18, 19, 12, 7, 0, 8, 9, 10, 11, 22,
609 0, 17, 18, 19, 12, 23, -6, 7, 0, 8,
610 9, 10, 11, 0, 0, 0, -4, 7, 12, 8,
611 9, 10, 11, 0, 0, 0, 0, 0, 12
614 static const yytype_int8 yycheck[] =
616 4, 5, 1, 0, 3, 4, 5, 6, 12, 7,
617 1, -1, 16, 12, -1, -1, -1, 21, 22, 0,
618 1, -1, 3, 4, 5, 6, 7, -1, 9, 10,
619 11, 12, 13, 0, 1, -1, 3, 4, 5, 6,
620 7, -1, 9, 10, 11, 12, 13, 0, 1, -1,
621 3, 4, 5, 6, 7, -1, 9, 10, 11, 12,
622 0, 1, -1, 3, 4, 5, 6, 7, -1, 9,
623 10, 11, 12, 1, -1, 3, 4, 5, 6, 7,
624 -1, 9, 10, 11, 12, 13, 0, 1, -1, 3,
625 4, 5, 6, -1, -1, -1, 0, 1, 12, 3,
626 4, 5, 6, -1, -1, -1, -1, -1, 12
629 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
630 symbol of state STATE-NUM. */
631 static const yytype_uint8 yystos[] =
633 0, 7, 15, 16, 17, 17, 0, 1, 3, 4,
634 5, 6, 12, 18, 18, 18, 7, 9, 10, 11,
638 #define yyerrok (yyerrstatus = 0)
639 #define yyclearin (yychar = YYEMPTY)
643 #define YYACCEPT goto yyacceptlab
644 #define YYABORT goto yyabortlab
645 #define YYERROR goto yyerrorlab
648 /* Like YYERROR except do call yyerror. This remains here temporarily
649 to ease the transition to the new meaning of YYERROR, for GCC.
650 Once GCC version 2 has supplanted version 1, this can go. However,
651 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
652 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
655 #define YYFAIL goto yyerrlab
657 /* This is here to suppress warnings from the GCC cpp's
658 -Wunused-macros. Normally we don't worry about that warning, but
659 some users do, and we want to make it easy for users to remove
660 YYFAIL uses, which will produce warnings from Bison 2.5. */
663 #define YYRECOVERING() (!!yyerrstatus)
665 #define YYBACKUP(Token, Value) \
667 if (yychar == YYEMPTY && yylen == 1) \
671 yytoken = YYTRANSLATE (yychar); \
677 yyerror (YY_("syntax error: cannot back up")); \
684 #define YYERRCODE 256
687 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
688 If N is 0, then set CURRENT to the empty location which ends
689 the previous symbol: RHS[0] (always defined). */
691 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
692 #ifndef YYLLOC_DEFAULT
693 # define YYLLOC_DEFAULT(Current, Rhs, N) \
697 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
698 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
699 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
700 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
704 (Current).first_line = (Current).last_line = \
705 YYRHSLOC (Rhs, 0).last_line; \
706 (Current).first_column = (Current).last_column = \
707 YYRHSLOC (Rhs, 0).last_column; \
713 /* YY_LOCATION_PRINT -- Print the location on the stream.
714 This macro was not mandated originally: define only if we know
715 we won't break user code: when these are the locations we know. */
717 #ifndef YY_LOCATION_PRINT
718 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
719 # define YY_LOCATION_PRINT(File, Loc) \
720 fprintf (File, "%d.%d-%d.%d", \
721 (Loc).first_line, (Loc).first_column, \
722 (Loc).last_line, (Loc).last_column)
724 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
729 /* YYLEX -- calling `yylex' with the right arguments. */
732 # define YYLEX yylex (YYLEX_PARAM)
734 # define YYLEX yylex ()
737 /* Enable debugging if requested. */
741 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
742 # define YYFPRINTF fprintf
745 # define YYDPRINTF(Args) \
751 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
755 YYFPRINTF (stderr, "%s ", Title); \
756 yy_symbol_print (stderr, \
758 YYFPRINTF (stderr, "\n"); \
763 /*--------------------------------.
764 | Print this symbol on YYOUTPUT. |
765 `--------------------------------*/
768 #if (defined __STDC__ || defined __C99__FUNC__ \
769 || defined __cplusplus || defined _MSC_VER)
771 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
774 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
777 YYSTYPE const * const yyvaluep;
783 if (yytype < YYNTOKENS)
784 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
796 /*--------------------------------.
797 | Print this symbol on YYOUTPUT. |
798 `--------------------------------*/
800 #if (defined __STDC__ || defined __C99__FUNC__ \
801 || defined __cplusplus || defined _MSC_VER)
803 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
806 yy_symbol_print (yyoutput, yytype, yyvaluep)
809 YYSTYPE const * const yyvaluep;
812 if (yytype < YYNTOKENS)
813 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
815 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
817 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
818 YYFPRINTF (yyoutput, ")");
821 /*------------------------------------------------------------------.
822 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
824 `------------------------------------------------------------------*/
826 #if (defined __STDC__ || defined __C99__FUNC__ \
827 || defined __cplusplus || defined _MSC_VER)
829 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
832 yy_stack_print (yybottom, yytop)
833 yytype_int16 *yybottom;
837 YYFPRINTF (stderr, "Stack now");
838 for (; yybottom <= yytop; yybottom++)
840 int yybot = *yybottom;
841 YYFPRINTF (stderr, " %d", yybot);
843 YYFPRINTF (stderr, "\n");
846 # define YY_STACK_PRINT(Bottom, Top) \
849 yy_stack_print ((Bottom), (Top)); \
853 /*------------------------------------------------.
854 | Report that the YYRULE is going to be reduced. |
855 `------------------------------------------------*/
857 #if (defined __STDC__ || defined __C99__FUNC__ \
858 || defined __cplusplus || defined _MSC_VER)
860 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
863 yy_reduce_print (yyvsp, yyrule)
868 int yynrhs = yyr2[yyrule];
870 unsigned long int yylno = yyrline[yyrule];
871 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
873 /* The symbols being reduced. */
874 for (yyi = 0; yyi < yynrhs; yyi++)
876 YYFPRINTF (stderr, " $%d = ", yyi + 1);
877 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
878 &(yyvsp[(yyi + 1) - (yynrhs)])
880 YYFPRINTF (stderr, "\n");
884 # define YY_REDUCE_PRINT(Rule) \
887 yy_reduce_print (yyvsp, Rule); \
890 /* Nonzero means print parse trace. It is left uninitialized so that
891 multiple parsers can coexist. */
894 # define YYDPRINTF(Args)
895 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
896 # define YY_STACK_PRINT(Bottom, Top)
897 # define YY_REDUCE_PRINT(Rule)
898 #endif /* !YYDEBUG */
901 /* YYINITDEPTH -- initial size of the parser's stacks. */
903 # define YYINITDEPTH 200
906 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
907 if the built-in stack extension method is used).
909 Do not make this value too large; the results are undefined if
910 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
911 evaluated with infinite-precision integer arithmetic. */
914 # define YYMAXDEPTH 10000
922 # if defined __GLIBC__ && defined _STRING_H
923 # define yystrlen strlen
925 /* Return the length of YYSTR. */
926 #if (defined __STDC__ || defined __C99__FUNC__ \
927 || defined __cplusplus || defined _MSC_VER)
929 yystrlen (const char *yystr)
937 for (yylen = 0; yystr[yylen]; yylen++)
945 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
946 # define yystpcpy stpcpy
948 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
950 #if (defined __STDC__ || defined __C99__FUNC__ \
951 || defined __cplusplus || defined _MSC_VER)
953 yystpcpy (char *yydest, const char *yysrc)
956 yystpcpy (yydest, yysrc)
962 const char *yys = yysrc;
964 while ((*yyd++ = *yys++) != '\0')
973 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
974 quotes and backslashes, so that it's suitable for yyerror. The
975 heuristic is that double-quoting is unnecessary unless the string
976 contains an apostrophe, a comma, or backslash (other than
977 backslash-backslash). YYSTR is taken from yytname. If YYRES is
978 null, do not copy; instead, return the length of what the result
981 yytnamerr (char *yyres, const char *yystr)
986 char const *yyp = yystr;
993 goto do_not_strip_quotes;
997 goto do_not_strip_quotes;
1010 do_not_strip_quotes: ;
1014 return yystrlen (yystr);
1016 return yystpcpy (yyres, yystr) - yyres;
1020 /* Copy into YYRESULT an error message about the unexpected token
1021 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1022 including the terminating null byte. If YYRESULT is null, do not
1023 copy anything; just return the number of bytes that would be
1024 copied. As a special case, return 0 if an ordinary "syntax error"
1025 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1026 size calculation. */
1028 yysyntax_error (char *yyresult, int yystate, int yychar)
1030 int yyn = yypact[yystate];
1032 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1036 int yytype = YYTRANSLATE (yychar);
1037 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1038 YYSIZE_T yysize = yysize0;
1040 int yysize_overflow = 0;
1041 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1042 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1046 /* This is so xgettext sees the translatable formats that are
1047 constructed on the fly. */
1048 YY_("syntax error, unexpected %s");
1049 YY_("syntax error, unexpected %s, expecting %s");
1050 YY_("syntax error, unexpected %s, expecting %s or %s");
1051 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1052 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1056 static char const yyunexpected[] = "syntax error, unexpected %s";
1057 static char const yyexpecting[] = ", expecting %s";
1058 static char const yyor[] = " or %s";
1059 char yyformat[sizeof yyunexpected
1060 + sizeof yyexpecting - 1
1061 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1062 * (sizeof yyor - 1))];
1063 char const *yyprefix = yyexpecting;
1065 /* Start YYX at -YYN if negative to avoid negative indexes in
1067 int yyxbegin = yyn < 0 ? -yyn : 0;
1069 /* Stay within bounds of both yycheck and yytname. */
1070 int yychecklim = YYLAST - yyn + 1;
1071 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1074 yyarg[0] = yytname[yytype];
1075 yyfmt = yystpcpy (yyformat, yyunexpected);
1077 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1078 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1080 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1084 yyformat[sizeof yyunexpected - 1] = '\0';
1087 yyarg[yycount++] = yytname[yyx];
1088 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1089 yysize_overflow |= (yysize1 < yysize);
1091 yyfmt = yystpcpy (yyfmt, yyprefix);
1095 yyf = YY_(yyformat);
1096 yysize1 = yysize + yystrlen (yyf);
1097 yysize_overflow |= (yysize1 < yysize);
1100 if (yysize_overflow)
1101 return YYSIZE_MAXIMUM;
1105 /* Avoid sprintf, as that infringes on the user's name space.
1106 Don't have undefined behavior even if the translation
1107 produced a string with the wrong number of "%s"s. */
1108 char *yyp = yyresult;
1110 while ((*yyp = *yyf) != '\0')
1112 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1114 yyp += yytnamerr (yyp, yyarg[yyi++]);
1127 #endif /* YYERROR_VERBOSE */
1130 /*-----------------------------------------------.
1131 | Release the memory associated to this symbol. |
1132 `-----------------------------------------------*/
1135 #if (defined __STDC__ || defined __C99__FUNC__ \
1136 || defined __cplusplus || defined _MSC_VER)
1138 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1141 yydestruct (yymsg, yytype, yyvaluep)
1151 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1161 /* Prevent warnings from -Wmissing-prototypes. */
1162 #ifdef YYPARSE_PARAM
1163 #if defined __STDC__ || defined __cplusplus
1164 int yyparse (void *YYPARSE_PARAM);
1168 #else /* ! YYPARSE_PARAM */
1169 #if defined __STDC__ || defined __cplusplus
1174 #endif /* ! YYPARSE_PARAM */
1177 /* The lookahead symbol. */
1180 /* The semantic value of the lookahead symbol. */
1183 /* Number of syntax errors so far. */
1188 /*-------------------------.
1189 | yyparse or yypush_parse. |
1190 `-------------------------*/
1192 #ifdef YYPARSE_PARAM
1193 #if (defined __STDC__ || defined __C99__FUNC__ \
1194 || defined __cplusplus || defined _MSC_VER)
1196 yyparse (void *YYPARSE_PARAM)
1199 yyparse (YYPARSE_PARAM)
1200 void *YYPARSE_PARAM;
1202 #else /* ! YYPARSE_PARAM */
1203 #if (defined __STDC__ || defined __C99__FUNC__ \
1204 || defined __cplusplus || defined _MSC_VER)
1217 /* Number of tokens to shift before error messages enabled. */
1220 /* The stacks and their tools:
1221 `yyss': related to states.
1222 `yyvs': related to semantic values.
1224 Refer to the stacks thru separate pointers, to allow yyoverflow
1225 to reallocate them elsewhere. */
1227 /* The state stack. */
1228 yytype_int16 yyssa[YYINITDEPTH];
1230 yytype_int16 *yyssp;
1232 /* The semantic value stack. */
1233 YYSTYPE yyvsa[YYINITDEPTH];
1237 YYSIZE_T yystacksize;
1241 /* Lookahead token as an internal (translated) token number. */
1243 /* The variables used to return semantic value and location from the
1248 /* Buffer for error messages, and its allocated size. */
1250 char *yymsg = yymsgbuf;
1251 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1254 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1256 /* The number of symbols on the RHS of the reduced rule.
1257 Keep to zero when no symbol should be popped. */
1263 yystacksize = YYINITDEPTH;
1265 YYDPRINTF ((stderr, "Starting parse\n"));
1270 yychar = YYEMPTY; /* Cause a token to be read. */
1272 /* Initialize stack pointers.
1273 Waste one element of value and location stack
1274 so that they stay on the same level as the state stack.
1275 The wasted elements are never initialized. */
1281 /*------------------------------------------------------------.
1282 | yynewstate -- Push a new state, which is found in yystate. |
1283 `------------------------------------------------------------*/
1285 /* In all cases, when you get here, the value and location stacks
1286 have just been pushed. So pushing a state here evens the stacks. */
1292 if (yyss + yystacksize - 1 <= yyssp)
1294 /* Get the current used size of the three stacks, in elements. */
1295 YYSIZE_T yysize = yyssp - yyss + 1;
1299 /* Give user a chance to reallocate the stack. Use copies of
1300 these so that the &'s don't force the real ones into
1302 YYSTYPE *yyvs1 = yyvs;
1303 yytype_int16 *yyss1 = yyss;
1305 /* Each stack pointer address is followed by the size of the
1306 data in use in that stack, in bytes. This used to be a
1307 conditional around just the two extra args, but that might
1308 be undefined if yyoverflow is a macro. */
1309 yyoverflow (YY_("memory exhausted"),
1310 &yyss1, yysize * sizeof (*yyssp),
1311 &yyvs1, yysize * sizeof (*yyvsp),
1317 #else /* no yyoverflow */
1318 # ifndef YYSTACK_RELOCATE
1319 goto yyexhaustedlab;
1321 /* Extend the stack our own way. */
1322 if (YYMAXDEPTH <= yystacksize)
1323 goto yyexhaustedlab;
1325 if (YYMAXDEPTH < yystacksize)
1326 yystacksize = YYMAXDEPTH;
1329 yytype_int16 *yyss1 = yyss;
1330 union yyalloc *yyptr =
1331 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1333 goto yyexhaustedlab;
1334 YYSTACK_RELOCATE (yyss_alloc, yyss);
1335 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1336 # undef YYSTACK_RELOCATE
1338 YYSTACK_FREE (yyss1);
1341 #endif /* no yyoverflow */
1343 yyssp = yyss + yysize - 1;
1344 yyvsp = yyvs + yysize - 1;
1346 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1347 (unsigned long int) yystacksize));
1349 if (yyss + yystacksize - 1 <= yyssp)
1353 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1355 if (yystate == YYFINAL)
1365 /* Do appropriate processing given the current state. Read a
1366 lookahead token if we need one and don't already have one. */
1368 /* First try to decide what to do without reference to lookahead token. */
1369 yyn = yypact[yystate];
1370 if (yyn == YYPACT_NINF)
1373 /* Not known => get a lookahead token if don't already have one. */
1375 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1376 if (yychar == YYEMPTY)
1378 YYDPRINTF ((stderr, "Reading a token: "));
1382 if (yychar <= YYEOF)
1384 yychar = yytoken = YYEOF;
1385 YYDPRINTF ((stderr, "Now at end of input.\n"));
1389 yytoken = YYTRANSLATE (yychar);
1390 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1393 /* If the proper action on seeing token YYTOKEN is to reduce or to
1394 detect an error, take that action. */
1396 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1401 if (yyn == 0 || yyn == YYTABLE_NINF)
1407 /* Count tokens shifted since error; after three, turn off error
1412 /* Shift the lookahead token. */
1413 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1415 /* Discard the shifted token. */
1424 /*-----------------------------------------------------------.
1425 | yydefault -- do the default action for the current state. |
1426 `-----------------------------------------------------------*/
1428 yyn = yydefact[yystate];
1434 /*-----------------------------.
1435 | yyreduce -- Do a reduction. |
1436 `-----------------------------*/
1438 /* yyn is the number of a rule to reduce with. */
1441 /* If YYLEN is nonzero, implement the default value of the action:
1444 Otherwise, the following line sets YYVAL to garbage.
1445 This behavior is undocumented and Bison
1446 users should not rely upon it. Assigning to YYVAL
1447 unconditionally makes the parser a bit smaller, and it avoids a
1448 GCC warning that YYVAL may be used uninitialized. */
1449 yyval = yyvsp[1-yylen];
1452 YY_REDUCE_PRINT (yyn);
1457 /* Line 1464 of yacc.c */
1459 { unary(FINAL, (yyvsp[(1) - (1)]));
1466 /* Line 1464 of yacc.c */
1468 { (yyval) = node(CAT, (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); }
1473 /* Line 1464 of yacc.c */
1475 { (yyval) = node(CAT, (yyvsp[(2) - (4)]), (yyvsp[(3) - (4)])); }
1480 /* Line 1464 of yacc.c */
1482 { (yyval) = node(CAT, (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)])); }
1487 /* Line 1464 of yacc.c */
1489 { (yyval) = node(CAT, (yyvsp[(1) - (3)]), (yyvsp[(2) - (3)])); }
1494 /* Line 1464 of yacc.c */
1496 { (yyval) = enter(DOT);
1497 (yyval) = unary(STAR, (yyval)); }
1502 /* Line 1464 of yacc.c */
1504 { (yyval) = enter((yyvsp[(1) - (1)])); }
1509 /* Line 1464 of yacc.c */
1511 { (yyval) = enter(DOT); }
1516 /* Line 1464 of yacc.c */
1518 { (yyval) = cclenter(CCL); }
1523 /* Line 1464 of yacc.c */
1525 { (yyval) = cclenter(NCCL); }
1530 /* Line 1464 of yacc.c */
1532 { (yyval) = node(OR, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); }
1537 /* Line 1464 of yacc.c */
1539 { (yyval) = node(CAT, (yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); }
1544 /* Line 1464 of yacc.c */
1546 { (yyval) = unary(STAR, (yyvsp[(1) - (2)])); }
1551 /* Line 1464 of yacc.c */
1553 { (yyval) = unary(PLUS, (yyvsp[(1) - (2)])); }
1558 /* Line 1464 of yacc.c */
1560 { (yyval) = unary(QUEST, (yyvsp[(1) - (2)])); }
1565 /* Line 1464 of yacc.c */
1567 { (yyval) = (yyvsp[(2) - (3)]); }
1572 /* Line 1464 of yacc.c */
1573 #line 1574 "egrep.c"
1576 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1580 YY_STACK_PRINT (yyss, yyssp);
1584 /* Now `shift' the result of the reduction. Determine what state
1585 that goes to, based on the state we popped back to and the rule
1586 number reduced by. */
1590 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1591 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1592 yystate = yytable[yystate];
1594 yystate = yydefgoto[yyn - YYNTOKENS];
1599 /*------------------------------------.
1600 | yyerrlab -- here on detecting error |
1601 `------------------------------------*/
1603 /* If not already recovering from an error, report this error. */
1607 #if ! YYERROR_VERBOSE
1608 yyerror (YY_("syntax error"));
1611 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1612 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1614 YYSIZE_T yyalloc = 2 * yysize;
1615 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1616 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1617 if (yymsg != yymsgbuf)
1618 YYSTACK_FREE (yymsg);
1619 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1621 yymsg_alloc = yyalloc;
1625 yymsg_alloc = sizeof yymsgbuf;
1629 if (0 < yysize && yysize <= yymsg_alloc)
1631 (void) yysyntax_error (yymsg, yystate, yychar);
1636 yyerror (YY_("syntax error"));
1638 goto yyexhaustedlab;
1646 if (yyerrstatus == 3)
1648 /* If just tried and failed to reuse lookahead token after an
1649 error, discard it. */
1651 if (yychar <= YYEOF)
1653 /* Return failure if at end of input. */
1654 if (yychar == YYEOF)
1659 yydestruct ("Error: discarding",
1665 /* Else will try to reuse lookahead token after shifting the error
1670 /*---------------------------------------------------.
1671 | yyerrorlab -- error raised explicitly by YYERROR. |
1672 `---------------------------------------------------*/
1675 /* Pacify compilers like GCC when the user code never invokes
1676 YYERROR and the label yyerrorlab therefore never appears in user
1678 if (/*CONSTCOND*/ 0)
1681 /* Do not reclaim the symbols of the rule which action triggered
1685 YY_STACK_PRINT (yyss, yyssp);
1690 /*-------------------------------------------------------------.
1691 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1692 `-------------------------------------------------------------*/
1694 yyerrstatus = 3; /* Each real token shifted decrements this. */
1698 yyn = yypact[yystate];
1699 if (yyn != YYPACT_NINF)
1702 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1710 /* Pop the current state because it cannot handle the error token. */
1715 yydestruct ("Error: popping",
1716 yystos[yystate], yyvsp);
1719 YY_STACK_PRINT (yyss, yyssp);
1725 /* Shift the error token. */
1726 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1732 /*-------------------------------------.
1733 | yyacceptlab -- YYACCEPT comes here. |
1734 `-------------------------------------*/
1739 /*-----------------------------------.
1740 | yyabortlab -- YYABORT comes here. |
1741 `-----------------------------------*/
1746 #if !defined(yyoverflow) || YYERROR_VERBOSE
1747 /*-------------------------------------------------.
1748 | yyexhaustedlab -- memory exhaustion comes here. |
1749 `-------------------------------------------------*/
1751 yyerror (YY_("memory exhausted"));
1757 if (yychar != YYEMPTY)
1758 yydestruct ("Cleanup: discarding lookahead",
1760 /* Do not reclaim the symbols of the rule which action triggered
1761 this YYABORT or YYACCEPT. */
1763 YY_STACK_PRINT (yyss, yyssp);
1764 while (yyssp != yyss)
1766 yydestruct ("Cleanup: popping",
1767 yystos[*yyssp], yyvsp);
1772 YYSTACK_FREE (yyss);
1775 if (yymsg != yymsgbuf)
1776 YYSTACK_FREE (yymsg);
1778 /* Make sure YYID is used. */
1779 return YYID (yyresult);
1784 /* Line 1684 of yacc.c */
1792 return 1; /* silence a warning */
1801 switch(c = nextch()) {
1824 if ((c = nextch()) == '^') {
1833 && chars[nxtchar-1] != 0) {
1834 if ((d = nextch()) != 0) {
1835 c = chars[nxtchar-1];
1836 while ((unsigned int)c < (unsigned int)d) {
1837 if (nxtchar >= MAXLIN)
1839 chars[nxtchar++] = ++c;
1845 if (nxtchar >= MAXLIN)
1847 chars[nxtchar++] = c;
1849 } while ((c = nextch()) != ']');
1850 chars[count] = cclcnt;
1853 if ((c = nextch()) == '\0')
1869 yyerror("Syntax error");
1889 right[linno] = count;
1894 node(int x, int l, int r)
1921 yyerror("internal table overflow");
1931 for (i = 1; i <= line; i++)
1935 } else if (right[v] == 0)
1946 unsigned int i, n, s;
1948 char symbol[NCHARS];
1949 unsigned int j, l, pc, pos;
1952 unsigned int num, number, newpos;
1955 for (n=3; n<=line; n++)
1957 if (cstate(line-1)==0) {
1962 for (n=3; n<=line; n++)
1963 initstat[n] = tmpstat[n];
1964 count--; /*leave out position 1 */
1969 for (s = 0; s <= n; s++) {
1972 for (i = 0; i < NCHARS; i++)
1974 num = positions[state[s]];
1976 for (i = 3; i <= line; i++)
1977 tmpstat[i] = initstat[i];
1979 for (i = 0; i < num; i++) {
1980 curpos = positions[pos];
1981 if ((c = name[curpos]) >= 0) {
1984 } else if (c == DOT) {
1985 for (k = 0; k < NCHARS; k++)
1988 } else if (c == CCL) {
1989 nc = chars[right[curpos]];
1990 pc = right[curpos] + 1;
1991 for (j = 0; j < nc; j++)
1992 symbol[(unsigned char)(chars[pc++])] = 1;
1993 } else if (c == NCCL) {
1994 nc = chars[right[curpos]];
1995 for (j = 0; j < NCHARS; j++) {
1996 pc = right[curpos] + 1;
1997 for (l = 0; l < nc; l++)
1998 if (j==(unsigned char)(chars[pc++]))
2009 for (c=0; c<NCHARS; c++) {
2010 if (symbol[c] == 1) {
2011 /* nextstate(s,c) */
2013 for (i=3; i <= line; i++)
2014 tmpstat[i] = initstat[i];
2016 for (i=0; i<num; i++) {
2017 curpos = positions[pos];
2018 if ((k = name[curpos]) >= 0)
2021 || (k == CCL && member(c, right[curpos], 1))
2022 || (k == NCCL && member(c, right[curpos], 0))
2024 number = positions[foll[curpos]];
2025 newpos = foll[curpos] + 1;
2026 for (j = 0; j < number; j++) {
2027 if (tmpstat[positions[newpos]] != 1) {
2028 tmpstat[positions[newpos]] = 1;
2035 } /* end nextstate */
2040 if (tmpstat[line] == 1)
2044 gotofn[s][c] = xstate;
2056 if (tmpstat[v] != 1) {
2062 else if (right[v] == 0) {
2063 if (cstate(left[v]) == 0) return (0);
2064 else if (name[v] == PLUS) return (1);
2067 else if (name[v] == CAT) {
2068 if (cstate(left[v]) == 0 && cstate(right[v]) == 0) return (0);
2071 else { /* name[v] == OR */
2072 b = cstate(right[v]);
2073 if (cstate(left[v]) == 0 || b == 0) return (0);
2079 member(int symb, int set, int torf)
2081 unsigned int i, num, pos;
2085 for (i = 0; i < num; i++)
2086 if (symb == (unsigned char)(chars[pos++]))
2095 for (i=0; i<=n; i++) {
2096 if (positions[state[i]] == count) {
2098 for (j=0; j < count; j++)
2099 if (tmpstat[positions[pos++]] != 1) goto nxt;
2109 add(int *array, int n)
2113 if (nxtpos + count > MAXPOS)
2116 positions[nxtpos++] = count;
2117 for (i=3; i <= line; i++) {
2118 if (tmpstat[i] == 1) {
2119 positions[nxtpos++] = i;
2125 follow(unsigned int v)
2134 case PLUS: cstate(v);
2139 case QUEST: follow(p);
2144 if (cstate(right[p]) == 0) {
2152 if (tmpstat[line] != 1) {
2161 egrepinit(char *egreppat)
2163 /* initialize the global data */
2164 memset(gotofn, 0, sizeof(gotofn));
2165 memset(state, 0, sizeof(state));
2166 memset(out, 0, sizeof(out));
2168 memset(name, 0, sizeof(name));
2169 memset(left, 0, sizeof(left));
2170 memset(right, 0, sizeof(right));
2171 memset(parent, 0, sizeof(parent));
2172 memset(foll, 0, sizeof(foll));
2173 memset(positions, 0, sizeof(positions));
2174 memset(chars, 0, sizeof(chars));
2177 memset(tmpstat, 0, sizeof(tmpstat));
2178 memset(initstat, 0, sizeof(initstat));
2184 if (setjmp(env) == 0) {
2193 egrep(char *file, FILE *output, char *format)
2204 if ((fptr = myfopen(file, "r")) == NULL)
2212 if ((ccount = fread(p, sizeof(char), BUFSIZ, fptr)) <= 0)
2215 istat = cstat = (unsigned int) gotofn[0]['\n'];
2220 cstat = (unsigned int) gotofn[cstat][(unsigned int)*p&0377];
2221 /* all input chars made positive */
2223 cstat = (unsigned int) gotofn[cstat][tolower((int)*p&0377)];
2231 fprintf(output, format, file, lnum);
2233 while (nlp < &buf[2*BUFSIZ])
2234 putc(*nlp++, output);
2238 putc(*nlp++, output);
2241 if ((out[(cstat=istat)]) == 0)
2243 } /* if (p++ == \n) */
2245 if (--ccount <= 0) {
2246 if (p <= &buf[BUFSIZ]) {
2247 ccount = fread(p, sizeof(char), BUFSIZ, fptr);
2248 } else if (p == &buf[2*BUFSIZ]) {
2250 ccount = fread(p, sizeof(char), BUFSIZ, fptr);
2252 ccount = fread(p, sizeof(char), &buf[2*BUFSIZ] - p,
2262 } /* if(ccount <= 0) */
2265 } /* if(out[cstat]) */
2271 if (out[(cstat=istat)])
2275 if (--ccount <= 0) {
2276 if (p <= &buf[BUFSIZ]) {
2277 ccount = fread(p, sizeof(char), BUFSIZ, fptr);
2278 } else if (p == &buf[2*BUFSIZ]) {
2280 ccount = fread(p, sizeof(char), BUFSIZ, fptr);
2282 ccount = fread(p, sizeof(char), &buf[2*BUFSIZ] - p, fptr);
2294 /* FIXME HBB: should export this to a separate file and use
2295 * AC_REPLACE_FUNCS() */
2296 #if !STDC_HEADERS && !defined(HAVE_MEMSET) && !defined(HAVE_MEMORY_H)
2299 * Set an array of n chars starting at sp to the character c.
2303 memset(char *sp, char c, int n)
2314 egrepcaseless(int i)
2316 iflag = i; /* simulate "egrep -i" */