1 /* A Bison parser, made by GNU Bison 3.0.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 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 "3.0.2"
50 #define YYSKELETON_NAME "yacc.c"
62 /* Substitute the variable and function names. */
63 #define yyparse zzparse
65 #define yyerror zzerror
66 #define yydebug zzdebug
67 #define yynerrs zznerrs
72 /* Copy the first part of user declarations. */
73 #line 26 "command.y" /* yacc.c:339 */
83 static int yylex(void);
84 static void yyerror(const char *mesg, ...);
86 static int find_command(const char *token, size_t toklen);
88 static bool want_nodeval = false;
90 static int cmd_idx = -1; /* index of current command in cmd table */
91 static int repeat_idx = -1; /* index of last repeatable command in command table */
92 static CMDARG *arg_list = NULL; /* list of arguments */
93 static long errcount = 0;
94 static char *lexptr_begin = NULL;
95 static bool in_commands = false;
98 static bool in_eval = false;
99 static const char start_EVAL[] = "function @eval(){";
100 static const char end_EVAL[] = "}";
101 static CMDARG *append_statement(CMDARG *stmt_list, char *stmt);
102 static NODE *concat_args(CMDARG *a, int count);
104 #ifdef HAVE_LIBREADLINE
105 static char *next_word(char *p, int len, char **endp);
106 static void history_expand_line(char **line);
107 static char *command_generator(const char *text, int state);
108 static char *srcfile_generator(const char *text, int state);
109 static char *argument_generator(const char *text, int state);
110 static char *variable_generator(const char *text, int state);
111 extern char *option_generator(const char *text, int state);
112 static int this_cmd = D_illegal;
114 #define history_expand_line(p) /* nothing */
115 static int rl_inhibit_completion; /* dummy variable */
121 enum nametypeval value;
125 * These two should be static, but there are some compilers that
126 * don't like the static keyword with an empty size. Therefore give
127 * them names that are less likely to conflict with the rest of gawk.
129 #define argtab zz_debug_argtab
130 #define cmdtab zz_debug_cmdtab
132 extern struct argtoken argtab[];
133 extern struct cmdtoken cmdtab[];
135 static CMDARG *mk_cmdarg(enum argtype type);
136 static void append_cmdarg(CMDARG *arg);
137 static int find_argument(CMDARG *arg);
138 #define YYSTYPE CMDARG *
140 #line 141 "command.c" /* yacc.c:339 */
143 # if defined __cplusplus && 201103L <= __cplusplus
144 # define YY_NULLPTR nullptr
146 # define YY_NULLPTR 0
150 /* Enabling verbose error messages. */
151 #ifdef YYERROR_VERBOSE
152 # undef YYERROR_VERBOSE
153 # define YYERROR_VERBOSE 1
155 # define YYERROR_VERBOSE 0
221 #define D_BACKTRACE 258
224 #define D_CONTINUE 261
226 #define D_DISABLE 263
248 #define D_DISPLAY 285
249 #define D_UNDISPLAY 286
251 #define D_UNWATCH 288
257 #define D_VARIABLE 294
259 #define D_COMMANDS 296
265 #define D_CONDITION 302
266 #define D_STATEMENT 303
269 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
271 # define YYSTYPE_IS_TRIVIAL 1
272 # define YYSTYPE_IS_DECLARED 1
276 extern YYSTYPE zzlval;
282 /* Copy the second part of user declarations. */
284 #line 285 "command.c" /* yacc.c:358 */
291 typedef YYTYPE_UINT8 yytype_uint8;
293 typedef unsigned char yytype_uint8;
297 typedef YYTYPE_INT8 yytype_int8;
299 typedef signed char yytype_int8;
303 typedef YYTYPE_UINT16 yytype_uint16;
305 typedef unsigned short int yytype_uint16;
309 typedef YYTYPE_INT16 yytype_int16;
311 typedef short int yytype_int16;
315 # ifdef __SIZE_TYPE__
316 # define YYSIZE_T __SIZE_TYPE__
317 # elif defined size_t
318 # define YYSIZE_T size_t
319 # elif ! defined YYSIZE_T
320 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
321 # define YYSIZE_T size_t
323 # define YYSIZE_T unsigned int
327 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
330 # if defined YYENABLE_NLS && YYENABLE_NLS
332 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
333 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
337 # define YY_(Msgid) Msgid
342 # if (defined __GNUC__ \
343 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
344 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
345 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
347 # define YY_ATTRIBUTE(Spec) /* empty */
351 #ifndef YY_ATTRIBUTE_PURE
352 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
355 #ifndef YY_ATTRIBUTE_UNUSED
356 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
359 #if !defined _Noreturn \
360 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
361 # if defined _MSC_VER && 1200 <= _MSC_VER
362 # define _Noreturn __declspec (noreturn)
364 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
368 /* Suppress unused-variable warnings by "using" E. */
369 #if ! defined lint || defined __GNUC__
370 # define YYUSE(E) ((void) (E))
372 # define YYUSE(E) /* empty */
375 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
376 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
377 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
378 _Pragma ("GCC diagnostic push") \
379 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
380 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
381 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
382 _Pragma ("GCC diagnostic pop")
384 # define YY_INITIAL_VALUE(Value) Value
386 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
387 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
388 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
390 #ifndef YY_INITIAL_VALUE
391 # define YY_INITIAL_VALUE(Value) /* Nothing. */
395 #if ! defined yyoverflow || YYERROR_VERBOSE
397 /* The parser invokes alloca or malloc; define the necessary symbols. */
399 # ifdef YYSTACK_USE_ALLOCA
400 # if YYSTACK_USE_ALLOCA
402 # define YYSTACK_ALLOC __builtin_alloca
403 # elif defined __BUILTIN_VA_ARG_INCR
404 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
406 # define YYSTACK_ALLOC __alloca
407 # elif defined _MSC_VER
408 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
409 # define alloca _alloca
411 # define YYSTACK_ALLOC alloca
412 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
413 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
414 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
415 # ifndef EXIT_SUCCESS
416 # define EXIT_SUCCESS 0
423 # ifdef YYSTACK_ALLOC
424 /* Pacify GCC's 'empty if-body' warning. */
425 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
426 # ifndef YYSTACK_ALLOC_MAXIMUM
427 /* The OS might guarantee only one guard page at the bottom of the stack,
428 and a page size can be as small as 4096 bytes. So we cannot safely
429 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
430 to allow for a few compiler-allocated temporary stack slots. */
431 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
434 # define YYSTACK_ALLOC YYMALLOC
435 # define YYSTACK_FREE YYFREE
436 # ifndef YYSTACK_ALLOC_MAXIMUM
437 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
439 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
440 && ! ((defined YYMALLOC || defined malloc) \
441 && (defined YYFREE || defined free)))
442 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
443 # ifndef EXIT_SUCCESS
444 # define EXIT_SUCCESS 0
448 # define YYMALLOC malloc
449 # if ! defined malloc && ! defined EXIT_SUCCESS
450 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
455 # if ! defined free && ! defined EXIT_SUCCESS
456 void free (void *); /* INFRINGES ON USER NAME SPACE */
460 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
463 #if (! defined yyoverflow \
464 && (! defined __cplusplus \
465 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
467 /* A type that is properly aligned for any stack member. */
470 yytype_int16 yyss_alloc;
474 /* The size of the maximum gap between one aligned stack and the next. */
475 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
477 /* The size of an array large to enough to hold all stacks, each with
479 # define YYSTACK_BYTES(N) \
480 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
481 + YYSTACK_GAP_MAXIMUM)
483 # define YYCOPY_NEEDED 1
485 /* Relocate STACK from its old location to the new one. The
486 local variables YYSIZE and YYSTACKSIZE give the old and new number of
487 elements in the stack, and YYPTR gives the new location of the
488 stack. Advance YYPTR to a properly aligned location for the next
490 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
493 YYSIZE_T yynewbytes; \
494 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
495 Stack = &yyptr->Stack_alloc; \
496 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
497 yyptr += yynewbytes / sizeof (*yyptr); \
503 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
504 /* Copy COUNT objects from SRC to DST. The source and destination do
507 # if defined __GNUC__ && 1 < __GNUC__
508 # define YYCOPY(Dst, Src, Count) \
509 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
511 # define YYCOPY(Dst, Src, Count) \
515 for (yyi = 0; yyi < (Count); yyi++) \
516 (Dst)[yyi] = (Src)[yyi]; \
521 #endif /* !YYCOPY_NEEDED */
523 /* YYFINAL -- State number of the termination state. */
525 /* YYLAST -- Last index in YYTABLE. */
528 /* YYNTOKENS -- Number of terminals. */
530 /* YYNNTS -- Number of nonterminals. */
532 /* YYNRULES -- Number of rules. */
534 /* YYNSTATES -- Number of states. */
535 #define YYNSTATES 203
537 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
538 by yylex, with out-of-bounds checking. */
540 #define YYMAXUTOK 303
542 #define YYTRANSLATE(YYX) \
543 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
545 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
546 as returned by yylex, without out-of-bounds checking. */
547 static const yytype_uint8 yytranslate[] =
549 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 58, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 57, 2, 2, 2,
553 2, 2, 2, 53, 50, 54, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 51, 2,
555 2, 49, 2, 2, 52, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 55, 2, 56, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
575 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
576 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
577 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
578 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
583 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
584 static const yytype_uint16 yyrline[] =
586 0, 106, 106, 108, 126, 127, 177, 184, 185, 186,
587 187, 188, 192, 193, 194, 195, 199, 200, 201, 202,
588 206, 207, 212, 216, 236, 243, 243, 250, 266, 280,
589 281, 282, 283, 284, 285, 291, 303, 304, 305, 305,
590 306, 306, 307, 308, 309, 310, 311, 311, 312, 313,
591 313, 314, 314, 315, 315, 316, 317, 318, 323, 328,
592 354, 364, 369, 381, 381, 389, 403, 416, 417, 423,
593 424, 428, 429, 430, 431, 437, 438, 439, 444, 455,
594 456, 461, 469, 486, 487, 488, 489, 490, 495, 496,
595 496, 497, 498, 498, 499, 504, 505, 510, 511, 516,
596 517, 520, 522, 526, 527, 542, 543, 548, 556, 557,
597 558, 559, 563, 564, 568, 569, 570, 575, 576, 578,
598 585, 586, 587, 588, 589, 590, 594, 607, 608, 609,
599 613, 614, 615, 616, 620, 622, 624, 628, 643, 647,
600 649, 654, 655, 664, 674, 676, 683, 696, 697, 703,
601 704, 709, 715, 724, 726, 728, 736
605 #if YYDEBUG || YYERROR_VERBOSE || 0
606 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
607 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
608 static const char *const yytname[] =
610 "$end", "error", "$undefined", "D_BACKTRACE", "D_BREAK", "D_CLEAR",
611 "D_CONTINUE", "D_DELETE", "D_DISABLE", "D_DOWN", "D_ENABLE", "D_FINISH",
612 "D_FRAME", "D_HELP", "D_IGNORE", "D_INFO", "D_LIST", "D_NEXT", "D_NEXTI",
613 "D_PRINT", "D_PRINTF", "D_QUIT", "D_RETURN", "D_RUN", "D_SET", "D_STEP",
614 "D_STEPI", "D_TBREAK", "D_UP", "D_UNTIL", "D_DISPLAY", "D_UNDISPLAY",
615 "D_WATCH", "D_UNWATCH", "D_DUMP", "D_TRACE", "D_INT", "D_STRING",
616 "D_NODE", "D_VARIABLE", "D_OPTION", "D_COMMANDS", "D_END", "D_SILENT",
617 "D_SOURCE", "D_SAVE", "D_EVAL", "D_CONDITION", "D_STATEMENT", "'='",
618 "','", "':'", "'@'", "'+'", "'-'", "'['", "']'", "'$'", "'\\n'",
619 "$accept", "input", "line", "control_cmd", "d_cmd", "frame_cmd",
620 "break_cmd", "set_want_nodeval", "eval_prologue", "statement_list", "@1",
621 "eval_cmd", "command", "$@2", "$@3", "$@4", "$@5", "$@6", "$@7", "$@8",
622 "condition_exp", "commands_arg", "opt_param_list", "param_list",
623 "opt_string_node", "string_node", "option_args", "func_name", "location",
624 "break_args", "$@9", "$@10", "opt_variable", "opt_string", "opt_node",
625 "help_args", "enable_args", "print_exp", "print_args", "printf_exp",
626 "printf_args", "list_args", "integer_range", "opt_integer_list",
627 "integer_list", "exp_list", "subscript", "subscript_list", "variable",
628 "node", "opt_plus_integer", "opt_integer", "plus_integer", "integer",
634 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
635 (internal) symbol number NUM (which must be that of a token). */
636 static const yytype_uint16 yytoknum[] =
638 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
639 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
640 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
641 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
642 295, 296, 297, 298, 299, 300, 301, 302, 303, 61,
643 44, 58, 64, 43, 45, 91, 93, 36, 10
647 #define YYPACT_NINF -151
649 #define yypact_value_is_default(Yystate) \
650 (!!((Yystate) == (-151)))
652 #define YYTABLE_NINF -148
654 #define yytable_value_is_error(Yytable_value) \
657 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
659 static const yytype_int16 yypact[] =
661 -151, 145, -151, -34, -151, -151, 50, -151, -151, -151,
662 -151, 10, -151, -151, -10, 59, -9, 43, -151, -151,
663 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
664 50, -151, -151, -151, -151, -8, -6, 14, 12, -151,
665 -151, 22, 23, -151, 59, -151, -151, 59, 13, 36,
666 64, -151, -151, -34, -151, -151, -151, 24, 47, -151,
667 -151, -151, -151, 13, -151, -151, -151, 59, 48, -151,
668 -151, 80, -151, 67, 47, -151, -151, -151, -151, 48,
669 4, 19, 69, -20, -151, -20, -20, -151, -151, -151,
670 70, -151, -151, -151, -151, -151, -151, -151, 16, -151,
671 -151, -151, -151, 84, 85, -151, -151, 73, -151, -151,
672 -151, 40, -151, 74, -151, -151, -151, 48, 59, -151,
673 74, -151, 71, 89, 91, -151, 42, -151, -151, -151,
674 -151, 81, -151, -151, 92, 94, -151, -151, 86, -151,
675 -151, 6, 96, -151, -151, -151, -34, 75, -151, 6,
676 -151, -151, 74, 6, -151, -151, -151, -151, -151, -151,
677 -151, -151, 48, 31, -151, 71, 71, -151, 52, -151,
678 -17, -151, -151, 69, -151, -151, -151, -151, -151, -151,
679 -151, 95, -151, -151, -151, -151, -34, -151, 17, -151,
680 -151, 71, -151, -151, -151, -151, 6, -151, -151, 69,
684 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
685 Performed when YYTABLE does not specify something else to do. Zero
686 means the default is an error. */
687 static const yytype_uint8 yydefact[] =
689 2, 0, 1, 0, 18, 20, 83, 7, 15, 14,
690 17, 0, 32, 19, 101, 0, 0, 117, 8, 9,
691 38, 40, 30, 49, 31, 46, 10, 11, 21, 16,
692 83, 51, 12, 53, 13, 97, 0, 79, 0, 60,
693 61, 0, 0, 22, 0, 156, 3, 147, 0, 149,
694 88, 24, 65, 0, 4, 6, 151, 82, 0, 85,
695 44, 84, 129, 0, 37, 131, 103, 128, 130, 102,
696 29, 0, 35, 82, 118, 119, 121, 42, 122, 120,
697 0, 0, 99, 0, 43, 95, 0, 98, 56, 62,
698 80, 48, 68, 59, 67, 148, 57, 58, 0, 63,
699 33, 55, 153, 0, 0, 34, 150, 82, 91, 45,
700 89, 0, 5, 0, 152, 104, 133, 132, 0, 36,
701 0, 111, 141, 0, 0, 108, 39, 105, 116, 112,
702 114, 41, 113, 144, 0, 0, 50, 100, 0, 52,
703 96, 0, 0, 74, 78, 71, 0, 70, 28, 0,
704 154, 155, 0, 0, 27, 25, 82, 87, 86, 126,
705 124, 125, 123, 0, 139, 143, 106, 142, 0, 109,
706 0, 145, 146, 0, 77, 54, 66, 76, 81, 23,
707 72, 0, 64, 94, 92, 90, 0, 136, 0, 134,
708 140, 107, 110, 115, 47, 73, 0, 26, 138, 0,
712 /* YYPGOTO[NTERM-NUM]. */
713 static const yytype_int16 yypgoto[] =
715 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
716 -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
717 -119, -151, -151, -151, -151, 38, -151, -15, 108, -151,
718 -151, -151, -151, -151, -151, -151, -151, -90, -151, -31,
719 -151, -151, -14, -25, -151, -151, -150, -26, -77, -147,
720 97, -151, -5, -151, -3
723 /* YYDEFGOTO[NTERM-NUM]. */
724 static const yytype_int16 yydefgoto[] =
726 -1, 1, 46, 47, 48, 49, 50, 98, 51, 111,
727 186, 52, 53, 80, 81, 83, 82, 85, 86, 149,
728 175, 93, 146, 147, 176, 177, 91, 59, 60, 109,
729 153, 196, 139, 88, 136, 70, 64, 125, 126, 130,
730 131, 77, 65, 66, 67, 188, 164, 165, 127, 137,
734 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
735 positive, shift that token. If negative, reduce the rule whose
736 number is the opposite. If YYTABLE_NINF, syntax error. */
737 static const yytype_int16 yytable[] =
739 55, 61, 76, 78, 132, 121, 138, 174, 140, 141,
740 71, 62, 79, 92, 62, 190, 189, 143, 198, 122,
741 128, 129, 122, 101, 45, 61, 194, 69, 72, 87,
742 182, 89, 187, 95, 185, 108, 169, 124, 115, 99,
743 124, 190, 95, 122, 144, 110, 56, 63, 56, 56,
744 112, 90, 202, 116, 144, 145, 123, 129, 122, 96,
745 97, 124, 117, 58, -75, 58, 58, 199, -127, 133,
746 -147, -127, 102, 200, -69, 113, 124, 201, 192, 56,
747 73, 122, 154, 114, 134, 135, 56, 57, 155, 103,
748 104, 122, 168, 132, 123, 56, 74, 75, 157, 124,
749 56, 107, 118, 58, 123, 160, 161, 133, 158, 124,
750 56, 156, 58, 159, 180, 162, 119, 58, 120, 142,
751 150, 151, 134, 135, 152, 181, 163, 58, 166, 167,
752 171, 170, 172, 178, 195, 173, 148, 183, 84, 193,
753 191, 0, 0, 179, 100, 2, 3, 184, 4, 5,
754 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
755 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
756 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
757 36, 0, 0, 197, 0, 37, 38, 39, 40, 41,
758 42, 43, 44, 0, 0, 0, 0, 0, 0, 0,
762 static const yytype_int16 yycheck[] =
764 3, 6, 17, 17, 81, 1, 83, 1, 85, 86,
765 15, 1, 17, 1, 1, 165, 163, 1, 1, 39,
766 1, 38, 39, 48, 58, 30, 173, 37, 37, 37,
767 149, 37, 1, 38, 153, 50, 126, 57, 63, 44,
768 57, 191, 47, 39, 38, 50, 36, 37, 36, 36,
769 53, 37, 199, 67, 38, 39, 52, 38, 39, 37,
770 37, 57, 67, 53, 58, 53, 53, 50, 58, 38,
771 58, 58, 36, 56, 58, 51, 57, 196, 168, 36,
772 37, 39, 42, 36, 53, 54, 36, 37, 48, 53,
773 54, 39, 50, 170, 52, 36, 53, 54, 113, 57,
774 36, 37, 54, 53, 52, 120, 120, 38, 113, 57,
775 36, 37, 53, 118, 39, 120, 36, 53, 51, 49,
776 36, 36, 53, 54, 51, 50, 55, 53, 39, 38,
777 38, 50, 38, 37, 39, 49, 98, 152, 30, 170,
778 166, -1, -1, 146, 47, 0, 1, 152, 3, 4,
779 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
780 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
781 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
782 35, -1, -1, 186, -1, 40, 41, 42, 43, 44,
783 45, 46, 47, -1, -1, -1, -1, -1, -1, -1,
787 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
788 symbol of state STATE-NUM. */
789 static const yytype_uint8 yystos[] =
791 0, 60, 0, 1, 3, 4, 5, 6, 7, 8,
792 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
793 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
794 29, 30, 31, 32, 33, 34, 35, 40, 41, 42,
795 43, 44, 45, 46, 47, 58, 61, 62, 63, 64,
796 65, 67, 70, 71, 113, 113, 36, 37, 53, 86,
797 87, 111, 1, 37, 95, 101, 102, 103, 111, 37,
798 94, 111, 37, 37, 53, 54, 86, 100, 101, 111,
799 72, 73, 75, 74, 87, 76, 77, 37, 92, 37,
800 37, 85, 1, 80, 109, 111, 37, 37, 66, 111,
801 109, 102, 36, 53, 54, 110, 112, 37, 86, 88,
802 111, 68, 113, 51, 36, 102, 101, 111, 54, 36,
803 51, 1, 39, 52, 57, 96, 97, 107, 1, 38,
804 98, 99, 107, 38, 53, 54, 93, 108, 107, 91,
805 107, 107, 49, 1, 38, 39, 81, 82, 84, 78,
806 36, 36, 51, 89, 42, 48, 37, 86, 111, 111,
807 86, 101, 111, 55, 105, 106, 39, 38, 50, 96,
808 50, 38, 38, 49, 1, 79, 83, 84, 37, 113,
809 39, 50, 79, 86, 111, 79, 69, 1, 104, 108,
810 105, 106, 96, 98, 108, 39, 90, 113, 1, 50,
814 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
815 static const yytype_uint8 yyr1[] =
817 0, 59, 60, 60, 61, 61, 61, 62, 62, 62,
818 62, 62, 63, 63, 63, 63, 64, 64, 64, 64,
819 65, 65, 66, 67, 68, 69, 68, 70, 70, 71,
820 71, 71, 71, 71, 71, 71, 71, 71, 72, 71,
821 73, 71, 71, 71, 71, 71, 74, 71, 71, 75,
822 71, 76, 71, 77, 71, 71, 71, 71, 71, 71,
823 71, 71, 71, 78, 71, 71, 79, 80, 80, 81,
824 81, 82, 82, 82, 82, 83, 83, 83, 84, 85,
825 85, 85, 86, 87, 87, 87, 87, 87, 88, 89,
826 88, 88, 90, 88, 88, 91, 91, 92, 92, 93,
827 93, 94, 94, 95, 95, 96, 96, 96, 97, 97,
828 97, 97, 98, 98, 99, 99, 99, 100, 100, 100,
829 100, 100, 100, 100, 100, 100, 101, 102, 102, 102,
830 103, 103, 103, 103, 104, 104, 104, 105, 105, 106,
831 106, 107, 107, 107, 108, 108, 108, 109, 109, 110,
832 110, 111, 111, 112, 112, 112, 113
835 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
836 static const yytype_uint8 yyr2[] =
838 0, 2, 0, 2, 1, 2, 2, 1, 1, 1,
839 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
840 1, 1, 0, 4, 0, 0, 4, 3, 3, 2,
841 1, 1, 1, 2, 2, 2, 3, 2, 0, 3,
842 0, 3, 2, 2, 2, 2, 0, 5, 2, 0,
843 3, 0, 3, 0, 4, 2, 2, 2, 2, 2,
844 1, 1, 2, 0, 4, 1, 1, 1, 1, 0,
845 1, 1, 2, 3, 1, 0, 1, 1, 1, 0,
846 1, 3, 1, 0, 1, 1, 3, 3, 0, 0,
847 3, 1, 0, 5, 3, 0, 1, 0, 1, 0,
848 1, 0, 1, 1, 2, 1, 2, 3, 1, 2,
849 3, 1, 1, 1, 1, 3, 1, 0, 1, 1,
850 1, 1, 1, 3, 3, 3, 3, 0, 1, 1,
851 1, 1, 2, 2, 1, 3, 1, 3, 3, 1,
852 2, 1, 2, 2, 1, 2, 2, 0, 1, 0,
857 #define yyerrok (yyerrstatus = 0)
858 #define yyclearin (yychar = YYEMPTY)
862 #define YYACCEPT goto yyacceptlab
863 #define YYABORT goto yyabortlab
864 #define YYERROR goto yyerrorlab
867 #define YYRECOVERING() (!!yyerrstatus)
869 #define YYBACKUP(Token, Value) \
871 if (yychar == YYEMPTY) \
875 YYPOPSTACK (yylen); \
881 yyerror (YY_("syntax error: cannot back up")); \
886 /* Error token number */
888 #define YYERRCODE 256
892 /* Enable debugging if requested. */
896 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
897 # define YYFPRINTF fprintf
900 # define YYDPRINTF(Args) \
906 /* This macro is provided for backward compatibility. */
907 #ifndef YY_LOCATION_PRINT
908 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
912 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
916 YYFPRINTF (stderr, "%s ", Title); \
917 yy_symbol_print (stderr, \
919 YYFPRINTF (stderr, "\n"); \
924 /*----------------------------------------.
925 | Print this symbol's value on YYOUTPUT. |
926 `----------------------------------------*/
929 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
931 FILE *yyo = yyoutput;
936 if (yytype < YYNTOKENS)
937 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
943 /*--------------------------------.
944 | Print this symbol on YYOUTPUT. |
945 `--------------------------------*/
948 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
950 YYFPRINTF (yyoutput, "%s %s (",
951 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
953 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
954 YYFPRINTF (yyoutput, ")");
957 /*------------------------------------------------------------------.
958 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
960 `------------------------------------------------------------------*/
963 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
965 YYFPRINTF (stderr, "Stack now");
966 for (; yybottom <= yytop; yybottom++)
968 int yybot = *yybottom;
969 YYFPRINTF (stderr, " %d", yybot);
971 YYFPRINTF (stderr, "\n");
974 # define YY_STACK_PRINT(Bottom, Top) \
977 yy_stack_print ((Bottom), (Top)); \
981 /*------------------------------------------------.
982 | Report that the YYRULE is going to be reduced. |
983 `------------------------------------------------*/
986 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
988 unsigned long int yylno = yyrline[yyrule];
989 int yynrhs = yyr2[yyrule];
991 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
993 /* The symbols being reduced. */
994 for (yyi = 0; yyi < yynrhs; yyi++)
996 YYFPRINTF (stderr, " $%d = ", yyi + 1);
997 yy_symbol_print (stderr,
998 yystos[yyssp[yyi + 1 - yynrhs]],
999 &(yyvsp[(yyi + 1) - (yynrhs)])
1001 YYFPRINTF (stderr, "\n");
1005 # define YY_REDUCE_PRINT(Rule) \
1008 yy_reduce_print (yyssp, yyvsp, Rule); \
1011 /* Nonzero means print parse trace. It is left uninitialized so that
1012 multiple parsers can coexist. */
1014 #else /* !YYDEBUG */
1015 # define YYDPRINTF(Args)
1016 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1017 # define YY_STACK_PRINT(Bottom, Top)
1018 # define YY_REDUCE_PRINT(Rule)
1019 #endif /* !YYDEBUG */
1022 /* YYINITDEPTH -- initial size of the parser's stacks. */
1024 # define YYINITDEPTH 200
1027 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1028 if the built-in stack extension method is used).
1030 Do not make this value too large; the results are undefined if
1031 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1032 evaluated with infinite-precision integer arithmetic. */
1035 # define YYMAXDEPTH 10000
1042 # if defined __GLIBC__ && defined _STRING_H
1043 # define yystrlen strlen
1045 /* Return the length of YYSTR. */
1047 yystrlen (const char *yystr)
1050 for (yylen = 0; yystr[yylen]; yylen++)
1058 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1059 # define yystpcpy stpcpy
1061 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1064 yystpcpy (char *yydest, const char *yysrc)
1067 const char *yys = yysrc;
1069 while ((*yyd++ = *yys++) != '\0')
1078 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1079 quotes and backslashes, so that it's suitable for yyerror. The
1080 heuristic is that double-quoting is unnecessary unless the string
1081 contains an apostrophe, a comma, or backslash (other than
1082 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1083 null, do not copy; instead, return the length of what the result
1086 yytnamerr (char *yyres, const char *yystr)
1091 char const *yyp = yystr;
1098 goto do_not_strip_quotes;
1102 goto do_not_strip_quotes;
1115 do_not_strip_quotes: ;
1119 return yystrlen (yystr);
1121 return yystpcpy (yyres, yystr) - yyres;
1125 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1126 about the unexpected token YYTOKEN for the state stack whose top is
1129 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1130 not large enough to hold the message. In that case, also set
1131 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1132 required number of bytes is too large to store. */
1134 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1135 yytype_int16 *yyssp, int yytoken)
1137 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1138 YYSIZE_T yysize = yysize0;
1139 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1140 /* Internationalized format string. */
1141 const char *yyformat = YY_NULLPTR;
1142 /* Arguments of yyformat. */
1143 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1144 /* Number of reported tokens (one for the "unexpected", one per
1148 /* There are many possibilities here to consider:
1149 - If this state is a consistent state with a default action, then
1150 the only way this function was invoked is if the default action
1151 is an error action. In that case, don't check for expected
1152 tokens because there are none.
1153 - The only way there can be no lookahead present (in yychar) is if
1154 this state is a consistent state with a default action. Thus,
1155 detecting the absence of a lookahead is sufficient to determine
1156 that there is no unexpected or expected token to report. In that
1157 case, just report a simple "syntax error".
1158 - Don't assume there isn't a lookahead just because this state is a
1159 consistent state with a default action. There might have been a
1160 previous inconsistent state, consistent state with a non-default
1161 action, or user semantic action that manipulated yychar.
1162 - Of course, the expected token list depends on states to have
1163 correct lookahead information, and it depends on the parser not
1164 to perform extra reductions after fetching a lookahead from the
1165 scanner and before detecting a syntax error. Thus, state merging
1166 (from LALR or IELR) and default reductions corrupt the expected
1167 token list. However, the list is correct for canonical LR with
1168 one exception: it will still contain any token that will not be
1169 accepted due to an error action in a later state.
1171 if (yytoken != YYEMPTY)
1173 int yyn = yypact[*yyssp];
1174 yyarg[yycount++] = yytname[yytoken];
1175 if (!yypact_value_is_default (yyn))
1177 /* Start YYX at -YYN if negative to avoid negative indexes in
1178 YYCHECK. In other words, skip the first -YYN actions for
1179 this state because they are default actions. */
1180 int yyxbegin = yyn < 0 ? -yyn : 0;
1181 /* Stay within bounds of both yycheck and yytname. */
1182 int yychecklim = YYLAST - yyn + 1;
1183 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1186 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1187 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1188 && !yytable_value_is_error (yytable[yyx + yyn]))
1190 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1196 yyarg[yycount++] = yytname[yyx];
1198 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1199 if (! (yysize <= yysize1
1200 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1210 # define YYCASE_(N, S) \
1214 YYCASE_(0, YY_("syntax error"));
1215 YYCASE_(1, YY_("syntax error, unexpected %s"));
1216 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1217 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1218 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1219 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1224 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1225 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1230 if (*yymsg_alloc < yysize)
1232 *yymsg_alloc = 2 * yysize;
1233 if (! (yysize <= *yymsg_alloc
1234 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1235 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1239 /* Avoid sprintf, as that infringes on the user's name space.
1240 Don't have undefined behavior even if the translation
1241 produced a string with the wrong number of "%s"s. */
1245 while ((*yyp = *yyformat) != '\0')
1246 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1248 yyp += yytnamerr (yyp, yyarg[yyi++]);
1259 #endif /* YYERROR_VERBOSE */
1261 /*-----------------------------------------------.
1262 | Release the memory associated to this symbol. |
1263 `-----------------------------------------------*/
1266 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1271 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1273 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1275 YY_IGNORE_MAYBE_UNINITIALIZED_END
1281 /* The lookahead symbol. */
1284 /* The semantic value of the lookahead symbol. */
1286 /* Number of syntax errors so far. */
1298 /* Number of tokens to shift before error messages enabled. */
1301 /* The stacks and their tools:
1302 'yyss': related to states.
1303 'yyvs': related to semantic values.
1305 Refer to the stacks through separate pointers, to allow yyoverflow
1306 to reallocate them elsewhere. */
1308 /* The state stack. */
1309 yytype_int16 yyssa[YYINITDEPTH];
1311 yytype_int16 *yyssp;
1313 /* The semantic value stack. */
1314 YYSTYPE yyvsa[YYINITDEPTH];
1318 YYSIZE_T yystacksize;
1322 /* Lookahead token as an internal (translated) token number. */
1324 /* The variables used to return semantic value and location from the
1329 /* Buffer for error messages, and its allocated size. */
1331 char *yymsg = yymsgbuf;
1332 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1335 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1337 /* The number of symbols on the RHS of the reduced rule.
1338 Keep to zero when no symbol should be popped. */
1341 yyssp = yyss = yyssa;
1342 yyvsp = yyvs = yyvsa;
1343 yystacksize = YYINITDEPTH;
1345 YYDPRINTF ((stderr, "Starting parse\n"));
1350 yychar = YYEMPTY; /* Cause a token to be read. */
1353 /*------------------------------------------------------------.
1354 | yynewstate -- Push a new state, which is found in yystate. |
1355 `------------------------------------------------------------*/
1357 /* In all cases, when you get here, the value and location stacks
1358 have just been pushed. So pushing a state here evens the stacks. */
1364 if (yyss + yystacksize - 1 <= yyssp)
1366 /* Get the current used size of the three stacks, in elements. */
1367 YYSIZE_T yysize = yyssp - yyss + 1;
1371 /* Give user a chance to reallocate the stack. Use copies of
1372 these so that the &'s don't force the real ones into
1374 YYSTYPE *yyvs1 = yyvs;
1375 yytype_int16 *yyss1 = yyss;
1377 /* Each stack pointer address is followed by the size of the
1378 data in use in that stack, in bytes. This used to be a
1379 conditional around just the two extra args, but that might
1380 be undefined if yyoverflow is a macro. */
1381 yyoverflow (YY_("memory exhausted"),
1382 &yyss1, yysize * sizeof (*yyssp),
1383 &yyvs1, yysize * sizeof (*yyvsp),
1389 #else /* no yyoverflow */
1390 # ifndef YYSTACK_RELOCATE
1391 goto yyexhaustedlab;
1393 /* Extend the stack our own way. */
1394 if (YYMAXDEPTH <= yystacksize)
1395 goto yyexhaustedlab;
1397 if (YYMAXDEPTH < yystacksize)
1398 yystacksize = YYMAXDEPTH;
1401 yytype_int16 *yyss1 = yyss;
1402 union yyalloc *yyptr =
1403 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1405 goto yyexhaustedlab;
1406 YYSTACK_RELOCATE (yyss_alloc, yyss);
1407 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1408 # undef YYSTACK_RELOCATE
1410 YYSTACK_FREE (yyss1);
1413 #endif /* no yyoverflow */
1415 yyssp = yyss + yysize - 1;
1416 yyvsp = yyvs + yysize - 1;
1418 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1419 (unsigned long int) yystacksize));
1421 if (yyss + yystacksize - 1 <= yyssp)
1425 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1427 if (yystate == YYFINAL)
1437 /* Do appropriate processing given the current state. Read a
1438 lookahead token if we need one and don't already have one. */
1440 /* First try to decide what to do without reference to lookahead token. */
1441 yyn = yypact[yystate];
1442 if (yypact_value_is_default (yyn))
1445 /* Not known => get a lookahead token if don't already have one. */
1447 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1448 if (yychar == YYEMPTY)
1450 YYDPRINTF ((stderr, "Reading a token: "));
1454 if (yychar <= YYEOF)
1456 yychar = yytoken = YYEOF;
1457 YYDPRINTF ((stderr, "Now at end of input.\n"));
1461 yytoken = YYTRANSLATE (yychar);
1462 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1465 /* If the proper action on seeing token YYTOKEN is to reduce or to
1466 detect an error, take that action. */
1468 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1473 if (yytable_value_is_error (yyn))
1479 /* Count tokens shifted since error; after three, turn off error
1484 /* Shift the lookahead token. */
1485 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1487 /* Discard the shifted token. */
1491 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1493 YY_IGNORE_MAYBE_UNINITIALIZED_END
1498 /*-----------------------------------------------------------.
1499 | yydefault -- do the default action for the current state. |
1500 `-----------------------------------------------------------*/
1502 yyn = yydefact[yystate];
1508 /*-----------------------------.
1509 | yyreduce -- Do a reduction. |
1510 `-----------------------------*/
1512 /* yyn is the number of a rule to reduce with. */
1515 /* If YYLEN is nonzero, implement the default value of the action:
1518 Otherwise, the following line sets YYVAL to garbage.
1519 This behavior is undocumented and Bison
1520 users should not rely upon it. Assigning to YYVAL
1521 unconditionally makes the parser a bit smaller, and it avoids a
1522 GCC warning that YYVAL may be used uninitialized. */
1523 yyval = yyvsp[1-yylen];
1526 YY_REDUCE_PRINT (yyn);
1530 #line 109 "command.y" /* yacc.c:1646 */
1533 want_nodeval = false;
1534 if (lexptr_begin != NULL) {
1535 if (input_from_tty && lexptr_begin[0] != '\0')
1536 add_history(lexptr_begin);
1537 efree(lexptr_begin);
1538 lexptr_begin = NULL;
1540 if (arg_list != NULL) {
1541 free_cmdarg(arg_list);
1545 #line 1546 "command.c" /* yacc.c:1646 */
1549 #line 128 "command.y" /* yacc.c:1646 */
1551 if (errcount == 0 && cmd_idx >= 0) {
1553 bool terminate = false;
1557 ctype = cmdtab[cmd_idx].type;
1559 /* a blank line repeats previous command
1560 * (list, next, nexti, step, stepi and continue without arguments).
1561 * save the index in the command table; used in yylex
1563 if ((ctype == D_list
1568 || ctype == D_continue)
1573 repeat_idx = cmd_idx;
1577 /* call the command handler; reset the globals arg_list, cmd_idx,
1578 * since this handler could invoke yyparse again.
1579 * call do_commands for the list of commands in `commands';
1580 * arg_list isn't freed on return.
1583 cmdfunc = cmdtab[cmd_idx].cf_ptr;
1585 cmdfunc = do_commands;
1587 want_nodeval = false;
1592 terminate = (*cmdfunc)(args, ctype);
1593 if (! in_commands || ctype == D_commands)
1599 #line 1600 "command.c" /* yacc.c:1646 */
1603 #line 178 "command.y" /* yacc.c:1646 */
1607 #line 1608 "command.c" /* yacc.c:1646 */
1611 #line 212 "command.y" /* yacc.c:1646 */
1612 { want_nodeval = true; }
1613 #line 1614 "command.c" /* yacc.c:1646 */
1617 #line 217 "command.y" /* yacc.c:1646 */
1619 if (errcount == 0) {
1620 /* don't free arg_list; passed on to statement_list
1621 * non-terminal (empty rule action). See below.
1623 if (input_from_tty) {
1624 dbg_prompt = eval_prompt;
1626 _("Type (g)awk statement(s). End with the command \"end\"\n"));
1627 rl_inhibit_completion = 1;
1633 #line 1634 "command.c" /* yacc.c:1646 */
1637 #line 236 "command.y" /* yacc.c:1646 */
1639 (yyval) = append_statement(arg_list, (char *) start_EVAL);
1640 if (read_a_line == read_commands_string) /* unserializing 'eval' in 'commands' */
1641 (yyval)->a_string[0] = '\0';
1642 free_cmdarg(arg_list);
1645 #line 1646 "command.c" /* yacc.c:1646 */
1649 #line 243 "command.y" /* yacc.c:1646 */
1650 { (yyval) = append_statement((yyvsp[-1]), lexptr_begin); }
1651 #line 1652 "command.c" /* yacc.c:1646 */
1655 #line 244 "command.y" /* yacc.c:1646 */
1657 (yyval) = (yyvsp[-1]);
1659 #line 1660 "command.c" /* yacc.c:1646 */
1663 #line 251 "command.y" /* yacc.c:1646 */
1665 arg_list = append_statement((yyvsp[-1]), (char *) end_EVAL);
1666 if (read_a_line == read_commands_string) { /* unserializing 'eval' in 'commands' */
1667 char *str = arg_list->a_string;
1668 size_t len = strlen(str);
1669 assert(len > 2 && str[len - 2] == '}');
1670 str[len - 2] = '\0';
1672 if (input_from_tty) {
1673 dbg_prompt = in_commands ? commands_prompt : dgawk_prompt;
1674 rl_inhibit_completion = 0;
1676 cmd_idx = find_command("eval", 4);
1679 #line 1680 "command.c" /* yacc.c:1646 */
1683 #line 267 "command.y" /* yacc.c:1646 */
1687 n = (yyvsp[0])->a_node;
1688 arg = append_statement(NULL, (char *) start_EVAL);
1689 (void) append_statement(arg, n->stptr);
1690 (void) append_statement(arg, (char *) end_EVAL);
1691 free_cmdarg(arg_list);
1694 #line 1695 "command.c" /* yacc.c:1646 */
1698 #line 286 "command.y" /* yacc.c:1646 */
1700 if (cmdtab[cmd_idx].class == D_FRAME
1701 && (yyvsp[0]) != NULL && (yyvsp[0])->a_int < 0)
1702 yyerror(_("invalid frame number: %d"), (yyvsp[0])->a_int);
1704 #line 1705 "command.c" /* yacc.c:1646 */
1708 #line 292 "command.y" /* yacc.c:1646 */
1710 int idx = find_argument((yyvsp[0]));
1712 yyerror(_("info: invalid option - \"%s\""), (yyvsp[0])->a_string);
1714 efree((yyvsp[0])->a_string);
1715 (yyvsp[0])->a_string = NULL;
1716 (yyvsp[0])->type = D_argument;
1717 (yyvsp[0])->a_argument = argtab[idx].value;
1720 #line 1721 "command.c" /* yacc.c:1646 */
1724 #line 305 "command.y" /* yacc.c:1646 */
1725 { want_nodeval = true; }
1726 #line 1727 "command.c" /* yacc.c:1646 */
1730 #line 306 "command.y" /* yacc.c:1646 */
1731 { want_nodeval = true; }
1732 #line 1733 "command.c" /* yacc.c:1646 */
1736 #line 311 "command.y" /* yacc.c:1646 */
1737 { want_nodeval = true; }
1738 #line 1739 "command.c" /* yacc.c:1646 */
1742 #line 313 "command.y" /* yacc.c:1646 */
1743 { want_nodeval = true; }
1744 #line 1745 "command.c" /* yacc.c:1646 */
1748 #line 314 "command.y" /* yacc.c:1646 */
1749 { want_nodeval = true; }
1750 #line 1751 "command.c" /* yacc.c:1646 */
1754 #line 315 "command.y" /* yacc.c:1646 */
1755 { want_nodeval = true; }
1756 #line 1757 "command.c" /* yacc.c:1646 */
1760 #line 319 "command.y" /* yacc.c:1646 */
1762 if (in_cmd_src((yyvsp[0])->a_string))
1763 yyerror(_("source \"%s\": already sourced."), (yyvsp[0])->a_string);
1765 #line 1766 "command.c" /* yacc.c:1646 */
1769 #line 324 "command.y" /* yacc.c:1646 */
1771 if (! input_from_tty)
1772 yyerror(_("save \"%s\": command not permitted."), (yyvsp[0])->a_string);
1774 #line 1775 "command.c" /* yacc.c:1646 */
1778 #line 329 "command.y" /* yacc.c:1646 */
1783 if ((yyvsp[0]) != NULL)
1784 num = (yyvsp[0])->a_int;
1788 else if (in_commands)
1789 yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands"));
1790 else if ((yyvsp[0]) == NULL && ! (type = has_break_or_watch_point(&num, true)))
1791 yyerror(_("no breakpoint/watchpoint has been set yet"));
1792 else if ((yyvsp[0]) != NULL && ! (type = has_break_or_watch_point(&num, false)))
1793 yyerror(_("invalid breakpoint/watchpoint number"));
1796 if (input_from_tty) {
1797 dbg_prompt = commands_prompt;
1798 fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"),
1799 (type == D_break) ? "breakpoint" : "watchpoint", num);
1800 fprintf(out_fp, _("End with the command \"end\"\n"));
1804 #line 1805 "command.c" /* yacc.c:1646 */
1808 #line 355 "command.y" /* yacc.c:1646 */
1811 yyerror(_("`end' valid only in command `commands' or `eval'"));
1814 dbg_prompt = dgawk_prompt;
1815 in_commands = false;
1818 #line 1819 "command.c" /* yacc.c:1646 */
1822 #line 365 "command.y" /* yacc.c:1646 */
1825 yyerror(_("`silent' valid only in command `commands'"));
1827 #line 1828 "command.c" /* yacc.c:1646 */
1831 #line 370 "command.y" /* yacc.c:1646 */
1833 int idx = find_argument((yyvsp[0]));
1835 yyerror(_("trace: invalid option - \"%s\""), (yyvsp[0])->a_string);
1837 efree((yyvsp[0])->a_string);
1838 (yyvsp[0])->a_string = NULL;
1839 (yyvsp[0])->type = D_argument;
1840 (yyvsp[0])->a_argument = argtab[idx].value;
1843 #line 1844 "command.c" /* yacc.c:1646 */
1847 #line 381 "command.y" /* yacc.c:1646 */
1848 { want_nodeval = true; }
1849 #line 1850 "command.c" /* yacc.c:1646 */
1853 #line 382 "command.y" /* yacc.c:1646 */
1856 int num = (yyvsp[-2])->a_int;
1857 type = has_break_or_watch_point(&num, false);
1859 yyerror(_("condition: invalid breakpoint/watchpoint number"));
1861 #line 1862 "command.c" /* yacc.c:1646 */
1865 #line 390 "command.y" /* yacc.c:1646 */
1868 /* Prepend command 'eval' to argument list */
1870 arg = mk_cmdarg(D_string);
1871 arg->a_string = estrdup("eval", 4);
1872 arg->next = arg_list;
1876 #line 1877 "command.c" /* yacc.c:1646 */
1880 #line 404 "command.y" /* yacc.c:1646 */
1882 if ((yyvsp[0]) != NULL) {
1883 NODE *n = (yyvsp[0])->a_node;
1884 (yyvsp[0])->type = D_string;
1885 (yyvsp[0])->a_string = n->stptr;
1888 (yyval) = (yyvsp[0]);
1890 #line 1891 "command.c" /* yacc.c:1646 */
1894 #line 418 "command.y" /* yacc.c:1646 */
1896 #line 1897 "command.c" /* yacc.c:1646 */
1900 #line 423 "command.y" /* yacc.c:1646 */
1902 #line 1903 "command.c" /* yacc.c:1646 */
1906 #line 432 "command.y" /* yacc.c:1646 */
1908 #line 1909 "command.c" /* yacc.c:1646 */
1912 #line 437 "command.y" /* yacc.c:1646 */
1914 #line 1915 "command.c" /* yacc.c:1646 */
1918 #line 440 "command.y" /* yacc.c:1646 */
1920 #line 1921 "command.c" /* yacc.c:1646 */
1924 #line 445 "command.y" /* yacc.c:1646 */
1927 n = (yyvsp[0])->a_node;
1928 if ((n->flags & STRING) == 0)
1929 yyerror(_("argument not a string"));
1931 #line 1932 "command.c" /* yacc.c:1646 */
1935 #line 455 "command.y" /* yacc.c:1646 */
1937 #line 1938 "command.c" /* yacc.c:1646 */
1941 #line 457 "command.y" /* yacc.c:1646 */
1943 if (find_option((yyvsp[0])->a_string) < 0)
1944 yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[0])->a_string);
1946 #line 1947 "command.c" /* yacc.c:1646 */
1950 #line 462 "command.y" /* yacc.c:1646 */
1952 if (find_option((yyvsp[-2])->a_string) < 0)
1953 yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[-2])->a_string);
1955 #line 1956 "command.c" /* yacc.c:1646 */
1959 #line 470 "command.y" /* yacc.c:1646 */
1962 n = lookup((yyvsp[0])->a_string);
1963 if (n == NULL || n->type != Node_func)
1964 yyerror(_("no such function - \"%s\""), (yyvsp[0])->a_string);
1966 (yyvsp[0])->type = D_func;
1967 efree((yyvsp[0])->a_string);
1968 (yyvsp[0])->a_string = NULL;
1969 (yyvsp[0])->a_node = n;
1972 #line 1973 "command.c" /* yacc.c:1646 */
1976 #line 486 "command.y" /* yacc.c:1646 */
1978 #line 1979 "command.c" /* yacc.c:1646 */
1982 #line 495 "command.y" /* yacc.c:1646 */
1984 #line 1985 "command.c" /* yacc.c:1646 */
1988 #line 496 "command.y" /* yacc.c:1646 */
1989 { want_nodeval = true; }
1990 #line 1991 "command.c" /* yacc.c:1646 */
1994 #line 498 "command.y" /* yacc.c:1646 */
1995 { want_nodeval = true; }
1996 #line 1997 "command.c" /* yacc.c:1646 */
2000 #line 504 "command.y" /* yacc.c:1646 */
2002 #line 2003 "command.c" /* yacc.c:1646 */
2006 #line 510 "command.y" /* yacc.c:1646 */
2008 #line 2009 "command.c" /* yacc.c:1646 */
2012 #line 516 "command.y" /* yacc.c:1646 */
2014 #line 2015 "command.c" /* yacc.c:1646 */
2018 #line 528 "command.y" /* yacc.c:1646 */
2020 int idx = find_argument((yyvsp[-1]));
2022 yyerror(_("enable: invalid option - \"%s\""), (yyvsp[-1])->a_string);
2024 efree((yyvsp[-1])->a_string);
2025 (yyvsp[-1])->a_string = NULL;
2026 (yyvsp[-1])->type = D_argument;
2027 (yyvsp[-1])->a_argument = argtab[idx].value;
2030 #line 2031 "command.c" /* yacc.c:1646 */
2034 #line 544 "command.y" /* yacc.c:1646 */
2036 (yyvsp[0])->type = D_array; /* dump all items */
2037 (yyvsp[0])->a_count = 0;
2039 #line 2040 "command.c" /* yacc.c:1646 */
2043 #line 549 "command.y" /* yacc.c:1646 */
2045 (yyvsp[-1])->type = D_array;
2046 (yyvsp[-1])->a_count = num_dim;
2048 #line 2049 "command.c" /* yacc.c:1646 */
2052 #line 575 "command.y" /* yacc.c:1646 */
2054 #line 2055 "command.c" /* yacc.c:1646 */
2058 #line 577 "command.y" /* yacc.c:1646 */
2060 #line 2061 "command.c" /* yacc.c:1646 */
2064 #line 579 "command.y" /* yacc.c:1646 */
2067 a = mk_cmdarg(D_int);
2071 #line 2072 "command.c" /* yacc.c:1646 */
2075 #line 595 "command.y" /* yacc.c:1646 */
2077 if ((yyvsp[-2])->a_int > (yyvsp[0])->a_int)
2078 yyerror(_("invalid range specification: %d - %d"),
2079 (yyvsp[-2])->a_int, (yyvsp[0])->a_int);
2081 (yyvsp[-2])->type = D_range;
2082 (yyval) = (yyvsp[-2]);
2084 #line 2085 "command.c" /* yacc.c:1646 */
2088 #line 607 "command.y" /* yacc.c:1646 */
2090 #line 2091 "command.c" /* yacc.c:1646 */
2094 #line 621 "command.y" /* yacc.c:1646 */
2095 { (yyval) = (yyvsp[0]); }
2096 #line 2097 "command.c" /* yacc.c:1646 */
2100 #line 623 "command.y" /* yacc.c:1646 */
2101 { (yyval) = (yyvsp[-2]); }
2102 #line 2103 "command.c" /* yacc.c:1646 */
2106 #line 629 "command.y" /* yacc.c:1646 */
2112 for (a = (yyvsp[-1]); a != NULL; a = a->next)
2114 subs = concat_args((yyvsp[-1]), count);
2115 free_cmdarg((yyvsp[-1])->next);
2116 (yyvsp[-1])->next = NULL;
2117 (yyvsp[-1])->type = D_node;
2118 (yyvsp[-1])->a_node = subs;
2119 (yyval) = (yyvsp[-1]);
2121 #line 2122 "command.c" /* yacc.c:1646 */
2125 #line 648 "command.y" /* yacc.c:1646 */
2126 { (yyval) = (yyvsp[0]); num_dim = 1; }
2127 #line 2128 "command.c" /* yacc.c:1646 */
2131 #line 650 "command.y" /* yacc.c:1646 */
2132 { (yyval) = (yyvsp[-1]); num_dim++; }
2133 #line 2134 "command.c" /* yacc.c:1646 */
2137 #line 656 "command.y" /* yacc.c:1646 */
2139 NODE *n = (yyvsp[0])->a_node;
2140 if ((n->flags & NUMBER) == 0)
2141 yyerror(_("non-numeric value for field number"));
2143 (yyvsp[0])->type = D_field;
2144 (yyval) = (yyvsp[0]);
2146 #line 2147 "command.c" /* yacc.c:1646 */
2150 #line 665 "command.y" /* yacc.c:1646 */
2152 /* a_string is array name, a_count is dimension count */
2153 (yyvsp[-1])->type = D_subscript;
2154 (yyvsp[-1])->a_count = num_dim;
2155 (yyval) = (yyvsp[-1]);
2157 #line 2158 "command.c" /* yacc.c:1646 */
2161 #line 675 "command.y" /* yacc.c:1646 */
2162 { (yyval) = (yyvsp[0]); }
2163 #line 2164 "command.c" /* yacc.c:1646 */
2167 #line 677 "command.y" /* yacc.c:1646 */
2169 NODE *n = (yyvsp[0])->a_node;
2170 if ((n->flags & NUMBER) == 0)
2171 yyerror(_("non-numeric value found, numeric expected"));
2172 (yyval) = (yyvsp[0]);
2174 #line 2175 "command.c" /* yacc.c:1646 */
2178 #line 684 "command.y" /* yacc.c:1646 */
2180 NODE *n = (yyvsp[0])->a_node;
2181 if ((n->flags & NUMBER) == 0)
2182 yyerror(_("non-numeric value found, numeric expected"));
2185 (yyval) = (yyvsp[0]);
2187 #line 2188 "command.c" /* yacc.c:1646 */
2191 #line 696 "command.y" /* yacc.c:1646 */
2193 #line 2194 "command.c" /* yacc.c:1646 */
2197 #line 698 "command.y" /* yacc.c:1646 */
2198 { (yyval) = (yyvsp[0]); }
2199 #line 2200 "command.c" /* yacc.c:1646 */
2203 #line 703 "command.y" /* yacc.c:1646 */
2205 #line 2206 "command.c" /* yacc.c:1646 */
2209 #line 705 "command.y" /* yacc.c:1646 */
2210 { (yyval) = (yyvsp[0]); }
2211 #line 2212 "command.c" /* yacc.c:1646 */
2215 #line 710 "command.y" /* yacc.c:1646 */
2217 if ((yyvsp[0])->a_int == 0)
2218 yyerror(_("non-zero integer value"));
2219 (yyval) = (yyvsp[0]);
2221 #line 2222 "command.c" /* yacc.c:1646 */
2225 #line 716 "command.y" /* yacc.c:1646 */
2227 if ((yyvsp[0])->a_int == 0)
2228 yyerror(_("non-zero integer value"));
2229 (yyval) = (yyvsp[0]);
2231 #line 2232 "command.c" /* yacc.c:1646 */
2235 #line 725 "command.y" /* yacc.c:1646 */
2236 { (yyval) = (yyvsp[0]); }
2237 #line 2238 "command.c" /* yacc.c:1646 */
2241 #line 727 "command.y" /* yacc.c:1646 */
2242 { (yyval) = (yyvsp[0]); }
2243 #line 2244 "command.c" /* yacc.c:1646 */
2247 #line 729 "command.y" /* yacc.c:1646 */
2249 (yyvsp[0])->a_int = - (yyvsp[0])->a_int;
2250 (yyval) = (yyvsp[0]);
2252 #line 2253 "command.c" /* yacc.c:1646 */
2256 #line 737 "command.y" /* yacc.c:1646 */
2258 if (lexptr_begin != NULL) {
2259 if (input_from_tty && lexptr_begin[0] != '\0')
2260 add_history(lexptr_begin);
2261 efree(lexptr_begin);
2262 lexptr_begin = NULL;
2265 #line 2266 "command.c" /* yacc.c:1646 */
2269 #line 2270 "command.c" /* yacc.c:1646 */
2272 /* User semantic actions sometimes alter yychar, and that requires
2273 that yytoken be updated with the new translation. We take the
2274 approach of translating immediately before every use of yytoken.
2275 One alternative is translating here after every semantic action,
2276 but that translation would be missed if the semantic action invokes
2277 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2278 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2279 incorrect destructor might then be invoked immediately. In the
2280 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2281 to an incorrect destructor call or verbose syntax error message
2282 before the lookahead is translated. */
2283 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2287 YY_STACK_PRINT (yyss, yyssp);
2291 /* Now 'shift' the result of the reduction. Determine what state
2292 that goes to, based on the state we popped back to and the rule
2293 number reduced by. */
2297 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2298 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2299 yystate = yytable[yystate];
2301 yystate = yydefgoto[yyn - YYNTOKENS];
2306 /*--------------------------------------.
2307 | yyerrlab -- here on detecting error. |
2308 `--------------------------------------*/
2310 /* Make sure we have latest lookahead translation. See comments at
2311 user semantic actions for why this is necessary. */
2312 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2314 /* If not already recovering from an error, report this error. */
2318 #if ! YYERROR_VERBOSE
2319 yyerror (YY_("syntax error"));
2321 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2324 char const *yymsgp = YY_("syntax error");
2325 int yysyntax_error_status;
2326 yysyntax_error_status = YYSYNTAX_ERROR;
2327 if (yysyntax_error_status == 0)
2329 else if (yysyntax_error_status == 1)
2331 if (yymsg != yymsgbuf)
2332 YYSTACK_FREE (yymsg);
2333 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2337 yymsg_alloc = sizeof yymsgbuf;
2338 yysyntax_error_status = 2;
2342 yysyntax_error_status = YYSYNTAX_ERROR;
2347 if (yysyntax_error_status == 2)
2348 goto yyexhaustedlab;
2350 # undef YYSYNTAX_ERROR
2356 if (yyerrstatus == 3)
2358 /* If just tried and failed to reuse lookahead token after an
2359 error, discard it. */
2361 if (yychar <= YYEOF)
2363 /* Return failure if at end of input. */
2364 if (yychar == YYEOF)
2369 yydestruct ("Error: discarding",
2375 /* Else will try to reuse lookahead token after shifting the error
2380 /*---------------------------------------------------.
2381 | yyerrorlab -- error raised explicitly by YYERROR. |
2382 `---------------------------------------------------*/
2385 /* Pacify compilers like GCC when the user code never invokes
2386 YYERROR and the label yyerrorlab therefore never appears in user
2388 if (/*CONSTCOND*/ 0)
2391 /* Do not reclaim the symbols of the rule whose action triggered
2395 YY_STACK_PRINT (yyss, yyssp);
2400 /*-------------------------------------------------------------.
2401 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2402 `-------------------------------------------------------------*/
2404 yyerrstatus = 3; /* Each real token shifted decrements this. */
2408 yyn = yypact[yystate];
2409 if (!yypact_value_is_default (yyn))
2412 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2420 /* Pop the current state because it cannot handle the error token. */
2425 yydestruct ("Error: popping",
2426 yystos[yystate], yyvsp);
2429 YY_STACK_PRINT (yyss, yyssp);
2432 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2434 YY_IGNORE_MAYBE_UNINITIALIZED_END
2437 /* Shift the error token. */
2438 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2444 /*-------------------------------------.
2445 | yyacceptlab -- YYACCEPT comes here. |
2446 `-------------------------------------*/
2451 /*-----------------------------------.
2452 | yyabortlab -- YYABORT comes here. |
2453 `-----------------------------------*/
2458 #if !defined yyoverflow || YYERROR_VERBOSE
2459 /*-------------------------------------------------.
2460 | yyexhaustedlab -- memory exhaustion comes here. |
2461 `-------------------------------------------------*/
2463 yyerror (YY_("memory exhausted"));
2469 if (yychar != YYEMPTY)
2471 /* Make sure we have latest lookahead translation. See comments at
2472 user semantic actions for why this is necessary. */
2473 yytoken = YYTRANSLATE (yychar);
2474 yydestruct ("Cleanup: discarding lookahead",
2477 /* Do not reclaim the symbols of the rule whose action triggered
2478 this YYABORT or YYACCEPT. */
2480 YY_STACK_PRINT (yyss, yyssp);
2481 while (yyssp != yyss)
2483 yydestruct ("Cleanup: popping",
2484 yystos[*yyssp], yyvsp);
2489 YYSTACK_FREE (yyss);
2492 if (yymsg != yymsgbuf)
2493 YYSTACK_FREE (yymsg);
2497 #line 747 "command.y" /* yacc.c:1906 */
2501 /* append_statement --- append 'stmt' to the list of eval awk statements */
2504 append_statement(CMDARG *stmt_list, char *stmt)
2508 int len, slen, ssize;
2510 #define EVALSIZE 512
2512 if (stmt == start_EVAL) {
2513 len = sizeof(start_EVAL);
2514 for (a = stmt_list; a != NULL; a = a->next)
2515 len += strlen(a->a_string) + 1; /* 1 for ',' */
2518 emalloc(s, char *, (len + 2) * sizeof(char), "append_statement");
2519 arg = mk_cmdarg(D_string);
2521 arg->a_count = len; /* kludge */
2523 slen = sizeof("function @eval(") - 1;
2524 memcpy(s, start_EVAL, slen);
2526 for (a = stmt_list; a != NULL; a = a->next) {
2527 len = strlen(a->a_string);
2528 memcpy(s + slen, a->a_string, len);
2530 if (a->next != NULL)
2539 len = strlen(stmt) + 1; /* 1 for newline */
2540 s = stmt_list->a_string;
2542 ssize = stmt_list->a_count;
2543 if (len > ssize - slen) {
2544 ssize = slen + len + EVALSIZE;
2545 erealloc(s, char *, (ssize + 2) * sizeof(char), "append_statement");
2546 stmt_list->a_string = s;
2547 stmt_list->a_count = ssize;
2549 memcpy(s + slen, stmt, len);
2551 if (slen >= 2 && s[slen - 2] != '\n') {
2556 if (stmt == end_EVAL)
2557 erealloc(stmt_list->a_string, char *, slen + 2, "append_statement");
2564 /* command names sorted in ascending order */
2566 struct cmdtoken cmdtab[] = {
2567 { "backtrace", "bt", D_backtrace, D_BACKTRACE, do_backtrace,
2568 gettext_noop("backtrace [N] - print trace of all or N innermost (outermost if N < 0) frames.") },
2569 { "break", "b", D_break, D_BREAK, do_breakpoint,
2570 gettext_noop("break [[filename:]N|function] - set breakpoint at the specified location.") },
2571 { "clear", "", D_clear, D_CLEAR, do_clear,
2572 gettext_noop("clear [[filename:]N|function] - delete breakpoints previously set.") },
2573 { "commands", "", D_commands, D_COMMANDS, do_commands,
2574 gettext_noop("commands [num] - starts a list of commands to be executed at a breakpoint(watchpoint) hit.") },
2575 { "condition", "", D_condition, D_CONDITION, do_condition,
2576 gettext_noop("condition num [expr] - set or clear breakpoint or watchpoint condition.") },
2577 { "continue", "c", D_continue, D_CONTINUE, do_continue,
2578 gettext_noop("continue [COUNT] - continue program being debugged.") },
2579 { "delete", "d", D_delete, D_DELETE, do_delete_breakpoint,
2580 gettext_noop("delete [breakpoints] [range] - delete specified breakpoints.") },
2581 { "disable", "", D_disable, D_DISABLE, do_disable_breakpoint,
2582 gettext_noop("disable [breakpoints] [range] - disable specified breakpoints.") },
2583 { "display", "", D_display, D_DISPLAY, do_display,
2584 gettext_noop("display [var] - print value of variable each time the program stops.") },
2585 { "down", "", D_down, D_DOWN, do_down,
2586 gettext_noop("down [N] - move N frames down the stack.") },
2587 { "dump", "", D_dump, D_DUMP, do_dump_instructions,
2588 gettext_noop("dump [filename] - dump instructions to file or stdout.") },
2589 { "enable", "e", D_enable, D_ENABLE, do_enable_breakpoint,
2590 gettext_noop("enable [once|del] [breakpoints] [range] - enable specified breakpoints.") },
2591 { "end", "", D_end, D_END, do_commands,
2592 gettext_noop("end - end a list of commands or awk statements.") },
2593 { "eval", "", D_eval, D_EVAL, do_eval,
2594 gettext_noop("eval stmt|[p1, p2, ...] - evaluate awk statement(s).") },
2595 { "finish", "", D_finish, D_FINISH, do_finish,
2596 gettext_noop("finish - execute until selected stack frame returns.") },
2597 { "frame", "f", D_frame, D_FRAME, do_frame,
2598 gettext_noop("frame [N] - select and print stack frame number N.") },
2599 { "help", "h", D_help, D_HELP, do_help,
2600 gettext_noop("help [command] - print list of commands or explanation of command.") },
2601 { "ignore", "", D_ignore, D_IGNORE, do_ignore_breakpoint,
2602 gettext_noop("ignore N COUNT - set ignore-count of breakpoint number N to COUNT.") },
2603 { "info", "i", D_info, D_INFO, do_info,
2604 gettext_noop("info topic - source|sources|variables|functions|break|frame|args|locals|display|watch.") },
2605 { "list", "l", D_list, D_LIST, do_list,
2606 gettext_noop("list [-|+|[filename:]lineno|function|range] - list specified line(s).") },
2607 { "next", "n", D_next, D_NEXT, do_next,
2608 gettext_noop("next [COUNT] - step program, proceeding through subroutine calls.") },
2609 { "nexti", "ni", D_nexti, D_NEXTI, do_nexti,
2610 gettext_noop("nexti [COUNT] - step one instruction, but proceed through subroutine calls.") },
2611 { "option", "o", D_option, D_OPTION, do_option,
2612 gettext_noop("option [name[=value]] - set or display debugger option(s).") },
2613 { "print", "p", D_print, D_PRINT, do_print_var,
2614 gettext_noop("print var [var] - print value of a variable or array.") },
2615 { "printf", "", D_printf, D_PRINTF, do_print_f,
2616 gettext_noop("printf format, [arg], ... - formatted output.") },
2617 { "quit", "q", D_quit, D_QUIT, do_quit,
2618 gettext_noop("quit - exit debugger.") },
2619 { "return", "", D_return, D_RETURN, do_return,
2620 gettext_noop("return [value] - make selected stack frame return to its caller.") },
2621 { "run", "r", D_run, D_RUN, do_run,
2622 gettext_noop("run - start or restart executing program.") },
2623 #ifdef HAVE_LIBREADLINE
2624 { "save", "", D_save, D_SAVE, do_save,
2625 gettext_noop("save filename - save commands from the session to file.") },
2627 { "set", "", D_set, D_SET, do_set_var,
2628 gettext_noop("set var = value - assign value to a scalar variable.") },
2629 { "silent", "", D_silent, D_SILENT, do_commands,
2630 gettext_noop("silent - suspends usual message when stopped at a breakpoint/watchpoint.") },
2631 { "source", "", D_source, D_SOURCE, do_source,
2632 gettext_noop("source file - execute commands from file.") },
2633 { "step", "s", D_step, D_STEP, do_step,
2634 gettext_noop("step [COUNT] - step program until it reaches a different source line.") },
2635 { "stepi", "si", D_stepi, D_STEPI, do_stepi,
2636 gettext_noop("stepi [COUNT] - step one instruction exactly.") },
2637 { "tbreak", "t", D_tbreak, D_TBREAK, do_tmp_breakpoint,
2638 gettext_noop("tbreak [[filename:]N|function] - set a temporary breakpoint.") },
2639 { "trace", "", D_trace, D_TRACE, do_trace_instruction,
2640 gettext_noop("trace on|off - print instruction before executing.") },
2641 { "undisplay", "", D_undisplay, D_UNDISPLAY, do_undisplay,
2642 gettext_noop("undisplay [N] - remove variable(s) from automatic display list.") },
2643 { "until", "u", D_until, D_UNTIL, do_until,
2644 gettext_noop("until [[filename:]N|function] - execute until program reaches a different line or line N within current frame.") },
2645 { "unwatch", "", D_unwatch, D_UNWATCH, do_unwatch,
2646 gettext_noop("unwatch [N] - remove variable(s) from watch list.") },
2647 { "up", "", D_up, D_UP, do_up,
2648 gettext_noop("up [N] - move N frames up the stack.") },
2649 { "watch", "w", D_watch, D_WATCH, do_watch,
2650 gettext_noop("watch var - set a watchpoint for a variable.") },
2651 { NULL, NULL, D_illegal, 0, (Func_cmd) 0,
2655 struct argtoken argtab[] = {
2656 { "args", D_info, A_ARGS },
2657 { "break", D_info, A_BREAK },
2658 { "del", D_enable, A_DEL },
2659 { "display", D_info, A_DISPLAY },
2660 { "frame", D_info, A_FRAME },
2661 { "functions", D_info, A_FUNCTIONS },
2662 { "locals", D_info, A_LOCALS },
2663 { "off", D_trace, A_TRACE_OFF },
2664 { "on", D_trace, A_TRACE_ON },
2665 { "once", D_enable, A_ONCE },
2666 { "source", D_info, A_SOURCE },
2667 { "sources", D_info, A_SOURCES },
2668 { "variables", D_info, A_VARIABLES },
2669 { "watch", D_info, A_WATCH },
2670 { NULL, D_illegal, A_NONE },
2674 /* get_command --- return command handler function */
2677 get_command(int ctype)
2680 for (i = 0; cmdtab[i].name != NULL; i++) {
2681 if (cmdtab[i].type == ctype)
2682 return cmdtab[i].cf_ptr;
2684 return (Func_cmd) 0;
2687 /* get_command_name --- return command name given it's type */
2690 get_command_name(int ctype)
2693 for (i = 0; cmdtab[i].name != NULL; i++) {
2694 if (cmdtab[i].type == ctype)
2695 return cmdtab[i].name;
2700 /* mk_cmdarg --- make an argument for command */
2703 mk_cmdarg(enum argtype type)
2706 emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg");
2707 memset(arg, 0, sizeof(CMDARG));
2712 /* append_cmdarg --- append ARG to the list of arguments for the current command */
2715 append_cmdarg(CMDARG *arg)
2717 static CMDARG *savetail;
2719 if (arg_list == NULL)
2722 savetail->next = arg;
2726 /* free_cmdarg --- free all arguments in LIST */
2729 free_cmdarg(CMDARG *list)
2731 CMDARG *arg, *nexta;
2733 for (arg = list; arg != NULL; arg = nexta) {
2736 switch (arg->type) {
2741 if (arg->a_string != NULL)
2742 efree(arg->a_string);
2755 /* yyerror --- print a syntax error message */
2758 yyerror(const char *mesg, ...)
2761 va_start(args, mesg);
2762 fprintf(out_fp, _("error: "));
2763 vfprintf(out_fp, mesg, args);
2764 fprintf(out_fp, "\n");
2771 /* yylex --- read a command and turn it into tokens */
2776 static char *lexptr = NULL;
2777 static char *lexend;
2782 yylval = (CMDARG *) NULL;
2784 if (errcount > 0 && lexptr_begin == NULL) {
2785 /* fake a new line */
2790 if (lexptr_begin == NULL) {
2792 lexptr_begin = read_a_line(dbg_prompt);
2793 if (lexptr_begin == NULL) { /* EOF or error */
2794 if (get_eof_status() == EXIT_FATAL)
2796 if (get_eof_status() == EXIT_FAILURE) {
2797 static int seen_eof = 0;
2799 /* force a quit, and let do_quit (in debug.c) exit */
2802 fprintf(stderr, _("can't read command (%s)\n"), strerror(errno));
2803 exit_val = EXIT_FAILURE;
2805 exit_val = EXIT_SUCCESS; */
2808 return '\n'; /* end current command if any */
2809 } else if (seen_eof++ == 1) {
2810 cmd_idx = find_command("quit", 4);
2811 return D_QUIT; /* 'quit' token */
2813 return '\n'; /* end command 'quit' */
2816 d_error(_("can't read command (%s)"), strerror(errno));
2817 if (pop_cmd_src() == 0)
2819 exit(EXIT_FATAL); /* shouldn't happen */
2822 if (! in_commands && ! in_eval /* history expansion off in 'commands' and 'eval' */
2825 history_expand_line(&lexptr_begin);
2827 lexptr = lexptr_begin;
2828 lexend = lexptr + strlen(lexptr);
2829 if (*lexptr == '\0' /* blank line */
2834 #ifdef HAVE_LIBREADLINE
2836 h = previous_history();
2838 add_history(h->line);
2840 cmd_idx = repeat_idx;
2841 return cmdtab[cmd_idx].class; /* repeat last command */
2848 while (c == ' ' || c == '\t')
2851 if (! input_from_tty && c == '#')
2855 if (lexptr >= lexend)
2858 if (cmd_idx < 0) { /* need a command */
2859 if (c == '?' && tokstart[1] == '\0' && ! in_eval) {
2861 cmd_idx = find_command("help", 4);
2865 while (c != '\0' && c != ' ' && c != '\t') {
2866 if (! isalpha(c) && ! in_eval) {
2867 yyerror(_("invalid character in command"));
2873 toklen = lexptr - tokstart;
2877 && tokstart[3] == '\0'
2878 && tokstart[0] == 'e'
2879 && tokstart[1] == 'n'
2880 && tokstart[2] == 'd'
2882 cmd_idx = find_command(tokstart, toklen);
2889 cmd_idx = find_command(tokstart, toklen);
2891 if (in_commands && cmdtab[cmd_idx].type != D_eval) {
2892 /* add the actual command string (lexptr_begin) to
2893 * arg_list; command string for 'eval' prepended to the arg_list
2894 * in the grammer above (see eval_cmd non-terminal).
2897 arg = mk_cmdarg(D_string);
2898 arg->a_string = estrdup(lexptr_begin, lexend - lexptr_begin);
2901 return cmdtab[cmd_idx].class;
2903 yyerror(_("unknown command - \"%.*s\", try help"), toklen, tokstart);
2910 if (cmdtab[cmd_idx].type == D_option) {
2913 } else if (c == '-' || c == '+' || c == ':' || c == '|')
2918 int flags = ALREADY_MALLOCED;
2919 bool esc_seen = false;
2921 toklen = lexend - lexptr;
2922 emalloc(str, char *, toklen + 2, "yylex");
2925 while ((c = *++lexptr) != '"') {
2926 if (lexptr == lexend) {
2929 yyerror(_("unterminated string"));
2935 if (want_nodeval || c != '"')
2938 if (lexptr == lexend)
2945 if (! want_nodeval) {
2946 yylval = mk_cmdarg(D_string);
2947 yylval->a_string = str;
2948 append_cmdarg(yylval);
2950 } else { /* awk string */
2953 yylval = mk_cmdarg(D_node);
2954 yylval->a_node = make_str_node(str, p - str, flags);
2955 append_cmdarg(yylval);
2960 if (! want_nodeval) {
2961 while ((c = *++lexptr) != '\0' && c != ':' && c != '-'
2962 && c != ' ' && c != '\t' && c != '=')
2965 /* Is it an integer? */
2966 if (isdigit((unsigned char) tokstart[0]) && cmdtab[cmd_idx].type != D_option) {
2971 l = strtol(tokstart, &end, 0);
2973 yyerror(_("%s"), strerror(errno));
2978 if (lexptr == end) {
2979 yylval = mk_cmdarg(D_int);
2981 append_cmdarg(yylval);
2986 /* Must be string */
2987 yylval = mk_cmdarg(D_string);
2988 yylval->a_string = estrdup(tokstart, lexptr - tokstart);
2989 append_cmdarg(yylval);
2993 /* look for awk number */
2995 if (isdigit((unsigned char) tokstart[0])) {
3003 tval = mpfr_strtofr(r->mpg_numbr, tokstart, & lexptr, 0, ROUND_MODE);
3004 IEEE_FMT(r->mpg_numbr, tval);
3005 if (mpfr_integer_p(r->mpg_numbr)) {
3006 /* integral value, convert to a GMP type. */
3009 mpfr_get_z(r->mpg_i, tmp->mpg_numbr, MPFR_RNDZ);
3014 r = make_number(strtod(tokstart, & lexptr));
3017 yyerror(strerror(errno));
3022 yylval = mk_cmdarg(D_node);
3024 append_cmdarg(yylval);
3029 if (c == '$' || c == '@'
3030 || c == '[' || c == ']'
3031 || c == ',' || c == '=')
3034 if (c != '_' && ! isalpha(c)) {
3035 yyerror(_("invalid character"));
3039 while (isalnum(c) || c == '_')
3041 toklen = lexptr - tokstart;
3044 yylval = mk_cmdarg(D_variable);
3045 yylval->a_string = estrdup(tokstart, toklen);
3046 append_cmdarg(yylval);
3050 /* find_argument --- find index in 'argtab' for a command option */
3053 find_argument(CMDARG *arg)
3055 /* non-number argument */
3059 assert(cmd_idx >= 0);
3060 name = arg->a_string;
3062 for (idx = 0; (p = (char *) argtab[idx].name) != NULL; idx++) {
3063 if (cmdtab[cmd_idx].type == argtab[idx].cmd
3066 && strncmp(p, name, len) == 0
3070 return -1; /* invalid option */
3073 /* concat_args --- concatenate argument strings into a single string NODE */
3076 concat_args(CMDARG *arg, int count)
3080 char *str, *subsep, *p;
3081 long len, subseplen;
3085 n = force_string(arg->a_node);
3089 emalloc(tmp, NODE **, count * sizeof(NODE *), "concat_args");
3090 subseplen = SUBSEP_node->var_value->stlen;
3091 subsep = SUBSEP_node->var_value->stptr;
3094 for (i = 0; i < count; i++) {
3095 n = force_string(arg->a_node);
3096 len += n->stlen + subseplen;
3101 emalloc(str, char *, len + 2, "concat_args");
3103 memcpy(str, n->stptr, n->stlen);
3105 for (i = 1; i < count; i++) {
3108 else if (subseplen > 0) {
3109 memcpy(p, subsep, subseplen);
3114 memcpy(p, n->stptr, n->stlen);
3119 return make_str_node(str, len, ALREADY_MALLOCED);
3122 /* find_command --- find the index in 'cmdtab' using exact,
3123 * abbreviation or unique partial match
3127 find_command(const char *token, size_t toklen)
3131 bool try_exact = true;
3132 int abrv_match = -1;
3133 int partial_match = -1;
3135 #if 'a' == 0x81 /* it's EBCDIC */
3136 /* make sure all lower case characters in token (sorting
3137 * isn't the solution in this case)
3139 for (i = 0; i < toklen; i++) {
3140 if (token[i] != tolower(token[i]))
3145 k = sizeof(cmdtab)/sizeof(cmdtab[0]) - 1;
3146 for (i = 0; i < k; i++) {
3147 name = (char *) cmdtab[i].name;
3148 if (try_exact && *token == *name
3149 && toklen == strlen(name)
3150 && strncmp(name, token, toklen) == 0
3154 if (*name > *token || i == (k - 1))
3157 if (abrv_match < 0) {
3158 abrv = cmdtab[i].abbrvn;
3159 if (abrv[0] == token[0]) {
3160 if (toklen == 1 && ! abrv[1])
3162 else if (toklen == 2 && abrv[1] == token[1])
3166 if (! try_exact && abrv_match >= 0)
3168 if (partial_match < 0) {
3170 && toklen < strlen(name)
3171 && strncmp(name, token, toklen) == 0
3173 if ((i == k - 1 || strncmp(cmdtab[i + 1].name, token, toklen) != 0)
3174 && (i == 0 || strncmp(cmdtab[i - 1].name, token, toklen) != 0)
3180 return partial_match;
3183 /* do_help -- help command */
3186 do_help(CMDARG *arg, int cmd)
3190 initialize_pager(out_fp);
3191 if (setjmp(pager_quit_tag) == 0) {
3192 for (i = 0; cmdtab[i].name != NULL; i++) {
3193 gprintf(out_fp, "%s:\n", cmdtab[i].name);
3194 gprintf(out_fp, "\t%s\n", _(cmdtab[i].help_txt));
3197 } else if (arg->type == D_string) {
3199 name = arg->a_string;
3200 i = find_command(name, strlen(name));
3202 fprintf(out_fp, "%s\n", cmdtab[i].help_txt);
3203 if (strcmp(cmdtab[i].name, "option") == 0)
3206 fprintf(out_fp, _("undefined command: %s\n"), name);
3213 #ifdef HAVE_LIBREADLINE
3215 /* next_word --- find the next word in a line to complete
3216 * (word seperation characters are space and tab).
3220 next_word(char *p, int len, char **endp)
3225 if (p == NULL || len <= 0)
3227 for (i = 0; i < len; i++, p++)
3228 if (*p != ' ' && *p != '\t')
3233 for (i++, q = p + 1; i < len; i++, q++)
3234 if (*q == ' ' || *q == '\t')
3241 /* command_completion --- attempt to complete based on the word number in line;
3242 * try to complete on command names if this is the first word; for the next
3243 * word(s), the type of completion depends on the command name (first word).
3246 #ifndef RL_READLINE_VERSION /* < 4.2a */
3247 #define rl_completion_matches(x, y) completion_matches((char *) (x), (y))
3252 command_completion(const char *text, int start, int end)
3258 rl_attempted_completion_over = true; /* no default filename completion please */
3260 this_cmd = D_illegal;
3262 if ((cmdtok = next_word(rl_line_buffer, len, &e)) == NULL) /* no first word yet */
3263 return rl_completion_matches(text, command_generator);
3264 len -= (e - rl_line_buffer);
3266 idx = find_command(cmdtok, e - cmdtok);
3269 this_cmd = cmdtab[idx].type;
3271 if (! next_word(e, len, NULL)) {
3278 return rl_completion_matches(text, srcfile_generator);
3283 return rl_completion_matches(text, argument_generator);
3285 return rl_completion_matches(text, option_generator);
3291 return rl_completion_matches(text, variable_generator);
3297 if (this_cmd == D_print || this_cmd == D_printf)
3298 return rl_completion_matches(text, variable_generator);
3302 /* command_generator --- generator function for command completion */
3305 command_generator(const char *text, int state)
3307 static size_t textlen;
3311 if (! state) { /* first time */
3312 textlen = strlen(text);
3315 while ((name = (char *) cmdtab[idx].name) != NULL) {
3317 if (strncmp(name, text, textlen) == 0)
3318 return estrdup(name, strlen(name));
3323 /* srcfile_generator --- generator function for source file completion */
3326 srcfile_generator(const char *text, int state)
3328 static size_t textlen;
3331 extern SRCFILE *srcfiles;
3333 if (! state) { /* first time */
3334 textlen = strlen(text);
3337 while (s != srcfiles) {
3338 if (s->stype != SRC_FILE && s->stype != SRC_INC) {
3344 if (strncmp(name, text, textlen) == 0)
3345 return estrdup(name, strlen(name));
3350 /* argument_generator --- generator function for non-number argument completion */
3353 argument_generator(const char *text, int state)
3355 static size_t textlen;
3359 if (! state) { /* first time */
3360 textlen = strlen(text);
3364 if (this_cmd == D_help) {
3365 while ((name = cmdtab[idx++].name) != NULL) {
3366 if (strncmp(name, text, textlen) == 0)
3367 return estrdup(name, strlen(name));
3370 while ((name = argtab[idx].name) != NULL) {
3371 if (this_cmd != argtab[idx++].cmd)
3373 if (strncmp(name, text, textlen) == 0)
3374 return estrdup(name, strlen(name));
3380 /* variable_generator --- generator function for variable name completion */
3383 variable_generator(const char *text, int state)
3385 static size_t textlen;
3387 static NODE *func = NULL;
3388 static NODE **vars = NULL;
3392 if (! state) { /* first time */
3393 textlen = strlen(text);
3396 vars = variable_list();
3398 func = get_function(); /* function in current context */
3401 /* function params */
3402 while (func != NULL) {
3403 if (idx >= func->param_cnt) {
3404 func = NULL; /* don't try to match params again */
3408 name = func->fparms[idx++].param;
3409 if (strncmp(name, text, textlen) == 0)
3410 return estrdup(name, strlen(name));
3414 while ((r = vars[idx++]) != NULL) {
3416 if (strncmp(name, text, textlen) == 0)
3417 return estrdup(name, strlen(name));
3423 /* history_expand_line --- history expand the LINE */
3426 history_expand_line(char **line)
3431 if (! *line || input_fd != 0 || ! input_from_tty)
3434 ret = history_expand(*line, &expansion);
3435 if (ret < 0 || ret == 2)