1 /* A Bison parser, made by GNU Bison 2.5. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "2.5"
50 #define YYSKELETON_NAME "yacc.c"
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
64 /* Substitute the variable and function names. */
65 #define yyparse zzparse
67 #define yyerror zzerror
70 #define yydebug zzdebug
71 #define yynerrs zznerrs
74 /* Copy the first part of user declarations. */
76 /* Line 268 of yacc.c */
87 static int yylex(void);
88 static void yyerror(const char *mesg, ...);
90 static int find_command(const char *token, size_t toklen);
92 static int want_nodeval = FALSE;
94 static int cmd_idx = -1; /* index of current command in cmd table */
95 static int repeat_idx = -1; /* index of last repeatable command in command table */
96 static CMDARG *arg_list = NULL; /* list of arguments */
97 static long errcount = 0;
98 static char *lexptr_begin = NULL;
99 static int in_commands = FALSE;
102 static int in_eval = FALSE;
103 static const char start_EVAL[] = "function @eval(){";
104 static const char end_EVAL[] = "}";
105 static CMDARG *append_statement(CMDARG *alist, char *stmt);
106 static char *next_word(char *p, int len, char **endp);
107 static NODE *concat_args(CMDARG *a, int count);
109 #ifdef HAVE_LIBREADLINE
110 static void history_expand_line(char **line);
111 static char *command_generator(const char *text, int state);
112 static char *srcfile_generator(const char *text, int state);
113 static char *argument_generator(const char *text, int state);
114 static char *variable_generator(const char *text, int state);
115 extern char *option_generator(const char *text, int state);
116 static int this_cmd = D_illegal;
118 #define history_expand_line(p) /* nothing */
119 static int rl_inhibit_completion; /* dummy variable */
125 enum nametypeval value;
129 * These two should be static, but there are some compilers that
130 * don't like the static keyword with an empty size. Therefore give
131 * them names that are less likely to conflict with the rest of gawk.
133 #define argtab zz_debug_argtab
134 #define cmdtab zz_debug_cmdtab
136 extern struct argtoken argtab[];
137 extern struct cmdtoken cmdtab[];
139 static CMDARG *mk_cmdarg(enum argtype type);
140 static void append_cmdarg(CMDARG *arg);
141 static int find_argument(CMDARG *arg);
142 #define YYSTYPE CMDARG *
145 /* Line 268 of yacc.c */
146 #line 147 "command.c"
148 /* Enabling traces. */
153 /* Enabling verbose error messages. */
154 #ifdef YYERROR_VERBOSE
155 # undef YYERROR_VERBOSE
156 # define YYERROR_VERBOSE 1
158 # define YYERROR_VERBOSE 0
161 /* Enabling the token table. */
162 #ifndef YYTOKEN_TABLE
163 # define YYTOKEN_TABLE 0
170 /* Put the tokens into the symbol table, so that GDB and other debuggers
222 #define D_BACKTRACE 258
225 #define D_CONTINUE 261
227 #define D_DISABLE 263
249 #define D_DISPLAY 285
250 #define D_UNDISPLAY 286
252 #define D_UNWATCH 288
258 #define D_VARIABLE 294
260 #define D_COMMANDS 296
266 #define D_CONDITION 302
267 #define D_STATEMENT 303
272 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
274 # define YYSTYPE_IS_TRIVIAL 1
275 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
276 # define YYSTYPE_IS_DECLARED 1
280 /* Copy the second part of user declarations. */
283 /* Line 343 of yacc.c */
284 #line 285 "command.c"
291 typedef YYTYPE_UINT8 yytype_uint8;
293 typedef unsigned char yytype_uint8;
297 typedef YYTYPE_INT8 yytype_int8;
298 #elif (defined __STDC__ || defined __C99__FUNC__ \
299 || defined __cplusplus || defined _MSC_VER)
300 typedef signed char yytype_int8;
302 typedef short int yytype_int8;
306 typedef YYTYPE_UINT16 yytype_uint16;
308 typedef unsigned short int yytype_uint16;
312 typedef YYTYPE_INT16 yytype_int16;
314 typedef short int yytype_int16;
318 # ifdef __SIZE_TYPE__
319 # define YYSIZE_T __SIZE_TYPE__
320 # elif defined size_t
321 # define YYSIZE_T size_t
322 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
323 || defined __cplusplus || defined _MSC_VER)
324 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
325 # define YYSIZE_T size_t
327 # define YYSIZE_T unsigned int
331 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
334 # if defined YYENABLE_NLS && YYENABLE_NLS
336 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
337 # define YY_(msgid) dgettext ("bison-runtime", msgid)
341 # define YY_(msgid) msgid
345 /* Suppress unused-variable warnings by "using" E. */
346 #if ! defined lint || defined __GNUC__
347 # define YYUSE(e) ((void) (e))
349 # define YYUSE(e) /* empty */
352 /* Identity function, used to suppress warnings about constant conditions. */
356 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
369 #if ! defined yyoverflow || YYERROR_VERBOSE
371 /* The parser invokes alloca or malloc; define the necessary symbols. */
373 # ifdef YYSTACK_USE_ALLOCA
374 # if YYSTACK_USE_ALLOCA
376 # define YYSTACK_ALLOC __builtin_alloca
377 # elif defined __BUILTIN_VA_ARG_INCR
378 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
380 # define YYSTACK_ALLOC __alloca
381 # elif defined _MSC_VER
382 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
383 # define alloca _alloca
385 # define YYSTACK_ALLOC alloca
386 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
387 || defined __cplusplus || defined _MSC_VER)
388 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
389 # ifndef EXIT_SUCCESS
390 # define EXIT_SUCCESS 0
397 # ifdef YYSTACK_ALLOC
398 /* Pacify GCC's `empty if-body' warning. */
399 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
400 # ifndef YYSTACK_ALLOC_MAXIMUM
401 /* The OS might guarantee only one guard page at the bottom of the stack,
402 and a page size can be as small as 4096 bytes. So we cannot safely
403 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
404 to allow for a few compiler-allocated temporary stack slots. */
405 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
408 # define YYSTACK_ALLOC YYMALLOC
409 # define YYSTACK_FREE YYFREE
410 # ifndef YYSTACK_ALLOC_MAXIMUM
411 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
413 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
414 && ! ((defined YYMALLOC || defined malloc) \
415 && (defined YYFREE || defined free)))
416 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
417 # ifndef EXIT_SUCCESS
418 # define EXIT_SUCCESS 0
422 # define YYMALLOC malloc
423 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
424 || defined __cplusplus || defined _MSC_VER)
425 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
430 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
431 || defined __cplusplus || defined _MSC_VER)
432 void free (void *); /* INFRINGES ON USER NAME SPACE */
436 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
439 #if (! defined yyoverflow && (! defined __cplusplus || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
441 /* A type that is properly aligned for any stack member. */
444 yytype_int16 yyss_alloc;
448 /* The size of the maximum gap between one aligned stack and the next. */
449 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
451 /* The size of an array large to enough to hold all stacks, each with
453 # define YYSTACK_BYTES(N) \
454 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
455 + YYSTACK_GAP_MAXIMUM)
457 # define YYCOPY_NEEDED 1
459 /* Relocate STACK from its old location to the new one. The
460 local variables YYSIZE and YYSTACKSIZE give the old and new number of
461 elements in the stack, and YYPTR gives the new location of the
462 stack. Advance YYPTR to a properly aligned location for the next
464 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
467 YYSIZE_T yynewbytes; \
468 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
469 Stack = &yyptr->Stack_alloc; \
470 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
471 yyptr += yynewbytes / sizeof (*yyptr); \
477 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
478 /* Copy COUNT objects from FROM to TO. The source and destination do
481 # if defined __GNUC__ && 1 < __GNUC__
482 # define YYCOPY(To, From, Count) \
483 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
485 # define YYCOPY(To, From, Count) \
489 for (yyi = 0; yyi < (Count); yyi++) \
490 (To)[yyi] = (From)[yyi]; \
495 #endif /* !YYCOPY_NEEDED */
497 /* YYFINAL -- State number of the termination state. */
499 /* YYLAST -- Last index in YYTABLE. */
502 /* YYNTOKENS -- Number of terminals. */
504 /* YYNNTS -- Number of nonterminals. */
506 /* YYNRULES -- Number of rules. */
508 /* YYNRULES -- Number of states. */
509 #define YYNSTATES 203
511 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
513 #define YYMAXUTOK 303
515 #define YYTRANSLATE(YYX) \
516 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
518 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
519 static const yytype_uint8 yytranslate[] =
521 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 58, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 57, 2, 2, 2,
525 2, 2, 2, 53, 50, 54, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 51, 2,
527 2, 49, 2, 2, 52, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 55, 2, 56, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
547 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
548 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
549 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
550 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
555 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
557 static const yytype_uint16 yyprhs[] =
559 0, 0, 3, 4, 7, 9, 12, 15, 17, 19,
560 21, 23, 25, 27, 29, 31, 33, 35, 37, 39,
561 41, 43, 45, 46, 51, 52, 53, 58, 62, 66,
562 69, 71, 73, 75, 78, 81, 84, 88, 91, 92,
563 96, 97, 101, 104, 107, 110, 113, 114, 120, 123,
564 124, 128, 129, 133, 134, 139, 142, 145, 148, 151,
565 154, 156, 158, 161, 162, 167, 169, 171, 173, 175,
566 176, 178, 180, 183, 187, 189, 190, 192, 194, 196,
567 197, 199, 203, 205, 206, 208, 210, 214, 218, 219,
568 220, 224, 226, 227, 233, 237, 238, 240, 241, 243,
569 244, 246, 247, 249, 251, 254, 256, 259, 263, 265,
570 268, 272, 274, 276, 278, 280, 284, 286, 287, 289,
571 291, 293, 295, 297, 301, 305, 309, 313, 314, 316,
572 318, 320, 322, 325, 328, 330, 334, 336, 340, 344,
573 346, 349, 351, 354, 357, 359, 362, 365, 366, 368,
574 369, 371, 373, 376, 378, 381, 384
577 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
578 static const yytype_int8 yyrhs[] =
580 60, 0, -1, -1, 60, 61, -1, 113, -1, 71,
581 113, -1, 1, 113, -1, 6, -1, 17, -1, 18,
582 -1, 25, -1, 26, -1, 31, -1, 33, -1, 8,
583 -1, 7, -1, 28, -1, 9, -1, 3, -1, 12,
584 -1, 4, -1, 27, -1, -1, 46, 66, 81, 113,
585 -1, -1, -1, 68, 48, 69, 113, -1, 67, 68,
586 42, -1, 46, 66, 84, -1, 13, 94, -1, 21,
587 -1, 23, -1, 11, -1, 62, 109, -1, 64, 110,
588 -1, 15, 37, -1, 14, 111, 36, -1, 10, 95,
589 -1, -1, 19, 72, 97, -1, -1, 20, 73, 99,
590 -1, 16, 100, -1, 29, 87, -1, 5, 87, -1,
591 65, 88, -1, -1, 24, 74, 107, 49, 108, -1,
592 40, 85, -1, -1, 22, 75, 93, -1, -1, 30,
593 76, 91, -1, -1, 32, 77, 107, 79, -1, 63,
594 102, -1, 34, 92, -1, 44, 37, -1, 45, 37,
595 -1, 41, 80, -1, 42, -1, 43, -1, 35, 37,
596 -1, -1, 47, 111, 78, 79, -1, 70, -1, 83,
597 -1, 109, -1, 1, -1, -1, 82, -1, 39, -1,
598 82, 39, -1, 82, 50, 39, -1, 1, -1, -1,
599 84, -1, 1, -1, 38, -1, -1, 37, -1, 37,
600 49, 37, -1, 37, -1, -1, 111, -1, 86, -1,
601 37, 51, 111, -1, 37, 51, 86, -1, -1, -1,
602 111, 89, 79, -1, 86, -1, -1, 37, 51, 111,
603 90, 79, -1, 37, 51, 86, -1, -1, 107, -1,
604 -1, 37, -1, -1, 108, -1, -1, 37, -1, 102,
605 -1, 37, 102, -1, 107, -1, 52, 39, -1, 52,
606 39, 106, -1, 96, -1, 97, 96, -1, 97, 50,
607 96, -1, 1, -1, 38, -1, 107, -1, 98, -1,
608 99, 50, 98, -1, 1, -1, -1, 53, -1, 54,
609 -1, 111, -1, 86, -1, 101, -1, 37, 51, 111,
610 -1, 37, 51, 86, -1, 37, 51, 101, -1, 111,
611 54, 111, -1, -1, 103, -1, 1, -1, 111, -1,
612 101, -1, 103, 111, -1, 103, 101, -1, 108, -1,
613 104, 50, 108, -1, 1, -1, 55, 104, 56, -1,
614 55, 104, 1, -1, 105, -1, 106, 105, -1, 39,
615 -1, 57, 38, -1, 39, 106, -1, 38, -1, 53,
616 38, -1, 54, 38, -1, -1, 111, -1, -1, 112,
617 -1, 36, -1, 53, 36, -1, 36, -1, 53, 36,
618 -1, 54, 36, -1, 58, -1
621 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
622 static const yytype_uint16 yyrline[] =
624 0, 106, 106, 108, 126, 127, 177, 184, 185, 186,
625 187, 188, 192, 193, 194, 195, 199, 200, 201, 202,
626 206, 207, 212, 216, 235, 242, 242, 249, 265, 279,
627 280, 281, 282, 283, 284, 290, 302, 303, 304, 304,
628 305, 305, 306, 307, 308, 309, 310, 310, 311, 312,
629 312, 313, 313, 314, 314, 315, 316, 317, 322, 327,
630 353, 363, 368, 380, 380, 388, 402, 415, 416, 422,
631 423, 427, 428, 429, 430, 436, 437, 438, 443, 454,
632 455, 460, 468, 485, 486, 487, 488, 489, 494, 495,
633 495, 496, 497, 497, 498, 503, 504, 509, 510, 515,
634 516, 519, 521, 525, 526, 541, 542, 547, 555, 556,
635 557, 558, 562, 563, 567, 568, 569, 574, 575, 577,
636 584, 585, 586, 587, 588, 589, 593, 606, 607, 608,
637 612, 613, 614, 615, 619, 621, 623, 627, 642, 646,
638 648, 653, 654, 663, 673, 675, 682, 695, 696, 702,
639 703, 708, 714, 723, 725, 727, 735
643 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
644 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
645 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
646 static const char *const yytname[] =
648 "$end", "error", "$undefined", "D_BACKTRACE", "D_BREAK", "D_CLEAR",
649 "D_CONTINUE", "D_DELETE", "D_DISABLE", "D_DOWN", "D_ENABLE", "D_FINISH",
650 "D_FRAME", "D_HELP", "D_IGNORE", "D_INFO", "D_LIST", "D_NEXT", "D_NEXTI",
651 "D_PRINT", "D_PRINTF", "D_QUIT", "D_RETURN", "D_RUN", "D_SET", "D_STEP",
652 "D_STEPI", "D_TBREAK", "D_UP", "D_UNTIL", "D_DISPLAY", "D_UNDISPLAY",
653 "D_WATCH", "D_UNWATCH", "D_DUMP", "D_TRACE", "D_INT", "D_STRING",
654 "D_NODE", "D_VARIABLE", "D_OPTION", "D_COMMANDS", "D_END", "D_SILENT",
655 "D_SOURCE", "D_SAVE", "D_EVAL", "D_CONDITION", "D_STATEMENT", "'='",
656 "','", "':'", "'@'", "'+'", "'-'", "'['", "']'", "'$'", "'\\n'",
657 "$accept", "input", "line", "control_cmd", "d_cmd", "frame_cmd",
658 "break_cmd", "set_want_nodeval", "eval_prologue", "statement_list", "@1",
659 "eval_cmd", "command", "$@2", "$@3", "$@4", "$@5", "$@6", "$@7", "$@8",
660 "condition_exp", "commands_arg", "opt_param_list", "param_list",
661 "opt_string_node", "string_node", "option_args", "func_name", "location",
662 "break_args", "$@9", "$@10", "opt_variable", "opt_string", "opt_node",
663 "help_args", "enable_args", "print_exp", "print_args", "printf_exp",
664 "printf_args", "list_args", "integer_range", "opt_integer_list",
665 "integer_list", "exp_list", "subscript", "subscript_list", "variable",
666 "node", "opt_plus_integer", "opt_integer", "plus_integer", "integer",
672 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
674 static const yytype_uint16 yytoknum[] =
676 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
677 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
678 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
679 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
680 295, 296, 297, 298, 299, 300, 301, 302, 303, 61,
681 44, 58, 64, 43, 45, 91, 93, 36, 10
685 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
686 static const yytype_uint8 yyr1[] =
688 0, 59, 60, 60, 61, 61, 61, 62, 62, 62,
689 62, 62, 63, 63, 63, 63, 64, 64, 64, 64,
690 65, 65, 66, 67, 68, 69, 68, 70, 70, 71,
691 71, 71, 71, 71, 71, 71, 71, 71, 72, 71,
692 73, 71, 71, 71, 71, 71, 74, 71, 71, 75,
693 71, 76, 71, 77, 71, 71, 71, 71, 71, 71,
694 71, 71, 71, 78, 71, 71, 79, 80, 80, 81,
695 81, 82, 82, 82, 82, 83, 83, 83, 84, 85,
696 85, 85, 86, 87, 87, 87, 87, 87, 88, 89,
697 88, 88, 90, 88, 88, 91, 91, 92, 92, 93,
698 93, 94, 94, 95, 95, 96, 96, 96, 97, 97,
699 97, 97, 98, 98, 99, 99, 99, 100, 100, 100,
700 100, 100, 100, 100, 100, 100, 101, 102, 102, 102,
701 103, 103, 103, 103, 104, 104, 104, 105, 105, 106,
702 106, 107, 107, 107, 108, 108, 108, 109, 109, 110,
703 110, 111, 111, 112, 112, 112, 113
706 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
707 static const yytype_uint8 yyr2[] =
709 0, 2, 0, 2, 1, 2, 2, 1, 1, 1,
710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
711 1, 1, 0, 4, 0, 0, 4, 3, 3, 2,
712 1, 1, 1, 2, 2, 2, 3, 2, 0, 3,
713 0, 3, 2, 2, 2, 2, 0, 5, 2, 0,
714 3, 0, 3, 0, 4, 2, 2, 2, 2, 2,
715 1, 1, 2, 0, 4, 1, 1, 1, 1, 0,
716 1, 1, 2, 3, 1, 0, 1, 1, 1, 0,
717 1, 3, 1, 0, 1, 1, 3, 3, 0, 0,
718 3, 1, 0, 5, 3, 0, 1, 0, 1, 0,
719 1, 0, 1, 1, 2, 1, 2, 3, 1, 2,
720 3, 1, 1, 1, 1, 3, 1, 0, 1, 1,
721 1, 1, 1, 3, 3, 3, 3, 0, 1, 1,
722 1, 1, 2, 2, 1, 3, 1, 3, 3, 1,
723 2, 1, 2, 2, 1, 2, 2, 0, 1, 0,
727 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
728 Performed when YYTABLE doesn't specify something else to do. Zero
729 means the default is an error. */
730 static const yytype_uint8 yydefact[] =
732 2, 0, 1, 0, 18, 20, 83, 7, 15, 14,
733 17, 0, 32, 19, 101, 0, 0, 117, 8, 9,
734 38, 40, 30, 49, 31, 46, 10, 11, 21, 16,
735 83, 51, 12, 53, 13, 97, 0, 79, 0, 60,
736 61, 0, 0, 22, 0, 156, 3, 147, 0, 149,
737 88, 24, 65, 0, 4, 6, 151, 82, 0, 85,
738 44, 84, 129, 0, 37, 131, 103, 128, 130, 102,
739 29, 0, 35, 82, 118, 119, 121, 42, 122, 120,
740 0, 0, 99, 0, 43, 95, 0, 98, 56, 62,
741 80, 48, 68, 59, 67, 148, 57, 58, 0, 63,
742 33, 55, 153, 0, 0, 34, 150, 82, 91, 45,
743 89, 0, 5, 0, 152, 104, 133, 132, 0, 36,
744 0, 111, 141, 0, 0, 108, 39, 105, 116, 112,
745 114, 41, 113, 144, 0, 0, 50, 100, 0, 52,
746 96, 0, 0, 74, 78, 71, 0, 70, 28, 0,
747 154, 155, 0, 0, 27, 25, 82, 87, 86, 126,
748 124, 125, 123, 0, 139, 143, 106, 142, 0, 109,
749 0, 145, 146, 0, 77, 54, 66, 76, 81, 23,
750 72, 0, 64, 94, 92, 90, 0, 136, 0, 134,
751 140, 107, 110, 115, 47, 73, 0, 26, 138, 0,
755 /* YYDEFGOTO[NTERM-NUM]. */
756 static const yytype_int16 yydefgoto[] =
758 -1, 1, 46, 47, 48, 49, 50, 98, 51, 111,
759 186, 52, 53, 80, 81, 83, 82, 85, 86, 149,
760 175, 93, 146, 147, 176, 177, 91, 59, 60, 109,
761 153, 196, 139, 88, 136, 70, 64, 125, 126, 130,
762 131, 77, 65, 66, 67, 188, 164, 165, 127, 137,
766 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
768 #define YYPACT_NINF -151
769 static const yytype_int16 yypact[] =
771 -151, 145, -151, -34, -151, -151, 50, -151, -151, -151,
772 -151, 10, -151, -151, -10, 59, -9, 43, -151, -151,
773 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
774 50, -151, -151, -151, -151, -8, -6, 14, 12, -151,
775 -151, 22, 23, -151, 59, -151, -151, 59, 13, 36,
776 64, -151, -151, -34, -151, -151, -151, 24, 47, -151,
777 -151, -151, -151, 13, -151, -151, -151, 59, 48, -151,
778 -151, 80, -151, 67, 47, -151, -151, -151, -151, 48,
779 4, 19, 69, -20, -151, -20, -20, -151, -151, -151,
780 70, -151, -151, -151, -151, -151, -151, -151, 16, -151,
781 -151, -151, -151, 84, 85, -151, -151, 73, -151, -151,
782 -151, 40, -151, 74, -151, -151, -151, 48, 59, -151,
783 74, -151, 71, 89, 91, -151, 42, -151, -151, -151,
784 -151, 81, -151, -151, 92, 94, -151, -151, 86, -151,
785 -151, 6, 96, -151, -151, -151, -34, 75, -151, 6,
786 -151, -151, 74, 6, -151, -151, -151, -151, -151, -151,
787 -151, -151, 48, 31, -151, 71, 71, -151, 52, -151,
788 -17, -151, -151, 69, -151, -151, -151, -151, -151, -151,
789 -151, 95, -151, -151, -151, -151, -34, -151, 17, -151,
790 -151, 71, -151, -151, -151, -151, 6, -151, -151, 69,
794 /* YYPGOTO[NTERM-NUM]. */
795 static const yytype_int16 yypgoto[] =
797 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
798 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
799 -119, -151, -151, -151, -151, 38, -151, -15, 108, -151,
800 -151, -151, -151, -151, -151, -151, -151, -90, -151, -31,
801 -151, -151, -14, -25, -151, -151, -150, -26, -77, -147,
802 97, -151, -5, -151, -3
805 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
806 positive, shift that token. If negative, reduce the rule which
807 number is the opposite. If YYTABLE_NINF, syntax error. */
808 #define YYTABLE_NINF -148
809 static const yytype_int16 yytable[] =
811 55, 61, 76, 78, 132, 121, 138, 174, 140, 141,
812 71, 62, 79, 92, 62, 190, 189, 143, 198, 122,
813 128, 129, 122, 101, 45, 61, 194, 69, 72, 87,
814 182, 89, 187, 95, 185, 108, 169, 124, 115, 99,
815 124, 190, 95, 122, 144, 110, 56, 63, 56, 56,
816 112, 90, 202, 116, 144, 145, 123, 129, 122, 96,
817 97, 124, 117, 58, -75, 58, 58, 199, -127, 133,
818 -147, -127, 102, 200, -69, 113, 124, 201, 192, 56,
819 73, 122, 154, 114, 134, 135, 56, 57, 155, 103,
820 104, 122, 168, 132, 123, 56, 74, 75, 157, 124,
821 56, 107, 118, 58, 123, 160, 161, 133, 158, 124,
822 56, 156, 58, 159, 180, 162, 119, 58, 120, 142,
823 150, 151, 134, 135, 152, 181, 163, 58, 166, 167,
824 171, 170, 172, 178, 195, 173, 148, 183, 84, 193,
825 191, 0, 0, 179, 100, 2, 3, 184, 4, 5,
826 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
827 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
828 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
829 36, 0, 0, 197, 0, 37, 38, 39, 40, 41,
830 42, 43, 44, 0, 0, 0, 0, 0, 0, 0,
834 #define yypact_value_is_default(yystate) \
835 ((yystate) == (-151))
837 #define yytable_value_is_error(yytable_value) \
840 static const yytype_int16 yycheck[] =
842 3, 6, 17, 17, 81, 1, 83, 1, 85, 86,
843 15, 1, 17, 1, 1, 165, 163, 1, 1, 39,
844 1, 38, 39, 48, 58, 30, 173, 37, 37, 37,
845 149, 37, 1, 38, 153, 50, 126, 57, 63, 44,
846 57, 191, 47, 39, 38, 50, 36, 37, 36, 36,
847 53, 37, 199, 67, 38, 39, 52, 38, 39, 37,
848 37, 57, 67, 53, 58, 53, 53, 50, 58, 38,
849 58, 58, 36, 56, 58, 51, 57, 196, 168, 36,
850 37, 39, 42, 36, 53, 54, 36, 37, 48, 53,
851 54, 39, 50, 170, 52, 36, 53, 54, 113, 57,
852 36, 37, 54, 53, 52, 120, 120, 38, 113, 57,
853 36, 37, 53, 118, 39, 120, 36, 53, 51, 49,
854 36, 36, 53, 54, 51, 50, 55, 53, 39, 38,
855 38, 50, 38, 37, 39, 49, 98, 152, 30, 170,
856 166, -1, -1, 146, 47, 0, 1, 152, 3, 4,
857 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
858 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
859 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
860 35, -1, -1, 186, -1, 40, 41, 42, 43, 44,
861 45, 46, 47, -1, -1, -1, -1, -1, -1, -1,
865 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
866 symbol of state STATE-NUM. */
867 static const yytype_uint8 yystos[] =
869 0, 60, 0, 1, 3, 4, 5, 6, 7, 8,
870 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
871 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
872 29, 30, 31, 32, 33, 34, 35, 40, 41, 42,
873 43, 44, 45, 46, 47, 58, 61, 62, 63, 64,
874 65, 67, 70, 71, 113, 113, 36, 37, 53, 86,
875 87, 111, 1, 37, 95, 101, 102, 103, 111, 37,
876 94, 111, 37, 37, 53, 54, 86, 100, 101, 111,
877 72, 73, 75, 74, 87, 76, 77, 37, 92, 37,
878 37, 85, 1, 80, 109, 111, 37, 37, 66, 111,
879 109, 102, 36, 53, 54, 110, 112, 37, 86, 88,
880 111, 68, 113, 51, 36, 102, 101, 111, 54, 36,
881 51, 1, 39, 52, 57, 96, 97, 107, 1, 38,
882 98, 99, 107, 38, 53, 54, 93, 108, 107, 91,
883 107, 107, 49, 1, 38, 39, 81, 82, 84, 78,
884 36, 36, 51, 89, 42, 48, 37, 86, 111, 111,
885 86, 101, 111, 55, 105, 106, 39, 38, 50, 96,
886 50, 38, 38, 49, 1, 79, 83, 84, 37, 113,
887 39, 50, 79, 86, 111, 79, 69, 1, 104, 108,
888 105, 106, 96, 98, 108, 39, 90, 113, 1, 50,
892 #define yyerrok (yyerrstatus = 0)
893 #define yyclearin (yychar = YYEMPTY)
897 #define YYACCEPT goto yyacceptlab
898 #define YYABORT goto yyabortlab
899 #define YYERROR goto yyerrorlab
902 /* Like YYERROR except do call yyerror. This remains here temporarily
903 to ease the transition to the new meaning of YYERROR, for GCC.
904 Once GCC version 2 has supplanted version 1, this can go. However,
905 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
906 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
909 #define YYFAIL goto yyerrlab
911 /* This is here to suppress warnings from the GCC cpp's
912 -Wunused-macros. Normally we don't worry about that warning, but
913 some users do, and we want to make it easy for users to remove
914 YYFAIL uses, which will produce warnings from Bison 2.5. */
917 #define YYRECOVERING() (!!yyerrstatus)
919 #define YYBACKUP(Token, Value) \
921 if (yychar == YYEMPTY && yylen == 1) \
930 yyerror (YY_("syntax error: cannot back up")); \
937 #define YYERRCODE 256
940 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
941 If N is 0, then set CURRENT to the empty location which ends
942 the previous symbol: RHS[0] (always defined). */
944 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
945 #ifndef YYLLOC_DEFAULT
946 # define YYLLOC_DEFAULT(Current, Rhs, N) \
950 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
951 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
952 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
953 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
957 (Current).first_line = (Current).last_line = \
958 YYRHSLOC (Rhs, 0).last_line; \
959 (Current).first_column = (Current).last_column = \
960 YYRHSLOC (Rhs, 0).last_column; \
966 /* This macro is provided for backward compatibility. */
968 #ifndef YY_LOCATION_PRINT
969 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
973 /* YYLEX -- calling `yylex' with the right arguments. */
976 # define YYLEX yylex (YYLEX_PARAM)
978 # define YYLEX yylex ()
981 /* Enable debugging if requested. */
985 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
986 # define YYFPRINTF fprintf
989 # define YYDPRINTF(Args) \
995 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
999 YYFPRINTF (stderr, "%s ", Title); \
1000 yy_symbol_print (stderr, \
1002 YYFPRINTF (stderr, "\n"); \
1007 /*--------------------------------.
1008 | Print this symbol on YYOUTPUT. |
1009 `--------------------------------*/
1012 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1014 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1017 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1020 YYSTYPE const * const yyvaluep;
1026 if (yytype < YYNTOKENS)
1027 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1039 /*--------------------------------.
1040 | Print this symbol on YYOUTPUT. |
1041 `--------------------------------*/
1043 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1045 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1048 yy_symbol_print (yyoutput, yytype, yyvaluep)
1051 YYSTYPE const * const yyvaluep;
1054 if (yytype < YYNTOKENS)
1055 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1057 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1059 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1060 YYFPRINTF (yyoutput, ")");
1063 /*------------------------------------------------------------------.
1064 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1066 `------------------------------------------------------------------*/
1068 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1070 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1073 yy_stack_print (yybottom, yytop)
1074 yytype_int16 *yybottom;
1075 yytype_int16 *yytop;
1078 YYFPRINTF (stderr, "Stack now");
1079 for (; yybottom <= yytop; yybottom++)
1081 int yybot = *yybottom;
1082 YYFPRINTF (stderr, " %d", yybot);
1084 YYFPRINTF (stderr, "\n");
1087 # define YY_STACK_PRINT(Bottom, Top) \
1090 yy_stack_print ((Bottom), (Top)); \
1094 /*------------------------------------------------.
1095 | Report that the YYRULE is going to be reduced. |
1096 `------------------------------------------------*/
1098 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1100 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1103 yy_reduce_print (yyvsp, yyrule)
1108 int yynrhs = yyr2[yyrule];
1110 unsigned long int yylno = yyrline[yyrule];
1111 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1113 /* The symbols being reduced. */
1114 for (yyi = 0; yyi < yynrhs; yyi++)
1116 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1117 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1118 &(yyvsp[(yyi + 1) - (yynrhs)])
1120 YYFPRINTF (stderr, "\n");
1124 # define YY_REDUCE_PRINT(Rule) \
1127 yy_reduce_print (yyvsp, Rule); \
1130 /* Nonzero means print parse trace. It is left uninitialized so that
1131 multiple parsers can coexist. */
1133 #else /* !YYDEBUG */
1134 # define YYDPRINTF(Args)
1135 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1136 # define YY_STACK_PRINT(Bottom, Top)
1137 # define YY_REDUCE_PRINT(Rule)
1138 #endif /* !YYDEBUG */
1141 /* YYINITDEPTH -- initial size of the parser's stacks. */
1143 # define YYINITDEPTH 200
1146 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1147 if the built-in stack extension method is used).
1149 Do not make this value too large; the results are undefined if
1150 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1151 evaluated with infinite-precision integer arithmetic. */
1154 # define YYMAXDEPTH 10000
1161 # if defined __GLIBC__ && defined _STRING_H
1162 # define yystrlen strlen
1164 /* Return the length of YYSTR. */
1165 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1167 yystrlen (const char *yystr)
1175 for (yylen = 0; yystr[yylen]; yylen++)
1183 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1184 # define yystpcpy stpcpy
1186 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1188 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1190 yystpcpy (char *yydest, const char *yysrc)
1193 yystpcpy (yydest, yysrc)
1199 const char *yys = yysrc;
1201 while ((*yyd++ = *yys++) != '\0')
1210 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1211 quotes and backslashes, so that it's suitable for yyerror. The
1212 heuristic is that double-quoting is unnecessary unless the string
1213 contains an apostrophe, a comma, or backslash (other than
1214 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1215 null, do not copy; instead, return the length of what the result
1218 yytnamerr (char *yyres, const char *yystr)
1223 char const *yyp = yystr;
1230 goto do_not_strip_quotes;
1234 goto do_not_strip_quotes;
1247 do_not_strip_quotes: ;
1251 return yystrlen (yystr);
1253 return yystpcpy (yyres, yystr) - yyres;
1257 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1258 about the unexpected token YYTOKEN for the state stack whose top is
1261 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1262 not large enough to hold the message. In that case, also set
1263 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1264 required number of bytes is too large to store. */
1266 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1267 yytype_int16 *yyssp, int yytoken)
1269 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1270 YYSIZE_T yysize = yysize0;
1272 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1273 /* Internationalized format string. */
1274 const char *yyformat = 0;
1275 /* Arguments of yyformat. */
1276 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1277 /* Number of reported tokens (one for the "unexpected", one per
1281 /* There are many possibilities here to consider:
1282 - Assume YYFAIL is not used. It's too flawed to consider. See
1283 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1284 for details. YYERROR is fine as it does not invoke this
1286 - If this state is a consistent state with a default action, then
1287 the only way this function was invoked is if the default action
1288 is an error action. In that case, don't check for expected
1289 tokens because there are none.
1290 - The only way there can be no lookahead present (in yychar) is if
1291 this state is a consistent state with a default action. Thus,
1292 detecting the absence of a lookahead is sufficient to determine
1293 that there is no unexpected or expected token to report. In that
1294 case, just report a simple "syntax error".
1295 - Don't assume there isn't a lookahead just because this state is a
1296 consistent state with a default action. There might have been a
1297 previous inconsistent state, consistent state with a non-default
1298 action, or user semantic action that manipulated yychar.
1299 - Of course, the expected token list depends on states to have
1300 correct lookahead information, and it depends on the parser not
1301 to perform extra reductions after fetching a lookahead from the
1302 scanner and before detecting a syntax error. Thus, state merging
1303 (from LALR or IELR) and default reductions corrupt the expected
1304 token list. However, the list is correct for canonical LR with
1305 one exception: it will still contain any token that will not be
1306 accepted due to an error action in a later state.
1308 if (yytoken != YYEMPTY)
1310 int yyn = yypact[*yyssp];
1311 yyarg[yycount++] = yytname[yytoken];
1312 if (!yypact_value_is_default (yyn))
1314 /* Start YYX at -YYN if negative to avoid negative indexes in
1315 YYCHECK. In other words, skip the first -YYN actions for
1316 this state because they are default actions. */
1317 int yyxbegin = yyn < 0 ? -yyn : 0;
1318 /* Stay within bounds of both yycheck and yytname. */
1319 int yychecklim = YYLAST - yyn + 1;
1320 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1323 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1324 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1325 && !yytable_value_is_error (yytable[yyx + yyn]))
1327 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1333 yyarg[yycount++] = yytname[yyx];
1334 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1335 if (! (yysize <= yysize1
1336 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1345 # define YYCASE_(N, S) \
1349 YYCASE_(0, YY_("syntax error"));
1350 YYCASE_(1, YY_("syntax error, unexpected %s"));
1351 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1352 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1353 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1354 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1358 yysize1 = yysize + yystrlen (yyformat);
1359 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1363 if (*yymsg_alloc < yysize)
1365 *yymsg_alloc = 2 * yysize;
1366 if (! (yysize <= *yymsg_alloc
1367 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1368 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1372 /* Avoid sprintf, as that infringes on the user's name space.
1373 Don't have undefined behavior even if the translation
1374 produced a string with the wrong number of "%s"s. */
1378 while ((*yyp = *yyformat) != '\0')
1379 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1381 yyp += yytnamerr (yyp, yyarg[yyi++]);
1392 #endif /* YYERROR_VERBOSE */
1394 /*-----------------------------------------------.
1395 | Release the memory associated to this symbol. |
1396 `-----------------------------------------------*/
1399 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1401 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1404 yydestruct (yymsg, yytype, yyvaluep)
1414 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1425 /* Prevent warnings from -Wmissing-prototypes. */
1426 #ifdef YYPARSE_PARAM
1427 #if defined __STDC__ || defined __cplusplus
1428 int yyparse (void *YYPARSE_PARAM);
1432 #else /* ! YYPARSE_PARAM */
1433 #if defined __STDC__ || defined __cplusplus
1438 #endif /* ! YYPARSE_PARAM */
1441 /* The lookahead symbol. */
1444 /* The semantic value of the lookahead symbol. */
1447 /* Number of syntax errors so far. */
1455 #ifdef YYPARSE_PARAM
1456 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1458 yyparse (void *YYPARSE_PARAM)
1461 yyparse (YYPARSE_PARAM)
1462 void *YYPARSE_PARAM;
1464 #else /* ! YYPARSE_PARAM */
1465 #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER)
1476 /* Number of tokens to shift before error messages enabled. */
1479 /* The stacks and their tools:
1480 `yyss': related to states.
1481 `yyvs': related to semantic values.
1483 Refer to the stacks thru separate pointers, to allow yyoverflow
1484 to reallocate them elsewhere. */
1486 /* The state stack. */
1487 yytype_int16 yyssa[YYINITDEPTH];
1489 yytype_int16 *yyssp;
1491 /* The semantic value stack. */
1492 YYSTYPE yyvsa[YYINITDEPTH];
1496 YYSIZE_T yystacksize;
1500 /* Lookahead token as an internal (translated) token number. */
1502 /* The variables used to return semantic value and location from the
1507 /* Buffer for error messages, and its allocated size. */
1509 char *yymsg = yymsgbuf;
1510 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1513 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1515 /* The number of symbols on the RHS of the reduced rule.
1516 Keep to zero when no symbol should be popped. */
1522 yystacksize = YYINITDEPTH;
1524 YYDPRINTF ((stderr, "Starting parse\n"));
1529 yychar = YYEMPTY; /* Cause a token to be read. */
1531 /* Initialize stack pointers.
1532 Waste one element of value and location stack
1533 so that they stay on the same level as the state stack.
1534 The wasted elements are never initialized. */
1540 /*------------------------------------------------------------.
1541 | yynewstate -- Push a new state, which is found in yystate. |
1542 `------------------------------------------------------------*/
1544 /* In all cases, when you get here, the value and location stacks
1545 have just been pushed. So pushing a state here evens the stacks. */
1551 if (yyss + yystacksize - 1 <= yyssp)
1553 /* Get the current used size of the three stacks, in elements. */
1554 YYSIZE_T yysize = yyssp - yyss + 1;
1558 /* Give user a chance to reallocate the stack. Use copies of
1559 these so that the &'s don't force the real ones into
1561 YYSTYPE *yyvs1 = yyvs;
1562 yytype_int16 *yyss1 = yyss;
1564 /* Each stack pointer address is followed by the size of the
1565 data in use in that stack, in bytes. This used to be a
1566 conditional around just the two extra args, but that might
1567 be undefined if yyoverflow is a macro. */
1568 yyoverflow (YY_("memory exhausted"),
1569 &yyss1, yysize * sizeof (*yyssp),
1570 &yyvs1, yysize * sizeof (*yyvsp),
1576 #else /* no yyoverflow */
1577 # ifndef YYSTACK_RELOCATE
1578 goto yyexhaustedlab;
1580 /* Extend the stack our own way. */
1581 if (YYMAXDEPTH <= yystacksize)
1582 goto yyexhaustedlab;
1584 if (YYMAXDEPTH < yystacksize)
1585 yystacksize = YYMAXDEPTH;
1588 yytype_int16 *yyss1 = yyss;
1589 union yyalloc *yyptr =
1590 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1592 goto yyexhaustedlab;
1593 YYSTACK_RELOCATE (yyss_alloc, yyss);
1594 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1595 # undef YYSTACK_RELOCATE
1597 YYSTACK_FREE (yyss1);
1600 #endif /* no yyoverflow */
1602 yyssp = yyss + yysize - 1;
1603 yyvsp = yyvs + yysize - 1;
1605 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1606 (unsigned long int) yystacksize));
1608 if (yyss + yystacksize - 1 <= yyssp)
1612 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1614 if (yystate == YYFINAL)
1624 /* Do appropriate processing given the current state. Read a
1625 lookahead token if we need one and don't already have one. */
1627 /* First try to decide what to do without reference to lookahead token. */
1628 yyn = yypact[yystate];
1629 if (yypact_value_is_default (yyn))
1632 /* Not known => get a lookahead token if don't already have one. */
1634 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1635 if (yychar == YYEMPTY)
1637 YYDPRINTF ((stderr, "Reading a token: "));
1641 if (yychar <= YYEOF)
1643 yychar = yytoken = YYEOF;
1644 YYDPRINTF ((stderr, "Now at end of input.\n"));
1648 yytoken = YYTRANSLATE (yychar);
1649 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1652 /* If the proper action on seeing token YYTOKEN is to reduce or to
1653 detect an error, take that action. */
1655 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1660 if (yytable_value_is_error (yyn))
1666 /* Count tokens shifted since error; after three, turn off error
1671 /* Shift the lookahead token. */
1672 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1674 /* Discard the shifted token. */
1683 /*-----------------------------------------------------------.
1684 | yydefault -- do the default action for the current state. |
1685 `-----------------------------------------------------------*/
1687 yyn = yydefact[yystate];
1693 /*-----------------------------.
1694 | yyreduce -- Do a reduction. |
1695 `-----------------------------*/
1697 /* yyn is the number of a rule to reduce with. */
1700 /* If YYLEN is nonzero, implement the default value of the action:
1703 Otherwise, the following line sets YYVAL to garbage.
1704 This behavior is undocumented and Bison
1705 users should not rely upon it. Assigning to YYVAL
1706 unconditionally makes the parser a bit smaller, and it avoids a
1707 GCC warning that YYVAL may be used uninitialized. */
1708 yyval = yyvsp[1-yylen];
1711 YY_REDUCE_PRINT (yyn);
1716 /* Line 1806 of yacc.c */
1717 #line 109 "command.y"
1720 want_nodeval = FALSE;
1721 if (lexptr_begin != NULL) {
1722 if (input_from_tty && lexptr_begin[0] != '\0')
1723 add_history(lexptr_begin);
1724 efree(lexptr_begin);
1725 lexptr_begin = NULL;
1727 if (arg_list != NULL) {
1728 free_cmdarg(arg_list);
1736 /* Line 1806 of yacc.c */
1737 #line 128 "command.y"
1739 if (errcount == 0 && cmd_idx >= 0) {
1741 int terminate = FALSE;
1745 ctype = cmdtab[cmd_idx].type;
1747 /* a blank line repeats previous command
1748 * (list, next, nexti, step, stepi and continue without arguments).
1749 * save the index in the command table; used in yylex
1751 if ((ctype == D_list
1756 || ctype == D_continue)
1761 repeat_idx = cmd_idx;
1765 /* call the command handler; reset the globals arg_list, cmd_idx,
1766 * since this handler could invoke yyparse again.
1767 * call do_commands for the list of commands in `commands';
1768 * arg_list isn't freed on return.
1771 cmdfunc = cmdtab[cmd_idx].cf_ptr;
1773 cmdfunc = do_commands;
1775 want_nodeval = FALSE;
1780 terminate = (*cmdfunc)(args, ctype);
1781 if (! in_commands || ctype == D_commands)
1791 /* Line 1806 of yacc.c */
1792 #line 178 "command.y"
1800 /* Line 1806 of yacc.c */
1801 #line 212 "command.y"
1802 { want_nodeval = TRUE; }
1807 /* Line 1806 of yacc.c */
1808 #line 217 "command.y"
1810 if (errcount == 0) {
1811 /* don't free arg_list; passed on to statement_list
1812 * non-terminal (empty rule action). See below.
1814 if (input_from_tty) {
1815 dPrompt = eval_Prompt;
1816 fprintf(out_fp, _("Type (g)awk statement(s). End with the command \"end\"\n"));
1817 rl_inhibit_completion = 1;
1827 /* Line 1806 of yacc.c */
1828 #line 235 "command.y"
1830 (yyval) = append_statement(arg_list, (char *) start_EVAL);
1831 if (read_a_line == read_commands_string) /* unserializing 'eval' in 'commands' */
1832 (yyval)->a_string[0] = '\0';
1833 free_cmdarg(arg_list);
1840 /* Line 1806 of yacc.c */
1841 #line 242 "command.y"
1842 { (yyval) = append_statement((yyvsp[(1) - (2)]), lexptr_begin); }
1847 /* Line 1806 of yacc.c */
1848 #line 243 "command.y"
1850 (yyval) = (yyvsp[(3) - (4)]);
1856 /* Line 1806 of yacc.c */
1857 #line 250 "command.y"
1859 arg_list = append_statement((yyvsp[(2) - (3)]), (char *) end_EVAL);
1860 if (read_a_line == read_commands_string) { /* unserializing 'eval' in 'commands' */
1861 char *str = arg_list->a_string;
1862 size_t len = strlen(str);
1863 assert(len > 2 && str[len - 2] == '}');
1864 str[len - 2] = '\0';
1866 if (input_from_tty) {
1867 dPrompt = in_commands ? commands_Prompt : dgawk_Prompt;
1868 rl_inhibit_completion = 0;
1870 cmd_idx = find_command("eval", 4);
1877 /* Line 1806 of yacc.c */
1878 #line 266 "command.y"
1882 n = (yyvsp[(3) - (3)])->a_node;
1883 arg = append_statement(NULL, (char *) start_EVAL);
1884 (void) append_statement(arg, n->stptr);
1885 (void) append_statement(arg, (char *) end_EVAL);
1886 free_cmdarg(arg_list);
1893 /* Line 1806 of yacc.c */
1894 #line 285 "command.y"
1896 if (cmdtab[cmd_idx].class == D_FRAME
1897 && (yyvsp[(2) - (2)]) != NULL && (yyvsp[(2) - (2)])->a_int < 0)
1898 yyerror(_("invalid frame number: %d"), (yyvsp[(2) - (2)])->a_int);
1904 /* Line 1806 of yacc.c */
1905 #line 291 "command.y"
1907 int idx = find_argument((yyvsp[(2) - (2)]));
1909 yyerror(_("info: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string);
1911 efree((yyvsp[(2) - (2)])->a_string);
1912 (yyvsp[(2) - (2)])->a_string = NULL;
1913 (yyvsp[(2) - (2)])->type = D_argument;
1914 (yyvsp[(2) - (2)])->a_argument = argtab[idx].value;
1921 /* Line 1806 of yacc.c */
1922 #line 304 "command.y"
1923 { want_nodeval = TRUE; }
1928 /* Line 1806 of yacc.c */
1929 #line 305 "command.y"
1930 { want_nodeval = TRUE; }
1935 /* Line 1806 of yacc.c */
1936 #line 310 "command.y"
1937 { want_nodeval = TRUE; }
1942 /* Line 1806 of yacc.c */
1943 #line 312 "command.y"
1944 { want_nodeval = TRUE; }
1949 /* Line 1806 of yacc.c */
1950 #line 313 "command.y"
1951 { want_nodeval = TRUE; }
1956 /* Line 1806 of yacc.c */
1957 #line 314 "command.y"
1958 { want_nodeval = TRUE; }
1963 /* Line 1806 of yacc.c */
1964 #line 318 "command.y"
1966 if (in_cmd_src((yyvsp[(2) - (2)])->a_string))
1967 yyerror(_("source \"%s\": already sourced."), (yyvsp[(2) - (2)])->a_string);
1973 /* Line 1806 of yacc.c */
1974 #line 323 "command.y"
1976 if (! input_from_tty)
1977 yyerror(_("save \"%s\": command not permitted."), (yyvsp[(2) - (2)])->a_string);
1983 /* Line 1806 of yacc.c */
1984 #line 328 "command.y"
1989 if ((yyvsp[(2) - (2)]) != NULL)
1990 num = (yyvsp[(2) - (2)])->a_int;
1994 else if (in_commands)
1995 yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands"));
1996 else if ((yyvsp[(2) - (2)]) == NULL && ! (type = has_break_or_watch_point(&num, TRUE)))
1997 yyerror(_("no breakpoint/watchpoint has been set yet"));
1998 else if ((yyvsp[(2) - (2)]) != NULL && ! (type = has_break_or_watch_point(&num, FALSE)))
1999 yyerror(_("invalid breakpoint/watchpoint number"));
2002 if (input_from_tty) {
2003 dPrompt = commands_Prompt;
2004 fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"),
2005 (type == D_break) ? "breakpoint" : "watchpoint", num);
2006 fprintf(out_fp, _("End with the command \"end\"\n"));
2014 /* Line 1806 of yacc.c */
2015 #line 354 "command.y"
2018 yyerror(_("`end' valid only in command `commands' or `eval'"));
2021 dPrompt = dgawk_Prompt;
2022 in_commands = FALSE;
2029 /* Line 1806 of yacc.c */
2030 #line 364 "command.y"
2033 yyerror(_("`silent' valid only in command `commands'"));
2039 /* Line 1806 of yacc.c */
2040 #line 369 "command.y"
2042 int idx = find_argument((yyvsp[(2) - (2)]));
2044 yyerror(_("trace: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string);
2046 efree((yyvsp[(2) - (2)])->a_string);
2047 (yyvsp[(2) - (2)])->a_string = NULL;
2048 (yyvsp[(2) - (2)])->type = D_argument;
2049 (yyvsp[(2) - (2)])->a_argument = argtab[idx].value;
2056 /* Line 1806 of yacc.c */
2057 #line 380 "command.y"
2058 { want_nodeval = TRUE; }
2063 /* Line 1806 of yacc.c */
2064 #line 381 "command.y"
2067 int num = (yyvsp[(2) - (4)])->a_int;
2068 type = has_break_or_watch_point(&num, FALSE);
2070 yyerror(_("condition: invalid breakpoint/watchpoint number"));
2076 /* Line 1806 of yacc.c */
2077 #line 389 "command.y"
2080 /* Prepend command 'eval' to argument list */
2082 arg = mk_cmdarg(D_string);
2083 arg->a_string = estrdup("eval", 4);
2084 arg->next = arg_list;
2092 /* Line 1806 of yacc.c */
2093 #line 403 "command.y"
2095 if ((yyvsp[(1) - (1)]) != NULL) {
2096 NODE *n = (yyvsp[(1) - (1)])->a_node;
2097 (yyvsp[(1) - (1)])->type = D_string;
2098 (yyvsp[(1) - (1)])->a_string = n->stptr;
2101 (yyval) = (yyvsp[(1) - (1)]);
2107 /* Line 1806 of yacc.c */
2108 #line 417 "command.y"
2114 /* Line 1806 of yacc.c */
2115 #line 422 "command.y"
2121 /* Line 1806 of yacc.c */
2122 #line 431 "command.y"
2128 /* Line 1806 of yacc.c */
2129 #line 436 "command.y"
2135 /* Line 1806 of yacc.c */
2136 #line 439 "command.y"
2142 /* Line 1806 of yacc.c */
2143 #line 444 "command.y"
2146 n = (yyvsp[(1) - (1)])->a_node;
2147 if ((n->flags & STRING) == 0)
2148 yyerror(_("argument not a string"));
2154 /* Line 1806 of yacc.c */
2155 #line 454 "command.y"
2161 /* Line 1806 of yacc.c */
2162 #line 456 "command.y"
2164 if (find_option((yyvsp[(1) - (1)])->a_string) < 0)
2165 yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (1)])->a_string);
2171 /* Line 1806 of yacc.c */
2172 #line 461 "command.y"
2174 if (find_option((yyvsp[(1) - (3)])->a_string) < 0)
2175 yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (3)])->a_string);
2181 /* Line 1806 of yacc.c */
2182 #line 469 "command.y"
2185 n = lookup((yyvsp[(1) - (1)])->a_string);
2186 if (n == NULL || n->type != Node_func)
2187 yyerror(_("no such function - \"%s\""), (yyvsp[(1) - (1)])->a_string);
2189 (yyvsp[(1) - (1)])->type = D_func;
2190 efree((yyvsp[(1) - (1)])->a_string);
2191 (yyvsp[(1) - (1)])->a_string = NULL;
2192 (yyvsp[(1) - (1)])->a_node = n;
2199 /* Line 1806 of yacc.c */
2200 #line 485 "command.y"
2206 /* Line 1806 of yacc.c */
2207 #line 494 "command.y"
2213 /* Line 1806 of yacc.c */
2214 #line 495 "command.y"
2215 { want_nodeval = TRUE; }
2220 /* Line 1806 of yacc.c */
2221 #line 497 "command.y"
2222 { want_nodeval = TRUE; }
2227 /* Line 1806 of yacc.c */
2228 #line 503 "command.y"
2234 /* Line 1806 of yacc.c */
2235 #line 509 "command.y"
2241 /* Line 1806 of yacc.c */
2242 #line 515 "command.y"
2248 /* Line 1806 of yacc.c */
2249 #line 527 "command.y"
2251 int idx = find_argument((yyvsp[(1) - (2)]));
2253 yyerror(_("enable: invalid option - \"%s\""), (yyvsp[(1) - (2)])->a_string);
2255 efree((yyvsp[(1) - (2)])->a_string);
2256 (yyvsp[(1) - (2)])->a_string = NULL;
2257 (yyvsp[(1) - (2)])->type = D_argument;
2258 (yyvsp[(1) - (2)])->a_argument = argtab[idx].value;
2265 /* Line 1806 of yacc.c */
2266 #line 543 "command.y"
2268 (yyvsp[(2) - (2)])->type = D_array; /* dump all items */
2269 (yyvsp[(2) - (2)])->a_count = 0;
2275 /* Line 1806 of yacc.c */
2276 #line 548 "command.y"
2278 (yyvsp[(2) - (3)])->type = D_array;
2279 (yyvsp[(2) - (3)])->a_count = num_dim;
2285 /* Line 1806 of yacc.c */
2286 #line 574 "command.y"
2292 /* Line 1806 of yacc.c */
2293 #line 576 "command.y"
2299 /* Line 1806 of yacc.c */
2300 #line 578 "command.y"
2303 a = mk_cmdarg(D_int);
2311 /* Line 1806 of yacc.c */
2312 #line 594 "command.y"
2314 if ((yyvsp[(1) - (3)])->a_int > (yyvsp[(3) - (3)])->a_int)
2315 yyerror(_("invalid range specification: %d - %d"),
2316 (yyvsp[(1) - (3)])->a_int, (yyvsp[(3) - (3)])->a_int);
2318 (yyvsp[(1) - (3)])->type = D_range;
2319 (yyval) = (yyvsp[(1) - (3)]);
2325 /* Line 1806 of yacc.c */
2326 #line 606 "command.y"
2332 /* Line 1806 of yacc.c */
2333 #line 620 "command.y"
2334 { (yyval) = (yyvsp[(1) - (1)]); }
2339 /* Line 1806 of yacc.c */
2340 #line 622 "command.y"
2341 { (yyval) = (yyvsp[(1) - (3)]); }
2346 /* Line 1806 of yacc.c */
2347 #line 628 "command.y"
2353 for (a = (yyvsp[(2) - (3)]); a != NULL; a = a->next)
2355 subs = concat_args((yyvsp[(2) - (3)]), count);
2356 free_cmdarg((yyvsp[(2) - (3)])->next);
2357 (yyvsp[(2) - (3)])->next = NULL;
2358 (yyvsp[(2) - (3)])->type = D_node;
2359 (yyvsp[(2) - (3)])->a_node = subs;
2360 (yyval) = (yyvsp[(2) - (3)]);
2366 /* Line 1806 of yacc.c */
2367 #line 647 "command.y"
2368 { (yyval) = (yyvsp[(1) - (1)]); num_dim = 1; }
2373 /* Line 1806 of yacc.c */
2374 #line 649 "command.y"
2375 { (yyval) = (yyvsp[(1) - (2)]); num_dim++; }
2380 /* Line 1806 of yacc.c */
2381 #line 655 "command.y"
2383 NODE *n = (yyvsp[(2) - (2)])->a_node;
2384 if ((n->flags & NUMBER) == 0)
2385 yyerror(_("non-numeric value for field number"));
2387 (yyvsp[(2) - (2)])->type = D_field;
2388 (yyval) = (yyvsp[(2) - (2)]);
2394 /* Line 1806 of yacc.c */
2395 #line 664 "command.y"
2397 /* a_string is array name, a_count is dimension count */
2398 (yyvsp[(1) - (2)])->type = D_subscript;
2399 (yyvsp[(1) - (2)])->a_count = num_dim;
2400 (yyval) = (yyvsp[(1) - (2)]);
2406 /* Line 1806 of yacc.c */
2407 #line 674 "command.y"
2408 { (yyval) = (yyvsp[(1) - (1)]); }
2413 /* Line 1806 of yacc.c */
2414 #line 676 "command.y"
2416 NODE *n = (yyvsp[(2) - (2)])->a_node;
2417 if ((n->flags & NUMBER) == 0)
2418 yyerror(_("non-numeric value found, numeric expected"));
2419 (yyval) = (yyvsp[(2) - (2)]);
2425 /* Line 1806 of yacc.c */
2426 #line 683 "command.y"
2428 NODE *n = (yyvsp[(2) - (2)])->a_node;
2429 if ((n->flags & NUMBER) == 0)
2430 yyerror(_("non-numeric value found, numeric expected"));
2432 (yyvsp[(2) - (2)])->a_node->numbr = - n->numbr;
2433 (yyval) = (yyvsp[(2) - (2)]);
2439 /* Line 1806 of yacc.c */
2440 #line 695 "command.y"
2446 /* Line 1806 of yacc.c */
2447 #line 697 "command.y"
2448 { (yyval) = (yyvsp[(1) - (1)]); }
2453 /* Line 1806 of yacc.c */
2454 #line 702 "command.y"
2460 /* Line 1806 of yacc.c */
2461 #line 704 "command.y"
2462 { (yyval) = (yyvsp[(1) - (1)]); }
2467 /* Line 1806 of yacc.c */
2468 #line 709 "command.y"
2470 if ((yyvsp[(1) - (1)])->a_int == 0)
2471 yyerror(_("non-zero integer value"));
2472 (yyval) = (yyvsp[(1) - (1)]);
2478 /* Line 1806 of yacc.c */
2479 #line 715 "command.y"
2481 if ((yyvsp[(2) - (2)])->a_int == 0)
2482 yyerror(_("non-zero integer value"));
2483 (yyval) = (yyvsp[(2) - (2)]);
2489 /* Line 1806 of yacc.c */
2490 #line 724 "command.y"
2491 { (yyval) = (yyvsp[(1) - (1)]); }
2496 /* Line 1806 of yacc.c */
2497 #line 726 "command.y"
2498 { (yyval) = (yyvsp[(2) - (2)]); }
2503 /* Line 1806 of yacc.c */
2504 #line 728 "command.y"
2506 (yyvsp[(2) - (2)])->a_int = - (yyvsp[(2) - (2)])->a_int;
2507 (yyval) = (yyvsp[(2) - (2)]);
2513 /* Line 1806 of yacc.c */
2514 #line 736 "command.y"
2516 if (lexptr_begin != NULL) {
2517 if (input_from_tty && lexptr_begin[0] != '\0')
2518 add_history(lexptr_begin);
2519 efree(lexptr_begin);
2520 lexptr_begin = NULL;
2527 /* Line 1806 of yacc.c */
2528 #line 2541 "command.c"
2531 /* User semantic actions sometimes alter yychar, and that requires
2532 that yytoken be updated with the new translation. We take the
2533 approach of translating immediately before every use of yytoken.
2534 One alternative is translating here after every semantic action,
2535 but that translation would be missed if the semantic action invokes
2536 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2537 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2538 incorrect destructor might then be invoked immediately. In the
2539 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2540 to an incorrect destructor call or verbose syntax error message
2541 before the lookahead is translated. */
2542 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2546 YY_STACK_PRINT (yyss, yyssp);
2550 /* Now `shift' the result of the reduction. Determine what state
2551 that goes to, based on the state we popped back to and the rule
2552 number reduced by. */
2556 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2557 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2558 yystate = yytable[yystate];
2560 yystate = yydefgoto[yyn - YYNTOKENS];
2565 /*------------------------------------.
2566 | yyerrlab -- here on detecting error |
2567 `------------------------------------*/
2569 /* Make sure we have latest lookahead translation. See comments at
2570 user semantic actions for why this is necessary. */
2571 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2573 /* If not already recovering from an error, report this error. */
2577 #if ! YYERROR_VERBOSE
2578 yyerror (YY_("syntax error"));
2580 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2583 char const *yymsgp = YY_("syntax error");
2584 int yysyntax_error_status;
2585 yysyntax_error_status = YYSYNTAX_ERROR;
2586 if (yysyntax_error_status == 0)
2588 else if (yysyntax_error_status == 1)
2590 if (yymsg != yymsgbuf)
2591 YYSTACK_FREE (yymsg);
2592 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2596 yymsg_alloc = sizeof yymsgbuf;
2597 yysyntax_error_status = 2;
2601 yysyntax_error_status = YYSYNTAX_ERROR;
2606 if (yysyntax_error_status == 2)
2607 goto yyexhaustedlab;
2609 # undef YYSYNTAX_ERROR
2615 if (yyerrstatus == 3)
2617 /* If just tried and failed to reuse lookahead token after an
2618 error, discard it. */
2620 if (yychar <= YYEOF)
2622 /* Return failure if at end of input. */
2623 if (yychar == YYEOF)
2628 yydestruct ("Error: discarding",
2634 /* Else will try to reuse lookahead token after shifting the error
2639 /*---------------------------------------------------.
2640 | yyerrorlab -- error raised explicitly by YYERROR. |
2641 `---------------------------------------------------*/
2644 /* Pacify compilers like GCC when the user code never invokes
2645 YYERROR and the label yyerrorlab therefore never appears in user
2647 if (/*CONSTCOND*/ 0)
2650 /* Do not reclaim the symbols of the rule which action triggered
2654 YY_STACK_PRINT (yyss, yyssp);
2659 /*-------------------------------------------------------------.
2660 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2661 `-------------------------------------------------------------*/
2663 yyerrstatus = 3; /* Each real token shifted decrements this. */
2667 yyn = yypact[yystate];
2668 if (!yypact_value_is_default (yyn))
2671 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2679 /* Pop the current state because it cannot handle the error token. */
2684 yydestruct ("Error: popping",
2685 yystos[yystate], yyvsp);
2688 YY_STACK_PRINT (yyss, yyssp);
2694 /* Shift the error token. */
2695 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2701 /*-------------------------------------.
2702 | yyacceptlab -- YYACCEPT comes here. |
2703 `-------------------------------------*/
2708 /*-----------------------------------.
2709 | yyabortlab -- YYABORT comes here. |
2710 `-----------------------------------*/
2715 #if !defined(yyoverflow) || YYERROR_VERBOSE
2716 /*-------------------------------------------------.
2717 | yyexhaustedlab -- memory exhaustion comes here. |
2718 `-------------------------------------------------*/
2720 yyerror (YY_("memory exhausted"));
2726 if (yychar != YYEMPTY)
2728 /* Make sure we have latest lookahead translation. See comments at
2729 user semantic actions for why this is necessary. */
2730 yytoken = YYTRANSLATE (yychar);
2731 yydestruct ("Cleanup: discarding lookahead",
2734 /* Do not reclaim the symbols of the rule which action triggered
2735 this YYABORT or YYACCEPT. */
2737 YY_STACK_PRINT (yyss, yyssp);
2738 while (yyssp != yyss)
2740 yydestruct ("Cleanup: popping",
2741 yystos[*yyssp], yyvsp);
2746 YYSTACK_FREE (yyss);
2749 if (yymsg != yymsgbuf)
2750 YYSTACK_FREE (yymsg);
2752 /* Make sure YYID is used. */
2753 return YYID (yyresult);
2758 /* Line 2067 of yacc.c */
2759 #line 746 "command.y"
2763 /* append_statement --- append 'stmt' to the list of eval awk statements */
2766 append_statement(CMDARG *alist, char *stmt)
2770 int len, slen, ssize;
2772 #define EVALSIZE 512
2774 if (stmt == start_EVAL) {
2775 len = sizeof(start_EVAL);
2776 for (a = alist; a != NULL; a = a->next)
2777 len += strlen(a->a_string) + 1; /* 1 for ',' */
2780 emalloc(s, char *, (len + 2) * sizeof(char), "append_statement");
2781 arg = mk_cmdarg(D_string);
2783 arg->a_count = len; /* kludge */
2785 slen = sizeof("function @eval(") - 1;
2786 memcpy(s, start_EVAL, slen);
2788 for (a = alist; a != NULL; a = a->next) {
2789 len = strlen(a->a_string);
2790 memcpy(s + slen, a->a_string, len);
2792 if (a->next != NULL)
2801 len = strlen(stmt) + 1; /* 1 for newline */
2802 s = alist->a_string;
2804 ssize = alist->a_count;
2805 if (len > ssize - slen) {
2806 ssize = slen + len + EVALSIZE;
2807 erealloc(s, char *, (ssize + 2) * sizeof(char), "append_statement");
2808 alist->a_string = s;
2809 alist->a_count = ssize;
2811 memcpy(s + slen, stmt, len);
2813 if (slen >= 2 && s[slen - 2] != '\n') {
2818 if (stmt == end_EVAL)
2819 erealloc(alist->a_string, char *, slen + 2, "append_statement");
2826 /* command names sorted in ascending order */
2828 struct cmdtoken cmdtab[] = {
2829 { "backtrace", "bt", D_backtrace, D_BACKTRACE, do_backtrace,
2830 gettext_noop("backtrace [N] - print trace of all or N innermost (outermost if N < 0) frames.") },
2831 { "break", "b", D_break, D_BREAK, do_breakpoint,
2832 gettext_noop("break [[filename:]N|function] - set breakpoint at the specified location.") },
2833 { "clear", "", D_clear, D_CLEAR, do_clear,
2834 gettext_noop("clear [[filename:]N|function] - delete breakpoints previously set.") },
2835 { "commands", "", D_commands, D_COMMANDS, do_commands,
2836 gettext_noop("commands [num] - starts a list of commands to be executed at a breakpoint(watchpoint) hit.") },
2837 { "condition", "", D_condition, D_CONDITION, do_condition,
2838 gettext_noop("condition num [expr] - set or clear breakpoint or watchpoint condition.") },
2839 { "continue", "c", D_continue, D_CONTINUE, do_continue,
2840 gettext_noop("continue [COUNT] - continue program being debugged.") },
2841 { "delete", "d", D_delete, D_DELETE, do_delete_breakpoint,
2842 gettext_noop("delete [breakpoints] [range] - delete specified breakpoints.") },
2843 { "disable", "", D_disable, D_DISABLE, do_disable_breakpoint,
2844 gettext_noop("disable [breakpoints] [range] - disable specified breakpoints.") },
2845 { "display", "", D_display, D_DISPLAY, do_display,
2846 gettext_noop("display [var] - print value of variable each time the program stops.") },
2847 { "down", "", D_down, D_DOWN, do_down,
2848 gettext_noop("down [N] - move N frames down the stack.") },
2849 { "dump", "", D_dump, D_DUMP, do_dump_instructions,
2850 gettext_noop("dump [filename] - dump instructions to file or stdout.") },
2851 { "enable", "e", D_enable, D_ENABLE, do_enable_breakpoint,
2852 gettext_noop("enable [once|del] [breakpoints] [range] - enable specified breakpoints.") },
2853 { "end", "", D_end, D_END, do_commands,
2854 gettext_noop("end - end a list of commands or awk statements.") },
2855 { "eval", "", D_eval, D_EVAL, do_eval,
2856 gettext_noop("eval stmt|[p1, p2, ...] - evaluate awk statement(s).") },
2857 { "finish", "", D_finish, D_FINISH, do_finish,
2858 gettext_noop("finish - execute until selected stack frame returns.") },
2859 { "frame", "f", D_frame, D_FRAME, do_frame,
2860 gettext_noop("frame [N] - select and print stack frame number N.") },
2861 { "help", "h", D_help, D_HELP, do_help,
2862 gettext_noop("help [command] - print list of commands or explanation of command.") },
2863 { "ignore", "", D_ignore, D_IGNORE, do_ignore_breakpoint,
2864 gettext_noop("ignore N COUNT - set ignore-count of breakpoint number N to COUNT.") },
2865 { "info", "i", D_info, D_INFO, do_info,
2866 gettext_noop("info topic - source|sources|variables|functions|break|frame|args|locals|display|watch.") },
2867 { "list", "l", D_list, D_LIST, do_list,
2868 gettext_noop("list [-|+|[filename:]lineno|function|range] - list specified line(s).") },
2869 { "next", "n", D_next, D_NEXT, do_next,
2870 gettext_noop("next [COUNT] - step program, proceeding through subroutine calls.") },
2871 { "nexti", "ni", D_nexti, D_NEXTI, do_nexti,
2872 gettext_noop("nexti [COUNT] - step one instruction, but proceed through subroutine calls.") },
2873 { "option", "o", D_option, D_OPTION, do_option,
2874 gettext_noop("option [name[=value]] - set or display debugger option(s).") },
2875 { "print", "p", D_print, D_PRINT, do_print_var,
2876 gettext_noop("print var [var] - print value of a variable or array.") },
2877 { "printf", "", D_printf, D_PRINTF, do_print_f,
2878 gettext_noop("printf format, [arg], ... - formatted output.") },
2879 { "quit", "q", D_quit, D_QUIT, do_quit,
2880 gettext_noop("quit - exit debugger.") },
2881 { "return", "", D_return, D_RETURN, do_return,
2882 gettext_noop("return [value] - make selected stack frame return to its caller.") },
2883 { "run", "r", D_run, D_RUN, do_run,
2884 gettext_noop("run - start or restart executing program.") },
2885 #ifdef HAVE_LIBREADLINE
2886 { "save", "", D_save, D_SAVE, do_save,
2887 gettext_noop("save filename - save commands from the session to file.") },
2889 { "set", "", D_set, D_SET, do_set_var,
2890 gettext_noop("set var = value - assign value to a scalar variable.") },
2891 { "silent", "", D_silent, D_SILENT, do_commands,
2892 gettext_noop("silent - suspends usual message when stopped at a breakpoint/watchpoint.") },
2893 { "source", "", D_source, D_SOURCE, do_source,
2894 gettext_noop("source file - execute commands from file.") },
2895 { "step", "s", D_step, D_STEP, do_step,
2896 gettext_noop("step [COUNT] - step program until it reaches a different source line.") },
2897 { "stepi", "si", D_stepi, D_STEPI, do_stepi,
2898 gettext_noop("stepi [COUNT] - step one instruction exactly.") },
2899 { "tbreak", "t", D_tbreak, D_TBREAK, do_tmp_breakpoint,
2900 gettext_noop("tbreak [[filename:]N|function] - set a temporary breakpoint.") },
2901 { "trace", "", D_trace, D_TRACE, do_trace_instruction,
2902 gettext_noop("trace on|off - print instruction before executing.") },
2903 { "undisplay", "", D_undisplay, D_UNDISPLAY, do_undisplay,
2904 gettext_noop("undisplay [N] - remove variable(s) from automatic display list.") },
2905 { "until", "u", D_until, D_UNTIL, do_until,
2906 gettext_noop("until [[filename:]N|function] - execute until program reaches a different line or line N within current frame.") },
2907 { "unwatch", "", D_unwatch, D_UNWATCH, do_unwatch,
2908 gettext_noop("unwatch [N] - remove variable(s) from watch list.") },
2909 { "up", "", D_up, D_UP, do_up,
2910 gettext_noop("up [N] - move N frames up the stack.") },
2911 { "watch", "w", D_watch, D_WATCH, do_watch,
2912 gettext_noop("watch var - set a watchpoint for a variable.") },
2913 { NULL, NULL, D_illegal, 0, (Func_cmd) 0,
2917 struct argtoken argtab[] = {
2918 { "args", D_info, A_ARGS },
2919 { "break", D_info, A_BREAK },
2920 { "del", D_enable, A_DEL },
2921 { "display", D_info, A_DISPLAY },
2922 { "frame", D_info, A_FRAME },
2923 { "functions", D_info, A_FUNCTIONS },
2924 { "locals", D_info, A_LOCALS },
2925 { "off", D_trace, A_TRACE_OFF },
2926 { "on", D_trace, A_TRACE_ON },
2927 { "once", D_enable, A_ONCE },
2928 { "source", D_info, A_SOURCE },
2929 { "sources", D_info, A_SOURCES },
2930 { "variables", D_info, A_VARIABLES },
2931 { "watch", D_info, A_WATCH },
2932 { NULL, D_illegal, 0 },
2936 /* get_command --- return command handler function */
2939 get_command(int ctype)
2942 for (i = 0; cmdtab[i].name != NULL; i++) {
2943 if (cmdtab[i].type == ctype)
2944 return cmdtab[i].cf_ptr;
2946 return (Func_cmd) 0;
2949 /* get_command_name --- return command name given it's type */
2952 get_command_name(int ctype)
2955 for (i = 0; cmdtab[i].name != NULL; i++) {
2956 if (cmdtab[i].type == ctype)
2957 return cmdtab[i].name;
2962 /* mk_cmdarg --- make an argument for command */
2965 mk_cmdarg(enum argtype type)
2968 emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg");
2969 memset(arg, 0, sizeof(CMDARG));
2974 /* append_cmdarg --- append ARG to the list of arguments for the current command */
2977 append_cmdarg(CMDARG *arg)
2979 static CMDARG *savetail;
2981 if (arg_list == NULL)
2984 savetail->next = arg;
2988 /* free_cmdarg --- free all arguments in LIST */
2991 free_cmdarg(CMDARG *list)
2993 CMDARG *arg, *nexta;
2995 for (arg = list; arg != NULL; arg = nexta) {
2998 switch (arg->type) {
3003 if (arg->a_string != NULL)
3004 efree(arg->a_string);
3017 /* yyerror --- print a syntax error message */
3020 yyerror(const char *mesg, ...)
3023 va_start(args, mesg);
3024 fprintf(out_fp, _("error: "));
3025 vfprintf(out_fp, mesg, args);
3026 fprintf(out_fp, "\n");
3033 /* yylex --- read a command and turn it into tokens */
3038 static char *lexptr = NULL;
3039 static char *lexend;
3044 yylval = (CMDARG *) NULL;
3046 if (errcount > 0 && lexptr_begin == NULL) {
3047 /* fake a new line */
3052 if (lexptr_begin == NULL) {
3054 lexptr_begin = read_a_line(dPrompt);
3055 if (lexptr_begin == NULL) { /* EOF or error */
3056 if (get_eof_status() == EXIT_FATAL)
3058 if (get_eof_status() == EXIT_FAILURE) {
3059 static int seen_eof = 0;
3061 /* force a quit, and let do_quit (in debug.c) exit */
3064 fprintf(stderr, _("can't read command (%s)\n"), strerror(errno));
3065 exit_val = EXIT_FAILURE;
3067 exit_val = EXIT_SUCCESS; */
3070 return '\n'; /* end current command if any */
3071 } else if (seen_eof++ == 1) {
3072 cmd_idx = find_command("quit", 4);
3073 return D_QUIT; /* 'quit' token */
3075 return '\n'; /* end command 'quit' */
3078 d_error(_("can't read command (%s)"), strerror(errno));
3079 if (pop_cmd_src() == 0)
3081 exit(EXIT_FATAL); /* shouldn't happen */
3084 if (! in_commands && ! in_eval /* history expansion off in 'commands' and 'eval' */
3087 history_expand_line(&lexptr_begin);
3089 lexptr = lexptr_begin;
3090 lexend = lexptr + strlen(lexptr);
3091 if (*lexptr == '\0' /* blank line */
3096 #ifdef HAVE_LIBREADLINE
3098 h = previous_history();
3100 add_history(h->line);
3102 cmd_idx = repeat_idx;
3103 return cmdtab[cmd_idx].class; /* repeat last command */
3110 while (c == ' ' || c == '\t')
3113 if (! input_from_tty && c == '#')
3117 if (lexptr >= lexend)
3120 if (cmd_idx < 0) { /* need a command */
3121 if (c == '?' && tokstart[1] == '\0' && ! in_eval) {
3123 cmd_idx = find_command("help", 4);
3127 while (c != '\0' && c != ' ' && c != '\t') {
3128 if (! isalpha(c) && ! in_eval) {
3129 yyerror(_("invalid character in command"));
3135 toklen = lexptr - tokstart;
3139 && tokstart[3] == '\0'
3140 && tokstart[0] == 'e'
3141 && tokstart[1] == 'n'
3142 && tokstart[2] == 'd'
3144 cmd_idx = find_command(tokstart, toklen);
3151 cmd_idx = find_command(tokstart, toklen);
3153 if (in_commands && cmdtab[cmd_idx].type != D_eval) {
3154 /* add the actual command string (lexptr_begin) to
3155 * arg_list; command string for 'eval' prepended to the arg_list
3156 * in the grammer above (see eval_cmd non-terminal).
3159 arg = mk_cmdarg(D_string);
3160 arg->a_string = estrdup(lexptr_begin, lexend - lexptr_begin);
3163 return cmdtab[cmd_idx].class;
3165 yyerror(_("unknown command - \"%.*s\", try help"), toklen, tokstart);
3172 if (cmdtab[cmd_idx].type == D_option) {
3175 } else if (c == '-' || c == '+' || c == ':' || c == '|')
3180 int flags = ALREADY_MALLOCED;
3181 int esc_seen = FALSE;
3183 toklen = lexend - lexptr;
3184 emalloc(str, char *, toklen + 2, "yylex");
3187 while ((c = *++lexptr) != '"') {
3188 if (lexptr == lexend) {
3191 yyerror(_("unterminated string"));
3197 if (want_nodeval || c != '"')
3200 if (lexptr == lexend)
3207 if (! want_nodeval) {
3208 yylval = mk_cmdarg(D_string);
3209 yylval->a_string = estrdup(str, p - str);
3210 append_cmdarg(yylval);
3212 } else { /* awk string */
3215 yylval = mk_cmdarg(D_node);
3216 yylval->a_node = make_str_node(str, p - str, flags);
3217 append_cmdarg(yylval);
3222 if (! want_nodeval) {
3223 while ((c = *++lexptr) != '\0' && c != ':' && c != '-'
3224 && c != ' ' && c != '\t' && c != '=')
3227 /* Is it an integer? */
3228 if (isdigit((unsigned char) tokstart[0]) && cmdtab[cmd_idx].type != D_option) {
3233 l = strtol(tokstart, &end, 0);
3235 yyerror(_("%s"), strerror(errno));
3240 if (lexptr == end) {
3241 yylval = mk_cmdarg(D_int);
3243 append_cmdarg(yylval);
3248 /* Must be string */
3249 yylval = mk_cmdarg(D_string);
3250 yylval->a_string = estrdup(tokstart, lexptr - tokstart);
3251 append_cmdarg(yylval);
3255 /* assert(want_nodval == TRUE); */
3257 /* look for awk number */
3259 if (isdigit((unsigned char) tokstart[0])) {
3263 d = strtod(tokstart, &lexptr);
3265 yyerror(strerror(errno));
3269 yylval = mk_cmdarg(D_node);
3270 yylval->a_node = make_number(d);
3271 append_cmdarg(yylval);
3276 if (c == '$' || c == '@'
3277 || c == '[' || c == ']'
3278 || c == ',' || c == '=')
3281 if (c != '_' && ! isalpha(c)) {
3282 yyerror(_("invalid character"));
3286 while (isalnum(c) || c == '_')
3288 toklen = lexptr - tokstart;
3291 yylval = mk_cmdarg(D_variable);
3292 yylval->a_string = estrdup(tokstart, toklen);
3293 append_cmdarg(yylval);
3297 /* find_argument --- find index in 'argtab' for a command option */
3300 find_argument(CMDARG *arg)
3302 /* non-number argument */
3306 assert(cmd_idx >= 0);
3307 name = arg->a_string;
3309 for (idx = 0; (p = (char *) argtab[idx].name) != NULL; idx++) {
3310 if (cmdtab[cmd_idx].type == argtab[idx].cmd
3313 && strncmp(p, name, len) == 0
3317 return -1; /* invalid option */
3320 /* concat_args --- concatenate argument strings into a single string NODE */
3323 concat_args(CMDARG *arg, int count)
3327 char *str, *subsep, *p;
3328 long len, subseplen;
3332 n = force_string(arg->a_node);
3336 emalloc(tmp, NODE **, count * sizeof(NODE *), "concat_args");
3337 subseplen = SUBSEP_node->var_value->stlen;
3338 subsep = SUBSEP_node->var_value->stptr;
3341 for (i = 0; i < count; i++) {
3342 n = force_string(arg->a_node);
3343 len += n->stlen + subseplen;
3348 emalloc(str, char *, len + 2, "concat_args");
3350 memcpy(str, n->stptr, n->stlen);
3352 for (i = 1; i < count; i++) {
3355 else if (subseplen > 0) {
3356 memcpy(p, subsep, subseplen);
3361 memcpy(p, n->stptr, n->stlen);
3366 return make_str_node(str, len, ALREADY_MALLOCED);
3369 /* find_command --- find the index in 'cmdtab' using exact,
3370 * abbreviation or unique partial match
3374 find_command(const char *token, size_t toklen)
3378 int try_exact = TRUE;
3379 int abrv_match = -1;
3380 int partial_match = -1;
3382 #if 'a' == 0x81 /* it's EBCDIC */
3383 /* make sure all lower case characters in token (sorting
3384 * isn't the solution in this case)
3386 for (i = 0; i < toklen; i++) {
3387 if (token[i] != tolower(token[i]))
3392 k = sizeof(cmdtab)/sizeof(cmdtab[0]) - 1;
3393 for (i = 0; i < k; i++) {
3394 name = (char *) cmdtab[i].name;
3395 if (try_exact && *token == *name
3396 && toklen == strlen(name)
3397 && strncmp(name, token, toklen) == 0
3402 if (abrv_match < 0) {
3403 abrv = cmdtab[i].abbrvn;
3404 if (abrv[0] == token[0]) {
3405 if (toklen == 1 && ! abrv[1])
3407 else if (toklen == 2 && abrv[1] == token[1])
3411 if (! try_exact && abrv_match >= 0)
3413 if (partial_match < 0) {
3415 && toklen < strlen(name)
3416 && strncmp(name, token, toklen) == 0
3418 if ((i == k - 1 || strncmp(cmdtab[i + 1].name, token, toklen) != 0)
3419 && (i == 0 || strncmp(cmdtab[i - 1].name, token, toklen) != 0)
3425 return partial_match;
3428 /* do_help -- help command */
3431 do_help(CMDARG *arg, int cmd)
3435 initialize_pager(out_fp);
3436 if (setjmp(pager_quit_tag) == 0) {
3437 for (i = 0; cmdtab[i].name != NULL; i++) {
3438 gprintf(out_fp, "%s:\n", cmdtab[i].name);
3439 gprintf(out_fp, "\t%s\n", _(cmdtab[i].help_txt));
3442 } else if (arg->type == D_string) {
3444 name = arg->a_string;
3445 i = find_command(name, strlen(name));
3447 fprintf(out_fp, "%s\n", cmdtab[i].help_txt);
3448 if (strcmp(cmdtab[i].name, "option") == 0)
3451 fprintf(out_fp, _("undefined command: %s\n"), name);
3458 /* next_word --- find the next word in a line to complete
3459 * (word seperation characters are space and tab).
3463 next_word(char *p, int len, char **endp)
3468 if (p == NULL || len <= 0)
3470 for (i = 0; i < len; i++, p++)
3471 if (*p != ' ' && *p != '\t')
3476 for (i++, q = p + 1; i < len; i++, q++)
3477 if (*q == ' ' || *q == '\t')
3484 #ifdef HAVE_LIBREADLINE
3486 /* command_completion --- attempt to complete based on the word number in line;
3487 * try to complete on command names if this is the first word; for the next
3488 * word(s), the type of completion depends on the command name (first word).
3491 #ifndef RL_READLINE_VERSION /* < 4.2a */
3492 #define rl_completion_matches(x, y) completion_matches((char *) (x), (y))
3497 command_completion(const char *text, int start, int end)
3503 rl_attempted_completion_over = TRUE; /* no default filename completion please */
3505 this_cmd = D_illegal;
3507 if ((cmdtok = next_word(rl_line_buffer, len, &e)) == NULL) /* no first word yet */
3508 return rl_completion_matches(text, command_generator);
3509 len -= (e - rl_line_buffer);
3511 idx = find_command(cmdtok, e - cmdtok);
3514 this_cmd = cmdtab[idx].type;
3516 if (! next_word(e, len, NULL)) {
3523 return rl_completion_matches(text, srcfile_generator);
3528 return rl_completion_matches(text, argument_generator);
3530 return rl_completion_matches(text, option_generator);
3536 return rl_completion_matches(text, variable_generator);
3541 if (this_cmd == D_print || this_cmd == D_printf)
3542 return rl_completion_matches(text, variable_generator);
3546 /* command_generator --- generator function for command completion */
3549 command_generator(const char *text, int state)
3551 static size_t textlen;
3555 if (! state) { /* first time */
3556 textlen = strlen(text);
3559 while ((name = (char *) cmdtab[idx].name) != NULL) {
3561 if (strncmp(name, text, textlen) == 0)
3562 return estrdup(name, strlen(name));
3567 /* srcfile_generator --- generator function for source file completion */
3570 srcfile_generator(const char *text, int state)
3572 static size_t textlen;
3575 extern SRCFILE *srcfiles;
3577 if (! state) { /* first time */
3578 textlen = strlen(text);
3581 while (s != srcfiles) {
3582 if (s->stype != SRC_FILE && s->stype != SRC_INC) {
3588 if (strncmp(name, text, textlen) == 0)
3589 return estrdup(name, strlen(name));
3594 /* argument_generator --- generator function for non-number argument completion */
3597 argument_generator(const char *text, int state)
3599 static size_t textlen;
3603 if (! state) { /* first time */
3604 textlen = strlen(text);
3608 if (this_cmd == D_help) {
3609 while ((name = (char *) cmdtab[idx++].name) != NULL) {
3610 if (strncmp(name, text, textlen) == 0)
3611 return estrdup(name, strlen(name));
3614 while ((name = (char *) argtab[idx].name) != NULL) {
3615 if (this_cmd != argtab[idx++].cmd)
3617 if (strncmp(name, text, textlen) == 0)
3618 return estrdup(name, strlen(name));
3624 /* variable_generator --- generator function for variable name completion */
3627 variable_generator(const char *text, int state)
3629 static size_t textlen;
3631 static char **pnames = NULL;
3632 static NODE **var_table = NULL;
3636 if (! state) { /* first time */
3637 textlen = strlen(text);
3638 if (var_table != NULL)
3640 var_table = get_varlist();
3642 pnames = get_parmlist(); /* names of function params in
3643 * current context; the array
3644 * is NULL terminated in
3645 * awkgram.y (func_install).
3649 /* function params */
3650 while (pnames != NULL) {
3653 pnames = NULL; /* don't try to match params again */
3658 if (strncmp(name, text, textlen) == 0)
3659 return estrdup(name, strlen(name));
3663 while ((hp = var_table[idx]) != NULL) {
3665 if (hp->hvalue->type == Node_func)
3667 if (strncmp(hp->hname, text, textlen) == 0)
3668 return estrdup(hp->hname, hp->hlength);
3673 /* history_expand_line --- history expand the LINE */
3676 history_expand_line(char **line)
3681 if (! *line || input_fd != 0 || ! input_from_tty)
3684 ret = history_expand(*line, &expansion);
3685 if (ret < 0 || ret == 2)