Introduced -devel and -extras subpackages for gawk
[platform/upstream/gawk.git] / command.c
1 /* A Bison parser, made by GNU Bison 2.5.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4    
5       Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6    
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.
11    
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.
16    
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/>.  */
19
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.
29    
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35
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.  */
42
43 /* Identify Bison output.  */
44 #define YYBISON 1
45
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.5"
48
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers.  */
53 #define YYPURE 0
54
55 /* Push parsers.  */
56 #define YYPUSH 0
57
58 /* Pull parsers.  */
59 #define YYPULL 1
60
61 /* Using locations.  */
62 #define YYLSP_NEEDED 0
63
64 /* Substitute the variable and function names.  */
65 #define yyparse         zzparse
66 #define yylex           zzlex
67 #define yyerror         zzerror
68 #define yylval          zzlval
69 #define yychar          zzchar
70 #define yydebug         zzdebug
71 #define yynerrs         zznerrs
72
73
74 /* Copy the first part of user declarations.  */
75
76 /* Line 268 of yacc.c  */
77 #line 26 "command.y"
78
79 #include "awk.h"
80 #include "cmd.h"
81
82 #if 0
83 #define YYDEBUG 12
84 int yydebug = 2;
85 #endif
86
87 static int yylex(void);
88 static void yyerror(const char *mesg, ...);
89
90 static int find_command(const char *token, size_t toklen);
91
92 static int want_nodeval = FALSE;
93
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;
100 static int num_dim;
101
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);
108
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;
117 #else
118 #define history_expand_line(p)  /* nothing */
119 static int rl_inhibit_completion;       /* dummy variable */
120 #endif
121
122 struct argtoken {
123         const char *name;
124         enum argtype cmd;
125         enum nametypeval value;
126 };
127
128 /*
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.
132  */
133 #define argtab zz_debug_argtab
134 #define cmdtab zz_debug_cmdtab
135
136 extern struct argtoken argtab[];
137 extern struct cmdtoken cmdtab[];
138
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 *
143
144
145 /* Line 268 of yacc.c  */
146 #line 147 "command.c"
147
148 /* Enabling traces.  */
149 #ifndef YYDEBUG
150 # define YYDEBUG 0
151 #endif
152
153 /* Enabling verbose error messages.  */
154 #ifdef YYERROR_VERBOSE
155 # undef YYERROR_VERBOSE
156 # define YYERROR_VERBOSE 1
157 #else
158 # define YYERROR_VERBOSE 0
159 #endif
160
161 /* Enabling the token table.  */
162 #ifndef YYTOKEN_TABLE
163 # define YYTOKEN_TABLE 0
164 #endif
165
166
167 /* Tokens.  */
168 #ifndef YYTOKENTYPE
169 # define YYTOKENTYPE
170    /* Put the tokens into the symbol table, so that GDB and other debuggers
171       know about them.  */
172    enum yytokentype {
173      D_BACKTRACE = 258,
174      D_BREAK = 259,
175      D_CLEAR = 260,
176      D_CONTINUE = 261,
177      D_DELETE = 262,
178      D_DISABLE = 263,
179      D_DOWN = 264,
180      D_ENABLE = 265,
181      D_FINISH = 266,
182      D_FRAME = 267,
183      D_HELP = 268,
184      D_IGNORE = 269,
185      D_INFO = 270,
186      D_LIST = 271,
187      D_NEXT = 272,
188      D_NEXTI = 273,
189      D_PRINT = 274,
190      D_PRINTF = 275,
191      D_QUIT = 276,
192      D_RETURN = 277,
193      D_RUN = 278,
194      D_SET = 279,
195      D_STEP = 280,
196      D_STEPI = 281,
197      D_TBREAK = 282,
198      D_UP = 283,
199      D_UNTIL = 284,
200      D_DISPLAY = 285,
201      D_UNDISPLAY = 286,
202      D_WATCH = 287,
203      D_UNWATCH = 288,
204      D_DUMP = 289,
205      D_TRACE = 290,
206      D_INT = 291,
207      D_STRING = 292,
208      D_NODE = 293,
209      D_VARIABLE = 294,
210      D_OPTION = 295,
211      D_COMMANDS = 296,
212      D_END = 297,
213      D_SILENT = 298,
214      D_SOURCE = 299,
215      D_SAVE = 300,
216      D_EVAL = 301,
217      D_CONDITION = 302,
218      D_STATEMENT = 303
219    };
220 #endif
221 /* Tokens.  */
222 #define D_BACKTRACE 258
223 #define D_BREAK 259
224 #define D_CLEAR 260
225 #define D_CONTINUE 261
226 #define D_DELETE 262
227 #define D_DISABLE 263
228 #define D_DOWN 264
229 #define D_ENABLE 265
230 #define D_FINISH 266
231 #define D_FRAME 267
232 #define D_HELP 268
233 #define D_IGNORE 269
234 #define D_INFO 270
235 #define D_LIST 271
236 #define D_NEXT 272
237 #define D_NEXTI 273
238 #define D_PRINT 274
239 #define D_PRINTF 275
240 #define D_QUIT 276
241 #define D_RETURN 277
242 #define D_RUN 278
243 #define D_SET 279
244 #define D_STEP 280
245 #define D_STEPI 281
246 #define D_TBREAK 282
247 #define D_UP 283
248 #define D_UNTIL 284
249 #define D_DISPLAY 285
250 #define D_UNDISPLAY 286
251 #define D_WATCH 287
252 #define D_UNWATCH 288
253 #define D_DUMP 289
254 #define D_TRACE 290
255 #define D_INT 291
256 #define D_STRING 292
257 #define D_NODE 293
258 #define D_VARIABLE 294
259 #define D_OPTION 295
260 #define D_COMMANDS 296
261 #define D_END 297
262 #define D_SILENT 298
263 #define D_SOURCE 299
264 #define D_SAVE 300
265 #define D_EVAL 301
266 #define D_CONDITION 302
267 #define D_STATEMENT 303
268
269
270
271
272 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
273 typedef int YYSTYPE;
274 # define YYSTYPE_IS_TRIVIAL 1
275 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
276 # define YYSTYPE_IS_DECLARED 1
277 #endif
278
279
280 /* Copy the second part of user declarations.  */
281
282
283 /* Line 343 of yacc.c  */
284 #line 285 "command.c"
285
286 #ifdef short
287 # undef short
288 #endif
289
290 #ifdef YYTYPE_UINT8
291 typedef YYTYPE_UINT8 yytype_uint8;
292 #else
293 typedef unsigned char yytype_uint8;
294 #endif
295
296 #ifdef YYTYPE_INT8
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;
301 #else
302 typedef short int yytype_int8;
303 #endif
304
305 #ifdef YYTYPE_UINT16
306 typedef YYTYPE_UINT16 yytype_uint16;
307 #else
308 typedef unsigned short int yytype_uint16;
309 #endif
310
311 #ifdef YYTYPE_INT16
312 typedef YYTYPE_INT16 yytype_int16;
313 #else
314 typedef short int yytype_int16;
315 #endif
316
317 #ifndef YYSIZE_T
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
326 # else
327 #  define YYSIZE_T unsigned int
328 # endif
329 #endif
330
331 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
332
333 #ifndef YY_
334 # if defined YYENABLE_NLS && YYENABLE_NLS
335 #  if ENABLE_NLS
336 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
337 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
338 #  endif
339 # endif
340 # ifndef YY_
341 #  define YY_(msgid) msgid
342 # endif
343 #endif
344
345 /* Suppress unused-variable warnings by "using" E.  */
346 #if ! defined lint || defined __GNUC__
347 # define YYUSE(e) ((void) (e))
348 #else
349 # define YYUSE(e) /* empty */
350 #endif
351
352 /* Identity function, used to suppress warnings about constant conditions.  */
353 #ifndef lint
354 # define YYID(n) (n)
355 #else
356 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
357 static int
358 YYID (int yyi)
359 #else
360 static int
361 YYID (yyi)
362     int yyi;
363 #endif
364 {
365   return yyi;
366 }
367 #endif
368
369 #if ! defined yyoverflow || YYERROR_VERBOSE
370
371 /* The parser invokes alloca or malloc; define the necessary symbols.  */
372
373 # ifdef YYSTACK_USE_ALLOCA
374 #  if YYSTACK_USE_ALLOCA
375 #   ifdef __GNUC__
376 #    define YYSTACK_ALLOC __builtin_alloca
377 #   elif defined __BUILTIN_VA_ARG_INCR
378 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
379 #   elif defined _AIX
380 #    define YYSTACK_ALLOC __alloca
381 #   elif defined _MSC_VER
382 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
383 #    define alloca _alloca
384 #   else
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
391 #     endif
392 #    endif
393 #   endif
394 #  endif
395 # endif
396
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 */
406 #  endif
407 # else
408 #  define YYSTACK_ALLOC YYMALLOC
409 #  define YYSTACK_FREE YYFREE
410 #  ifndef YYSTACK_ALLOC_MAXIMUM
411 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
412 #  endif
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
419 #   endif
420 #  endif
421 #  ifndef YYMALLOC
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 */
426 #   endif
427 #  endif
428 #  ifndef YYFREE
429 #   define YYFREE free
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 */
433 #   endif
434 #  endif
435 # endif
436 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
437
438
439 #if (! defined yyoverflow      && (! defined __cplusplus         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
440
441 /* A type that is properly aligned for any stack member.  */
442 union yyalloc
443 {
444   yytype_int16 yyss_alloc;
445   YYSTYPE yyvs_alloc;
446 };
447
448 /* The size of the maximum gap between one aligned stack and the next.  */
449 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
450
451 /* The size of an array large to enough to hold all stacks, each with
452    N elements.  */
453 # define YYSTACK_BYTES(N) \
454      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
455       + YYSTACK_GAP_MAXIMUM)
456
457 # define YYCOPY_NEEDED 1
458
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
463    stack.  */
464 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
465     do                                                                  \
466       {                                                                 \
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);                          \
472       }                                                                 \
473     while (YYID (0))
474
475 #endif
476
477 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
478 /* Copy COUNT objects from FROM to TO.  The source and destination do
479    not overlap.  */
480 # ifndef YYCOPY
481 #  if defined __GNUC__ && 1 < __GNUC__
482 #   define YYCOPY(To, From, Count) \
483       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
484 #  else
485 #   define YYCOPY(To, From, Count)              \
486       do                                        \
487         {                                       \
488           YYSIZE_T yyi;                         \
489           for (yyi = 0; yyi < (Count); yyi++)   \
490             (To)[yyi] = (From)[yyi];            \
491         }                                       \
492       while (YYID (0))
493 #  endif
494 # endif
495 #endif /* !YYCOPY_NEEDED */
496
497 /* YYFINAL -- State number of the termination state.  */
498 #define YYFINAL  2
499 /* YYLAST -- Last index in YYTABLE.  */
500 #define YYLAST   203
501
502 /* YYNTOKENS -- Number of terminals.  */
503 #define YYNTOKENS  59
504 /* YYNNTS -- Number of nonterminals.  */
505 #define YYNNTS  55
506 /* YYNRULES -- Number of rules.  */
507 #define YYNRULES  156
508 /* YYNRULES -- Number of states.  */
509 #define YYNSTATES  203
510
511 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
512 #define YYUNDEFTOK  2
513 #define YYMAXUTOK   303
514
515 #define YYTRANSLATE(YYX)                                                \
516   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
517
518 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
519 static const yytype_uint8 yytranslate[] =
520 {
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,
551       45,    46,    47,    48
552 };
553
554 #if YYDEBUG
555 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
556    YYRHS.  */
557 static const yytype_uint16 yyprhs[] =
558 {
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
575 };
576
577 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
578 static const yytype_int8 yyrhs[] =
579 {
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
619 };
620
621 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
622 static const yytype_uint16 yyrline[] =
623 {
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
640 };
641 #endif
642
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[] =
647 {
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",
667   "nls", 0
668 };
669 #endif
670
671 # ifdef YYPRINT
672 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
673    token YYLEX-NUM.  */
674 static const yytype_uint16 yytoknum[] =
675 {
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
682 };
683 # endif
684
685 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
686 static const yytype_uint8 yyr1[] =
687 {
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
704 };
705
706 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
707 static const yytype_uint8 yyr2[] =
708 {
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,
724        1,     1,     2,     1,     2,     2,     1
725 };
726
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[] =
731 {
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,
752      137,    93,   135
753 };
754
755 /* YYDEFGOTO[NTERM-NUM].  */
756 static const yytype_int16 yydefgoto[] =
757 {
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,
763       94,   105,    68,   106,    54
764 };
765
766 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
767    STATE-NUM.  */
768 #define YYPACT_NINF -151
769 static const yytype_int16 yypact[] =
770 {
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,
791     -151,  -151,  -151
792 };
793
794 /* YYPGOTO[NTERM-NUM].  */
795 static const yytype_int16 yypgoto[] =
796 {
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
803 };
804
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[] =
810 {
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,
831        0,     0,     0,    45
832 };
833
834 #define yypact_value_is_default(yystate) \
835   ((yystate) == (-151))
836
837 #define yytable_value_is_error(yytable_value) \
838   YYID (0)
839
840 static const yytype_int16 yycheck[] =
841 {
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,
862       -1,    -1,    -1,    58
863 };
864
865 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
866    symbol of state STATE-NUM.  */
867 static const yytype_uint8 yystos[] =
868 {
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,
889       56,    79,   108
890 };
891
892 #define yyerrok         (yyerrstatus = 0)
893 #define yyclearin       (yychar = YYEMPTY)
894 #define YYEMPTY         (-2)
895 #define YYEOF           0
896
897 #define YYACCEPT        goto yyacceptlab
898 #define YYABORT         goto yyabortlab
899 #define YYERROR         goto yyerrorlab
900
901
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
907    discussed.  */
908
909 #define YYFAIL          goto yyerrlab
910 #if defined YYFAIL
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.  */
915 #endif
916
917 #define YYRECOVERING()  (!!yyerrstatus)
918
919 #define YYBACKUP(Token, Value)                                  \
920 do                                                              \
921   if (yychar == YYEMPTY && yylen == 1)                          \
922     {                                                           \
923       yychar = (Token);                                         \
924       yylval = (Value);                                         \
925       YYPOPSTACK (1);                                           \
926       goto yybackup;                                            \
927     }                                                           \
928   else                                                          \
929     {                                                           \
930       yyerror (YY_("syntax error: cannot back up")); \
931       YYERROR;                                                  \
932     }                                                           \
933 while (YYID (0))
934
935
936 #define YYTERROR        1
937 #define YYERRCODE       256
938
939
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).  */
943
944 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
945 #ifndef YYLLOC_DEFAULT
946 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
947     do                                                                  \
948       if (YYID (N))                                                    \
949         {                                                               \
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;       \
954         }                                                               \
955       else                                                              \
956         {                                                               \
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;                              \
961         }                                                               \
962     while (YYID (0))
963 #endif
964
965
966 /* This macro is provided for backward compatibility. */
967
968 #ifndef YY_LOCATION_PRINT
969 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
970 #endif
971
972
973 /* YYLEX -- calling `yylex' with the right arguments.  */
974
975 #ifdef YYLEX_PARAM
976 # define YYLEX yylex (YYLEX_PARAM)
977 #else
978 # define YYLEX yylex ()
979 #endif
980
981 /* Enable debugging if requested.  */
982 #if YYDEBUG
983
984 # ifndef YYFPRINTF
985 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
986 #  define YYFPRINTF fprintf
987 # endif
988
989 # define YYDPRINTF(Args)                        \
990 do {                                            \
991   if (yydebug)                                  \
992     YYFPRINTF Args;                             \
993 } while (YYID (0))
994
995 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
996 do {                                                                      \
997   if (yydebug)                                                            \
998     {                                                                     \
999       YYFPRINTF (stderr, "%s ", Title);                                   \
1000       yy_symbol_print (stderr,                                            \
1001                   Type, Value); \
1002       YYFPRINTF (stderr, "\n");                                           \
1003     }                                                                     \
1004 } while (YYID (0))
1005
1006
1007 /*--------------------------------.
1008 | Print this symbol on YYOUTPUT.  |
1009 `--------------------------------*/
1010
1011 /*ARGSUSED*/
1012 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1013 static void
1014 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1015 #else
1016 static void
1017 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1018     FILE *yyoutput;
1019     int yytype;
1020     YYSTYPE const * const yyvaluep;
1021 #endif
1022 {
1023   if (!yyvaluep)
1024     return;
1025 # ifdef YYPRINT
1026   if (yytype < YYNTOKENS)
1027     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1028 # else
1029   YYUSE (yyoutput);
1030 # endif
1031   switch (yytype)
1032     {
1033       default:
1034         break;
1035     }
1036 }
1037
1038
1039 /*--------------------------------.
1040 | Print this symbol on YYOUTPUT.  |
1041 `--------------------------------*/
1042
1043 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1044 static void
1045 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1046 #else
1047 static void
1048 yy_symbol_print (yyoutput, yytype, yyvaluep)
1049     FILE *yyoutput;
1050     int yytype;
1051     YYSTYPE const * const yyvaluep;
1052 #endif
1053 {
1054   if (yytype < YYNTOKENS)
1055     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1056   else
1057     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1058
1059   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1060   YYFPRINTF (yyoutput, ")");
1061 }
1062
1063 /*------------------------------------------------------------------.
1064 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1065 | TOP (included).                                                   |
1066 `------------------------------------------------------------------*/
1067
1068 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1069 static void
1070 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1071 #else
1072 static void
1073 yy_stack_print (yybottom, yytop)
1074     yytype_int16 *yybottom;
1075     yytype_int16 *yytop;
1076 #endif
1077 {
1078   YYFPRINTF (stderr, "Stack now");
1079   for (; yybottom <= yytop; yybottom++)
1080     {
1081       int yybot = *yybottom;
1082       YYFPRINTF (stderr, " %d", yybot);
1083     }
1084   YYFPRINTF (stderr, "\n");
1085 }
1086
1087 # define YY_STACK_PRINT(Bottom, Top)                            \
1088 do {                                                            \
1089   if (yydebug)                                                  \
1090     yy_stack_print ((Bottom), (Top));                           \
1091 } while (YYID (0))
1092
1093
1094 /*------------------------------------------------.
1095 | Report that the YYRULE is going to be reduced.  |
1096 `------------------------------------------------*/
1097
1098 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1099 static void
1100 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1101 #else
1102 static void
1103 yy_reduce_print (yyvsp, yyrule)
1104     YYSTYPE *yyvsp;
1105     int yyrule;
1106 #endif
1107 {
1108   int yynrhs = yyr2[yyrule];
1109   int yyi;
1110   unsigned long int yylno = yyrline[yyrule];
1111   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1112              yyrule - 1, yylno);
1113   /* The symbols being reduced.  */
1114   for (yyi = 0; yyi < yynrhs; yyi++)
1115     {
1116       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1117       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1118                        &(yyvsp[(yyi + 1) - (yynrhs)])
1119                                        );
1120       YYFPRINTF (stderr, "\n");
1121     }
1122 }
1123
1124 # define YY_REDUCE_PRINT(Rule)          \
1125 do {                                    \
1126   if (yydebug)                          \
1127     yy_reduce_print (yyvsp, Rule); \
1128 } while (YYID (0))
1129
1130 /* Nonzero means print parse trace.  It is left uninitialized so that
1131    multiple parsers can coexist.  */
1132 int yydebug;
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 */
1139
1140
1141 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1142 #ifndef YYINITDEPTH
1143 # define YYINITDEPTH 200
1144 #endif
1145
1146 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1147    if the built-in stack extension method is used).
1148
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.  */
1152
1153 #ifndef YYMAXDEPTH
1154 # define YYMAXDEPTH 10000
1155 #endif
1156
1157
1158 #if YYERROR_VERBOSE
1159
1160 # ifndef yystrlen
1161 #  if defined __GLIBC__ && defined _STRING_H
1162 #   define yystrlen strlen
1163 #  else
1164 /* Return the length of YYSTR.  */
1165 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1166 static YYSIZE_T
1167 yystrlen (const char *yystr)
1168 #else
1169 static YYSIZE_T
1170 yystrlen (yystr)
1171     const char *yystr;
1172 #endif
1173 {
1174   YYSIZE_T yylen;
1175   for (yylen = 0; yystr[yylen]; yylen++)
1176     continue;
1177   return yylen;
1178 }
1179 #  endif
1180 # endif
1181
1182 # ifndef yystpcpy
1183 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1184 #   define yystpcpy stpcpy
1185 #  else
1186 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1187    YYDEST.  */
1188 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1189 static char *
1190 yystpcpy (char *yydest, const char *yysrc)
1191 #else
1192 static char *
1193 yystpcpy (yydest, yysrc)
1194     char *yydest;
1195     const char *yysrc;
1196 #endif
1197 {
1198   char *yyd = yydest;
1199   const char *yys = yysrc;
1200
1201   while ((*yyd++ = *yys++) != '\0')
1202     continue;
1203
1204   return yyd - 1;
1205 }
1206 #  endif
1207 # endif
1208
1209 # ifndef yytnamerr
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
1216    would have been.  */
1217 static YYSIZE_T
1218 yytnamerr (char *yyres, const char *yystr)
1219 {
1220   if (*yystr == '"')
1221     {
1222       YYSIZE_T yyn = 0;
1223       char const *yyp = yystr;
1224
1225       for (;;)
1226         switch (*++yyp)
1227           {
1228           case '\'':
1229           case ',':
1230             goto do_not_strip_quotes;
1231
1232           case '\\':
1233             if (*++yyp != '\\')
1234               goto do_not_strip_quotes;
1235             /* Fall through.  */
1236           default:
1237             if (yyres)
1238               yyres[yyn] = *yyp;
1239             yyn++;
1240             break;
1241
1242           case '"':
1243             if (yyres)
1244               yyres[yyn] = '\0';
1245             return yyn;
1246           }
1247     do_not_strip_quotes: ;
1248     }
1249
1250   if (! yyres)
1251     return yystrlen (yystr);
1252
1253   return yystpcpy (yyres, yystr) - yyres;
1254 }
1255 # endif
1256
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
1259    YYSSP.
1260
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.  */
1265 static int
1266 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1267                 yytype_int16 *yyssp, int yytoken)
1268 {
1269   YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1270   YYSIZE_T yysize = yysize0;
1271   YYSIZE_T yysize1;
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
1278      "expected"). */
1279   int yycount = 0;
1280
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
1285        function.
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.
1307   */
1308   if (yytoken != YYEMPTY)
1309     {
1310       int yyn = yypact[*yyssp];
1311       yyarg[yycount++] = yytname[yytoken];
1312       if (!yypact_value_is_default (yyn))
1313         {
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;
1321           int yyx;
1322
1323           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1324             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1325                 && !yytable_value_is_error (yytable[yyx + yyn]))
1326               {
1327                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1328                   {
1329                     yycount = 1;
1330                     yysize = yysize0;
1331                     break;
1332                   }
1333                 yyarg[yycount++] = yytname[yyx];
1334                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1335                 if (! (yysize <= yysize1
1336                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1337                   return 2;
1338                 yysize = yysize1;
1339               }
1340         }
1341     }
1342
1343   switch (yycount)
1344     {
1345 # define YYCASE_(N, S)                      \
1346       case N:                               \
1347         yyformat = S;                       \
1348       break
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"));
1355 # undef YYCASE_
1356     }
1357
1358   yysize1 = yysize + yystrlen (yyformat);
1359   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1360     return 2;
1361   yysize = yysize1;
1362
1363   if (*yymsg_alloc < yysize)
1364     {
1365       *yymsg_alloc = 2 * yysize;
1366       if (! (yysize <= *yymsg_alloc
1367              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1368         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1369       return 1;
1370     }
1371
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.  */
1375   {
1376     char *yyp = *yymsg;
1377     int yyi = 0;
1378     while ((*yyp = *yyformat) != '\0')
1379       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1380         {
1381           yyp += yytnamerr (yyp, yyarg[yyi++]);
1382           yyformat += 2;
1383         }
1384       else
1385         {
1386           yyp++;
1387           yyformat++;
1388         }
1389   }
1390   return 0;
1391 }
1392 #endif /* YYERROR_VERBOSE */
1393
1394 /*-----------------------------------------------.
1395 | Release the memory associated to this symbol.  |
1396 `-----------------------------------------------*/
1397
1398 /*ARGSUSED*/
1399 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1400 static void
1401 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1402 #else
1403 static void
1404 yydestruct (yymsg, yytype, yyvaluep)
1405     const char *yymsg;
1406     int yytype;
1407     YYSTYPE *yyvaluep;
1408 #endif
1409 {
1410   YYUSE (yyvaluep);
1411
1412   if (!yymsg)
1413     yymsg = "Deleting";
1414   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1415
1416   switch (yytype)
1417     {
1418
1419       default:
1420         break;
1421     }
1422 }
1423
1424
1425 /* Prevent warnings from -Wmissing-prototypes.  */
1426 #ifdef YYPARSE_PARAM
1427 #if defined __STDC__ || defined __cplusplus
1428 int yyparse (void *YYPARSE_PARAM);
1429 #else
1430 int yyparse ();
1431 #endif
1432 #else /* ! YYPARSE_PARAM */
1433 #if defined __STDC__ || defined __cplusplus
1434 int yyparse (void);
1435 #else
1436 int yyparse ();
1437 #endif
1438 #endif /* ! YYPARSE_PARAM */
1439
1440
1441 /* The lookahead symbol.  */
1442 int yychar;
1443
1444 /* The semantic value of the lookahead symbol.  */
1445 YYSTYPE yylval;
1446
1447 /* Number of syntax errors so far.  */
1448 int yynerrs;
1449
1450
1451 /*----------.
1452 | yyparse.  |
1453 `----------*/
1454
1455 #ifdef YYPARSE_PARAM
1456 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1457 int
1458 yyparse (void *YYPARSE_PARAM)
1459 #else
1460 int
1461 yyparse (YYPARSE_PARAM)
1462     void *YYPARSE_PARAM;
1463 #endif
1464 #else /* ! YYPARSE_PARAM */
1465 #if (defined __STDC__ || defined __C99__FUNC__      || defined __cplusplus || defined _MSC_VER)
1466 int
1467 yyparse (void)
1468 #else
1469 int
1470 yyparse ()
1471
1472 #endif
1473 #endif
1474 {
1475     int yystate;
1476     /* Number of tokens to shift before error messages enabled.  */
1477     int yyerrstatus;
1478
1479     /* The stacks and their tools:
1480        `yyss': related to states.
1481        `yyvs': related to semantic values.
1482
1483        Refer to the stacks thru separate pointers, to allow yyoverflow
1484        to reallocate them elsewhere.  */
1485
1486     /* The state stack.  */
1487     yytype_int16 yyssa[YYINITDEPTH];
1488     yytype_int16 *yyss;
1489     yytype_int16 *yyssp;
1490
1491     /* The semantic value stack.  */
1492     YYSTYPE yyvsa[YYINITDEPTH];
1493     YYSTYPE *yyvs;
1494     YYSTYPE *yyvsp;
1495
1496     YYSIZE_T yystacksize;
1497
1498   int yyn;
1499   int yyresult;
1500   /* Lookahead token as an internal (translated) token number.  */
1501   int yytoken;
1502   /* The variables used to return semantic value and location from the
1503      action routines.  */
1504   YYSTYPE yyval;
1505
1506 #if YYERROR_VERBOSE
1507   /* Buffer for error messages, and its allocated size.  */
1508   char yymsgbuf[128];
1509   char *yymsg = yymsgbuf;
1510   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1511 #endif
1512
1513 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1514
1515   /* The number of symbols on the RHS of the reduced rule.
1516      Keep to zero when no symbol should be popped.  */
1517   int yylen = 0;
1518
1519   yytoken = 0;
1520   yyss = yyssa;
1521   yyvs = yyvsa;
1522   yystacksize = YYINITDEPTH;
1523
1524   YYDPRINTF ((stderr, "Starting parse\n"));
1525
1526   yystate = 0;
1527   yyerrstatus = 0;
1528   yynerrs = 0;
1529   yychar = YYEMPTY; /* Cause a token to be read.  */
1530
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.  */
1535   yyssp = yyss;
1536   yyvsp = yyvs;
1537
1538   goto yysetstate;
1539
1540 /*------------------------------------------------------------.
1541 | yynewstate -- Push a new state, which is found in yystate.  |
1542 `------------------------------------------------------------*/
1543  yynewstate:
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.  */
1546   yyssp++;
1547
1548  yysetstate:
1549   *yyssp = yystate;
1550
1551   if (yyss + yystacksize - 1 <= yyssp)
1552     {
1553       /* Get the current used size of the three stacks, in elements.  */
1554       YYSIZE_T yysize = yyssp - yyss + 1;
1555
1556 #ifdef yyoverflow
1557       {
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
1560            memory.  */
1561         YYSTYPE *yyvs1 = yyvs;
1562         yytype_int16 *yyss1 = yyss;
1563
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),
1571                     &yystacksize);
1572
1573         yyss = yyss1;
1574         yyvs = yyvs1;
1575       }
1576 #else /* no yyoverflow */
1577 # ifndef YYSTACK_RELOCATE
1578       goto yyexhaustedlab;
1579 # else
1580       /* Extend the stack our own way.  */
1581       if (YYMAXDEPTH <= yystacksize)
1582         goto yyexhaustedlab;
1583       yystacksize *= 2;
1584       if (YYMAXDEPTH < yystacksize)
1585         yystacksize = YYMAXDEPTH;
1586
1587       {
1588         yytype_int16 *yyss1 = yyss;
1589         union yyalloc *yyptr =
1590           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1591         if (! yyptr)
1592           goto yyexhaustedlab;
1593         YYSTACK_RELOCATE (yyss_alloc, yyss);
1594         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1595 #  undef YYSTACK_RELOCATE
1596         if (yyss1 != yyssa)
1597           YYSTACK_FREE (yyss1);
1598       }
1599 # endif
1600 #endif /* no yyoverflow */
1601
1602       yyssp = yyss + yysize - 1;
1603       yyvsp = yyvs + yysize - 1;
1604
1605       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1606                   (unsigned long int) yystacksize));
1607
1608       if (yyss + yystacksize - 1 <= yyssp)
1609         YYABORT;
1610     }
1611
1612   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1613
1614   if (yystate == YYFINAL)
1615     YYACCEPT;
1616
1617   goto yybackup;
1618
1619 /*-----------.
1620 | yybackup.  |
1621 `-----------*/
1622 yybackup:
1623
1624   /* Do appropriate processing given the current state.  Read a
1625      lookahead token if we need one and don't already have one.  */
1626
1627   /* First try to decide what to do without reference to lookahead token.  */
1628   yyn = yypact[yystate];
1629   if (yypact_value_is_default (yyn))
1630     goto yydefault;
1631
1632   /* Not known => get a lookahead token if don't already have one.  */
1633
1634   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1635   if (yychar == YYEMPTY)
1636     {
1637       YYDPRINTF ((stderr, "Reading a token: "));
1638       yychar = YYLEX;
1639     }
1640
1641   if (yychar <= YYEOF)
1642     {
1643       yychar = yytoken = YYEOF;
1644       YYDPRINTF ((stderr, "Now at end of input.\n"));
1645     }
1646   else
1647     {
1648       yytoken = YYTRANSLATE (yychar);
1649       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1650     }
1651
1652   /* If the proper action on seeing token YYTOKEN is to reduce or to
1653      detect an error, take that action.  */
1654   yyn += yytoken;
1655   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1656     goto yydefault;
1657   yyn = yytable[yyn];
1658   if (yyn <= 0)
1659     {
1660       if (yytable_value_is_error (yyn))
1661         goto yyerrlab;
1662       yyn = -yyn;
1663       goto yyreduce;
1664     }
1665
1666   /* Count tokens shifted since error; after three, turn off error
1667      status.  */
1668   if (yyerrstatus)
1669     yyerrstatus--;
1670
1671   /* Shift the lookahead token.  */
1672   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1673
1674   /* Discard the shifted token.  */
1675   yychar = YYEMPTY;
1676
1677   yystate = yyn;
1678   *++yyvsp = yylval;
1679
1680   goto yynewstate;
1681
1682
1683 /*-----------------------------------------------------------.
1684 | yydefault -- do the default action for the current state.  |
1685 `-----------------------------------------------------------*/
1686 yydefault:
1687   yyn = yydefact[yystate];
1688   if (yyn == 0)
1689     goto yyerrlab;
1690   goto yyreduce;
1691
1692
1693 /*-----------------------------.
1694 | yyreduce -- Do a reduction.  |
1695 `-----------------------------*/
1696 yyreduce:
1697   /* yyn is the number of a rule to reduce with.  */
1698   yylen = yyr2[yyn];
1699
1700   /* If YYLEN is nonzero, implement the default value of the action:
1701      `$$ = $1'.
1702
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];
1709
1710
1711   YY_REDUCE_PRINT (yyn);
1712   switch (yyn)
1713     {
1714         case 3:
1715
1716 /* Line 1806 of yacc.c  */
1717 #line 109 "command.y"
1718     {
1719                 cmd_idx = -1;
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;
1726                 }
1727                 if (arg_list != NULL) {
1728                         free_cmdarg(arg_list);
1729                         arg_list = NULL;
1730                 }
1731           }
1732     break;
1733
1734   case 5:
1735
1736 /* Line 1806 of yacc.c  */
1737 #line 128 "command.y"
1738     {
1739                 if (errcount == 0 && cmd_idx >= 0) {
1740                         Func_cmd cmdfunc;
1741                         int terminate = FALSE;
1742                         CMDARG *args;
1743                         int ctype = 0;
1744                         
1745                         ctype = cmdtab[cmd_idx].type;
1746
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
1750                          */
1751                         if ((ctype == D_list
1752                                         || ctype == D_next
1753                                         || ctype == D_step
1754                                         || ctype == D_nexti
1755                                         || ctype == D_stepi
1756                                         || ctype == D_continue)
1757                                 && arg_list == NULL
1758                                 && ! in_commands
1759                                 && input_from_tty
1760                         )
1761                                 repeat_idx = cmd_idx;
1762                         else
1763                                 repeat_idx = -1;
1764
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.
1769                          */
1770
1771                         cmdfunc = cmdtab[cmd_idx].cf_ptr;
1772                         if (in_commands)
1773                                 cmdfunc = do_commands;
1774                         cmd_idx = -1;
1775                         want_nodeval = FALSE;
1776
1777                         args = arg_list;
1778                         arg_list = NULL;
1779
1780                         terminate = (*cmdfunc)(args, ctype);
1781                         if (! in_commands || ctype == D_commands)
1782                                 free_cmdarg(args);
1783                         if (terminate)
1784                                 YYACCEPT;
1785                 }
1786           }
1787     break;
1788
1789   case 6:
1790
1791 /* Line 1806 of yacc.c  */
1792 #line 178 "command.y"
1793     {
1794                 yyerrok;
1795           }
1796     break;
1797
1798   case 22:
1799
1800 /* Line 1806 of yacc.c  */
1801 #line 212 "command.y"
1802     { want_nodeval = TRUE; }
1803     break;
1804
1805   case 23:
1806
1807 /* Line 1806 of yacc.c  */
1808 #line 217 "command.y"
1809     {
1810                 if (errcount == 0) {
1811                         /* don't free arg_list; passed on to statement_list
1812                          * non-terminal (empty rule action). See below.
1813                          */
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;
1818                         }
1819                         cmd_idx = -1;
1820                         in_eval = TRUE;
1821                 }
1822           }
1823     break;
1824
1825   case 24:
1826
1827 /* Line 1806 of yacc.c  */
1828 #line 235 "command.y"
1829     {
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);
1834                 arg_list = NULL;
1835           }
1836     break;
1837
1838   case 25:
1839
1840 /* Line 1806 of yacc.c  */
1841 #line 242 "command.y"
1842     { (yyval) = append_statement((yyvsp[(1) - (2)]), lexptr_begin); }
1843     break;
1844
1845   case 26:
1846
1847 /* Line 1806 of yacc.c  */
1848 #line 243 "command.y"
1849     {
1850                 (yyval) = (yyvsp[(3) - (4)]);
1851           }
1852     break;
1853
1854   case 27:
1855
1856 /* Line 1806 of yacc.c  */
1857 #line 250 "command.y"
1858     {
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';
1865                 }
1866                 if (input_from_tty) {
1867                         dPrompt = in_commands ? commands_Prompt : dgawk_Prompt;
1868                         rl_inhibit_completion = 0;
1869                 }
1870                 cmd_idx = find_command("eval", 4);
1871                 in_eval = FALSE;
1872           }
1873     break;
1874
1875   case 28:
1876
1877 /* Line 1806 of yacc.c  */
1878 #line 266 "command.y"
1879     {
1880                 NODE *n;
1881                 CMDARG *arg;
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);
1887                 arg_list = arg;
1888           }
1889     break;
1890
1891   case 34:
1892
1893 /* Line 1806 of yacc.c  */
1894 #line 285 "command.y"
1895     {
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);
1899           }
1900     break;
1901
1902   case 35:
1903
1904 /* Line 1806 of yacc.c  */
1905 #line 291 "command.y"
1906     {
1907                 int idx = find_argument((yyvsp[(2) - (2)]));
1908                 if (idx < 0)
1909                         yyerror(_("info: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string);
1910                 else {
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;
1915                 }
1916           }
1917     break;
1918
1919   case 38:
1920
1921 /* Line 1806 of yacc.c  */
1922 #line 304 "command.y"
1923     { want_nodeval = TRUE; }
1924     break;
1925
1926   case 40:
1927
1928 /* Line 1806 of yacc.c  */
1929 #line 305 "command.y"
1930     { want_nodeval = TRUE; }
1931     break;
1932
1933   case 46:
1934
1935 /* Line 1806 of yacc.c  */
1936 #line 310 "command.y"
1937     { want_nodeval = TRUE; }
1938     break;
1939
1940   case 49:
1941
1942 /* Line 1806 of yacc.c  */
1943 #line 312 "command.y"
1944     { want_nodeval = TRUE; }
1945     break;
1946
1947   case 51:
1948
1949 /* Line 1806 of yacc.c  */
1950 #line 313 "command.y"
1951     { want_nodeval = TRUE; }
1952     break;
1953
1954   case 53:
1955
1956 /* Line 1806 of yacc.c  */
1957 #line 314 "command.y"
1958     { want_nodeval = TRUE; }
1959     break;
1960
1961   case 57:
1962
1963 /* Line 1806 of yacc.c  */
1964 #line 318 "command.y"
1965     {
1966                 if (in_cmd_src((yyvsp[(2) - (2)])->a_string))
1967                         yyerror(_("source \"%s\": already sourced."), (yyvsp[(2) - (2)])->a_string);
1968           }
1969     break;
1970
1971   case 58:
1972
1973 /* Line 1806 of yacc.c  */
1974 #line 323 "command.y"
1975     {
1976                 if (! input_from_tty)
1977                         yyerror(_("save \"%s\": command not permitted."), (yyvsp[(2) - (2)])->a_string);
1978           }
1979     break;
1980
1981   case 59:
1982
1983 /* Line 1806 of yacc.c  */
1984 #line 328 "command.y"
1985     {
1986                 int type = 0;
1987                 int num;
1988
1989                 if ((yyvsp[(2) - (2)]) != NULL)
1990                         num = (yyvsp[(2) - (2)])->a_int;
1991
1992                 if (errcount != 0)
1993                         ;
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"));
2000                 if (type) {
2001                         in_commands = TRUE;
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"));
2007                         }
2008                 }
2009           }
2010     break;
2011
2012   case 60:
2013
2014 /* Line 1806 of yacc.c  */
2015 #line 354 "command.y"
2016     {
2017                 if (! in_commands)
2018                         yyerror(_("`end' valid only in command `commands' or `eval'"));
2019                 else {
2020                         if (input_from_tty)
2021                                 dPrompt = dgawk_Prompt; 
2022                         in_commands = FALSE;
2023                 }
2024           }
2025     break;
2026
2027   case 61:
2028
2029 /* Line 1806 of yacc.c  */
2030 #line 364 "command.y"
2031     {
2032                 if (! in_commands)
2033                         yyerror(_("`silent' valid only in command `commands'"));
2034           }
2035     break;
2036
2037   case 62:
2038
2039 /* Line 1806 of yacc.c  */
2040 #line 369 "command.y"
2041     {
2042                 int idx = find_argument((yyvsp[(2) - (2)]));
2043                 if (idx < 0)
2044                         yyerror(_("trace: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string);
2045                 else {
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;
2050                 }
2051           }
2052     break;
2053
2054   case 63:
2055
2056 /* Line 1806 of yacc.c  */
2057 #line 380 "command.y"
2058     { want_nodeval = TRUE; }
2059     break;
2060
2061   case 64:
2062
2063 /* Line 1806 of yacc.c  */
2064 #line 381 "command.y"
2065     {
2066                 int type;
2067                 int num = (yyvsp[(2) - (4)])->a_int;
2068                 type = has_break_or_watch_point(&num, FALSE);
2069                 if (! type)
2070                         yyerror(_("condition: invalid breakpoint/watchpoint number"));
2071           }
2072     break;
2073
2074   case 65:
2075
2076 /* Line 1806 of yacc.c  */
2077 #line 389 "command.y"
2078     {
2079                 if (in_commands) {
2080                         /* Prepend command 'eval' to argument list */
2081                         CMDARG *arg;
2082                         arg = mk_cmdarg(D_string);
2083                         arg->a_string = estrdup("eval", 4);
2084                         arg->next = arg_list;
2085                         arg_list = arg;
2086                 }
2087           }
2088     break;
2089
2090   case 66:
2091
2092 /* Line 1806 of yacc.c  */
2093 #line 403 "command.y"
2094     {
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;
2099                         freenode(n);
2100                 }
2101                 (yyval) = (yyvsp[(1) - (1)]);
2102           }
2103     break;
2104
2105   case 68:
2106
2107 /* Line 1806 of yacc.c  */
2108 #line 417 "command.y"
2109     {   (yyval) = NULL; }
2110     break;
2111
2112   case 69:
2113
2114 /* Line 1806 of yacc.c  */
2115 #line 422 "command.y"
2116     { (yyval) = NULL; }
2117     break;
2118
2119   case 74:
2120
2121 /* Line 1806 of yacc.c  */
2122 #line 431 "command.y"
2123     { (yyval) = NULL; }
2124     break;
2125
2126   case 75:
2127
2128 /* Line 1806 of yacc.c  */
2129 #line 436 "command.y"
2130     { (yyval) = NULL; }
2131     break;
2132
2133   case 77:
2134
2135 /* Line 1806 of yacc.c  */
2136 #line 439 "command.y"
2137     { (yyval) = NULL; }
2138     break;
2139
2140   case 78:
2141
2142 /* Line 1806 of yacc.c  */
2143 #line 444 "command.y"
2144     {
2145                 NODE *n;
2146                 n = (yyvsp[(1) - (1)])->a_node;
2147                 if ((n->flags & STRING) == 0)
2148                         yyerror(_("argument not a string"));
2149           }
2150     break;
2151
2152   case 79:
2153
2154 /* Line 1806 of yacc.c  */
2155 #line 454 "command.y"
2156     { (yyval) = NULL; }
2157     break;
2158
2159   case 80:
2160
2161 /* Line 1806 of yacc.c  */
2162 #line 456 "command.y"
2163     {
2164                 if (find_option((yyvsp[(1) - (1)])->a_string) < 0)
2165                         yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (1)])->a_string);
2166           }
2167     break;
2168
2169   case 81:
2170
2171 /* Line 1806 of yacc.c  */
2172 #line 461 "command.y"
2173     {
2174                 if (find_option((yyvsp[(1) - (3)])->a_string) < 0)
2175                         yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (3)])->a_string);
2176           }
2177     break;
2178
2179   case 82:
2180
2181 /* Line 1806 of yacc.c  */
2182 #line 469 "command.y"
2183     {
2184                 NODE *n;
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);
2188                 else {
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;
2193                 }
2194           }
2195     break;
2196
2197   case 83:
2198
2199 /* Line 1806 of yacc.c  */
2200 #line 485 "command.y"
2201     { (yyval) = NULL; }
2202     break;
2203
2204   case 88:
2205
2206 /* Line 1806 of yacc.c  */
2207 #line 494 "command.y"
2208     { (yyval) = NULL; }
2209     break;
2210
2211   case 89:
2212
2213 /* Line 1806 of yacc.c  */
2214 #line 495 "command.y"
2215     { want_nodeval = TRUE; }
2216     break;
2217
2218   case 92:
2219
2220 /* Line 1806 of yacc.c  */
2221 #line 497 "command.y"
2222     { want_nodeval = TRUE; }
2223     break;
2224
2225   case 95:
2226
2227 /* Line 1806 of yacc.c  */
2228 #line 503 "command.y"
2229     { (yyval) = NULL; }
2230     break;
2231
2232   case 97:
2233
2234 /* Line 1806 of yacc.c  */
2235 #line 509 "command.y"
2236     { (yyval) = NULL; }
2237     break;
2238
2239   case 99:
2240
2241 /* Line 1806 of yacc.c  */
2242 #line 515 "command.y"
2243     { (yyval) = NULL; }
2244     break;
2245
2246   case 104:
2247
2248 /* Line 1806 of yacc.c  */
2249 #line 527 "command.y"
2250     {
2251                 int idx = find_argument((yyvsp[(1) - (2)]));
2252                 if (idx < 0)
2253                         yyerror(_("enable: invalid option - \"%s\""), (yyvsp[(1) - (2)])->a_string);
2254                 else {
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;
2259                 }
2260           }
2261     break;
2262
2263   case 106:
2264
2265 /* Line 1806 of yacc.c  */
2266 #line 543 "command.y"
2267     {
2268                 (yyvsp[(2) - (2)])->type = D_array;     /* dump all items */
2269                 (yyvsp[(2) - (2)])->a_count = 0;
2270           }
2271     break;
2272
2273   case 107:
2274
2275 /* Line 1806 of yacc.c  */
2276 #line 548 "command.y"
2277     {
2278                 (yyvsp[(2) - (3)])->type = D_array;
2279                 (yyvsp[(2) - (3)])->a_count = num_dim;
2280           }
2281     break;
2282
2283   case 117:
2284
2285 /* Line 1806 of yacc.c  */
2286 #line 574 "command.y"
2287     { (yyval) = NULL; }
2288     break;
2289
2290   case 118:
2291
2292 /* Line 1806 of yacc.c  */
2293 #line 576 "command.y"
2294     { (yyval) = NULL; }
2295     break;
2296
2297   case 119:
2298
2299 /* Line 1806 of yacc.c  */
2300 #line 578 "command.y"
2301     {
2302                 CMDARG *a;
2303                 a = mk_cmdarg(D_int);
2304                 a->a_int = -1;
2305                 append_cmdarg(a);
2306           }
2307     break;
2308
2309   case 126:
2310
2311 /* Line 1806 of yacc.c  */
2312 #line 594 "command.y"
2313     {
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);
2317                 else
2318                         (yyvsp[(1) - (3)])->type = D_range;
2319                 (yyval) = (yyvsp[(1) - (3)]);
2320           }
2321     break;
2322
2323   case 127:
2324
2325 /* Line 1806 of yacc.c  */
2326 #line 606 "command.y"
2327     { (yyval) = NULL; }
2328     break;
2329
2330   case 134:
2331
2332 /* Line 1806 of yacc.c  */
2333 #line 620 "command.y"
2334     { (yyval) = (yyvsp[(1) - (1)]); }
2335     break;
2336
2337   case 135:
2338
2339 /* Line 1806 of yacc.c  */
2340 #line 622 "command.y"
2341     { (yyval) = (yyvsp[(1) - (3)]); }
2342     break;
2343
2344   case 137:
2345
2346 /* Line 1806 of yacc.c  */
2347 #line 628 "command.y"
2348     {
2349                 CMDARG *a;
2350                 NODE *subs;
2351                 int count = 0;
2352                 
2353                 for (a = (yyvsp[(2) - (3)]); a != NULL; a = a->next)
2354                         count++;
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)]);
2361           }
2362     break;
2363
2364   case 139:
2365
2366 /* Line 1806 of yacc.c  */
2367 #line 647 "command.y"
2368     { (yyval) = (yyvsp[(1) - (1)]); num_dim = 1; }
2369     break;
2370
2371   case 140:
2372
2373 /* Line 1806 of yacc.c  */
2374 #line 649 "command.y"
2375     {   (yyval) = (yyvsp[(1) - (2)]); num_dim++; }
2376     break;
2377
2378   case 142:
2379
2380 /* Line 1806 of yacc.c  */
2381 #line 655 "command.y"
2382     {
2383                 NODE *n = (yyvsp[(2) - (2)])->a_node;
2384                 if ((n->flags & NUMBER) == 0)
2385                         yyerror(_("non-numeric value for field number"));
2386                 else
2387                         (yyvsp[(2) - (2)])->type = D_field;
2388                 (yyval) = (yyvsp[(2) - (2)]);
2389           }
2390     break;
2391
2392   case 143:
2393
2394 /* Line 1806 of yacc.c  */
2395 #line 664 "command.y"
2396     {
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)]);
2401           }
2402     break;
2403
2404   case 144:
2405
2406 /* Line 1806 of yacc.c  */
2407 #line 674 "command.y"
2408     { (yyval) = (yyvsp[(1) - (1)]); }
2409     break;
2410
2411   case 145:
2412
2413 /* Line 1806 of yacc.c  */
2414 #line 676 "command.y"
2415     { 
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)]);
2420           }
2421     break;
2422
2423   case 146:
2424
2425 /* Line 1806 of yacc.c  */
2426 #line 683 "command.y"
2427     { 
2428                 NODE *n = (yyvsp[(2) - (2)])->a_node;
2429                 if ((n->flags & NUMBER) == 0)
2430                         yyerror(_("non-numeric value found, numeric expected"));
2431                 else
2432                         (yyvsp[(2) - (2)])->a_node->numbr = - n->numbr;
2433                 (yyval) = (yyvsp[(2) - (2)]);
2434           }
2435     break;
2436
2437   case 147:
2438
2439 /* Line 1806 of yacc.c  */
2440 #line 695 "command.y"
2441     { (yyval) = NULL; }
2442     break;
2443
2444   case 148:
2445
2446 /* Line 1806 of yacc.c  */
2447 #line 697 "command.y"
2448     { (yyval) = (yyvsp[(1) - (1)]); }
2449     break;
2450
2451   case 149:
2452
2453 /* Line 1806 of yacc.c  */
2454 #line 702 "command.y"
2455     { (yyval) = NULL; }
2456     break;
2457
2458   case 150:
2459
2460 /* Line 1806 of yacc.c  */
2461 #line 704 "command.y"
2462     { (yyval) = (yyvsp[(1) - (1)]); }
2463     break;
2464
2465   case 151:
2466
2467 /* Line 1806 of yacc.c  */
2468 #line 709 "command.y"
2469     {
2470                 if ((yyvsp[(1) - (1)])->a_int == 0)
2471                         yyerror(_("non-zero integer value"));
2472                 (yyval) = (yyvsp[(1) - (1)]);
2473           }
2474     break;
2475
2476   case 152:
2477
2478 /* Line 1806 of yacc.c  */
2479 #line 715 "command.y"
2480     {
2481                 if ((yyvsp[(2) - (2)])->a_int == 0)
2482                         yyerror(_("non-zero integer value"));
2483                 (yyval) = (yyvsp[(2) - (2)]);
2484           }
2485     break;
2486
2487   case 153:
2488
2489 /* Line 1806 of yacc.c  */
2490 #line 724 "command.y"
2491     { (yyval) = (yyvsp[(1) - (1)]); }
2492     break;
2493
2494   case 154:
2495
2496 /* Line 1806 of yacc.c  */
2497 #line 726 "command.y"
2498     { (yyval) = (yyvsp[(2) - (2)]); }
2499     break;
2500
2501   case 155:
2502
2503 /* Line 1806 of yacc.c  */
2504 #line 728 "command.y"
2505     {
2506                 (yyvsp[(2) - (2)])->a_int = - (yyvsp[(2) - (2)])->a_int;
2507                 (yyval) = (yyvsp[(2) - (2)]);
2508           }
2509     break;
2510
2511   case 156:
2512
2513 /* Line 1806 of yacc.c  */
2514 #line 736 "command.y"
2515     {
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;
2521                 }
2522           }
2523     break;
2524
2525
2526
2527 /* Line 1806 of yacc.c  */
2528 #line 2541 "command.c"
2529       default: break;
2530     }
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);
2543
2544   YYPOPSTACK (yylen);
2545   yylen = 0;
2546   YY_STACK_PRINT (yyss, yyssp);
2547
2548   *++yyvsp = yyval;
2549
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.  */
2553
2554   yyn = yyr1[yyn];
2555
2556   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2557   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2558     yystate = yytable[yystate];
2559   else
2560     yystate = yydefgoto[yyn - YYNTOKENS];
2561
2562   goto yynewstate;
2563
2564
2565 /*------------------------------------.
2566 | yyerrlab -- here on detecting error |
2567 `------------------------------------*/
2568 yyerrlab:
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);
2572
2573   /* If not already recovering from an error, report this error.  */
2574   if (!yyerrstatus)
2575     {
2576       ++yynerrs;
2577 #if ! YYERROR_VERBOSE
2578       yyerror (YY_("syntax error"));
2579 #else
2580 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2581                                         yyssp, yytoken)
2582       {
2583         char const *yymsgp = YY_("syntax error");
2584         int yysyntax_error_status;
2585         yysyntax_error_status = YYSYNTAX_ERROR;
2586         if (yysyntax_error_status == 0)
2587           yymsgp = yymsg;
2588         else if (yysyntax_error_status == 1)
2589           {
2590             if (yymsg != yymsgbuf)
2591               YYSTACK_FREE (yymsg);
2592             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2593             if (!yymsg)
2594               {
2595                 yymsg = yymsgbuf;
2596                 yymsg_alloc = sizeof yymsgbuf;
2597                 yysyntax_error_status = 2;
2598               }
2599             else
2600               {
2601                 yysyntax_error_status = YYSYNTAX_ERROR;
2602                 yymsgp = yymsg;
2603               }
2604           }
2605         yyerror (yymsgp);
2606         if (yysyntax_error_status == 2)
2607           goto yyexhaustedlab;
2608       }
2609 # undef YYSYNTAX_ERROR
2610 #endif
2611     }
2612
2613
2614
2615   if (yyerrstatus == 3)
2616     {
2617       /* If just tried and failed to reuse lookahead token after an
2618          error, discard it.  */
2619
2620       if (yychar <= YYEOF)
2621         {
2622           /* Return failure if at end of input.  */
2623           if (yychar == YYEOF)
2624             YYABORT;
2625         }
2626       else
2627         {
2628           yydestruct ("Error: discarding",
2629                       yytoken, &yylval);
2630           yychar = YYEMPTY;
2631         }
2632     }
2633
2634   /* Else will try to reuse lookahead token after shifting the error
2635      token.  */
2636   goto yyerrlab1;
2637
2638
2639 /*---------------------------------------------------.
2640 | yyerrorlab -- error raised explicitly by YYERROR.  |
2641 `---------------------------------------------------*/
2642 yyerrorlab:
2643
2644   /* Pacify compilers like GCC when the user code never invokes
2645      YYERROR and the label yyerrorlab therefore never appears in user
2646      code.  */
2647   if (/*CONSTCOND*/ 0)
2648      goto yyerrorlab;
2649
2650   /* Do not reclaim the symbols of the rule which action triggered
2651      this YYERROR.  */
2652   YYPOPSTACK (yylen);
2653   yylen = 0;
2654   YY_STACK_PRINT (yyss, yyssp);
2655   yystate = *yyssp;
2656   goto yyerrlab1;
2657
2658
2659 /*-------------------------------------------------------------.
2660 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2661 `-------------------------------------------------------------*/
2662 yyerrlab1:
2663   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2664
2665   for (;;)
2666     {
2667       yyn = yypact[yystate];
2668       if (!yypact_value_is_default (yyn))
2669         {
2670           yyn += YYTERROR;
2671           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2672             {
2673               yyn = yytable[yyn];
2674               if (0 < yyn)
2675                 break;
2676             }
2677         }
2678
2679       /* Pop the current state because it cannot handle the error token.  */
2680       if (yyssp == yyss)
2681         YYABORT;
2682
2683
2684       yydestruct ("Error: popping",
2685                   yystos[yystate], yyvsp);
2686       YYPOPSTACK (1);
2687       yystate = *yyssp;
2688       YY_STACK_PRINT (yyss, yyssp);
2689     }
2690
2691   *++yyvsp = yylval;
2692
2693
2694   /* Shift the error token.  */
2695   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2696
2697   yystate = yyn;
2698   goto yynewstate;
2699
2700
2701 /*-------------------------------------.
2702 | yyacceptlab -- YYACCEPT comes here.  |
2703 `-------------------------------------*/
2704 yyacceptlab:
2705   yyresult = 0;
2706   goto yyreturn;
2707
2708 /*-----------------------------------.
2709 | yyabortlab -- YYABORT comes here.  |
2710 `-----------------------------------*/
2711 yyabortlab:
2712   yyresult = 1;
2713   goto yyreturn;
2714
2715 #if !defined(yyoverflow) || YYERROR_VERBOSE
2716 /*-------------------------------------------------.
2717 | yyexhaustedlab -- memory exhaustion comes here.  |
2718 `-------------------------------------------------*/
2719 yyexhaustedlab:
2720   yyerror (YY_("memory exhausted"));
2721   yyresult = 2;
2722   /* Fall through.  */
2723 #endif
2724
2725 yyreturn:
2726   if (yychar != YYEMPTY)
2727     {
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",
2732                   yytoken, &yylval);
2733     }
2734   /* Do not reclaim the symbols of the rule which action triggered
2735      this YYABORT or YYACCEPT.  */
2736   YYPOPSTACK (yylen);
2737   YY_STACK_PRINT (yyss, yyssp);
2738   while (yyssp != yyss)
2739     {
2740       yydestruct ("Cleanup: popping",
2741                   yystos[*yyssp], yyvsp);
2742       YYPOPSTACK (1);
2743     }
2744 #ifndef yyoverflow
2745   if (yyss != yyssa)
2746     YYSTACK_FREE (yyss);
2747 #endif
2748 #if YYERROR_VERBOSE
2749   if (yymsg != yymsgbuf)
2750     YYSTACK_FREE (yymsg);
2751 #endif
2752   /* Make sure YYID is used.  */
2753   return YYID (yyresult);
2754 }
2755
2756
2757
2758 /* Line 2067 of yacc.c  */
2759 #line 746 "command.y"
2760
2761
2762
2763 /* append_statement --- append 'stmt' to the list of eval awk statements */ 
2764
2765 static CMDARG *
2766 append_statement(CMDARG *alist, char *stmt) 
2767 {
2768         CMDARG *a, *arg; 
2769         char *s;
2770         int len, slen, ssize;
2771
2772 #define EVALSIZE        512
2773
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 ',' */
2778                 len += EVALSIZE;
2779
2780                 emalloc(s, char *, (len + 2) * sizeof(char), "append_statement");
2781                 arg = mk_cmdarg(D_string);
2782                 arg->a_string = s;
2783                 arg->a_count = len;     /* kludge */
2784
2785                 slen = sizeof("function @eval(") - 1;
2786                 memcpy(s, start_EVAL, slen);
2787
2788                 for (a = alist; a != NULL; a = a->next) {
2789                         len = strlen(a->a_string);
2790                         memcpy(s + slen, a->a_string, len);
2791                         slen += len;
2792                         if (a->next != NULL)
2793                                 s[slen++] = ',';
2794                 }
2795                 s[slen++] = ')';
2796                 s[slen++] = '{';
2797                 s[slen] = '\0';
2798                 return arg;
2799         }
2800                  
2801         len = strlen(stmt) + 1; /* 1 for newline */
2802         s = alist->a_string;
2803         slen = strlen(s);
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;
2810         }
2811         memcpy(s + slen, stmt, len);
2812         slen += len;
2813         if (slen >= 2 && s[slen - 2] != '\n') {
2814                 s[slen - 1] = '\n';
2815                 s[slen] = '\0';
2816         }
2817
2818         if (stmt == end_EVAL)
2819                 erealloc(alist->a_string, char *, slen + 2, "append_statement");
2820         return alist;
2821
2822 #undef EVALSIZE
2823 }
2824
2825
2826 /* command names sorted in ascending order */
2827
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.") },
2888 #endif
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,
2914          NULL },
2915 };
2916
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 },
2933 };
2934
2935
2936 /* get_command --- return command handler function */
2937
2938 Func_cmd
2939 get_command(int ctype)
2940 {
2941         int i;
2942         for (i = 0; cmdtab[i].name != NULL; i++) {
2943                 if (cmdtab[i].type == ctype)
2944                         return cmdtab[i].cf_ptr;
2945         }
2946         return (Func_cmd) 0;
2947 }
2948
2949 /* get_command_name --- return command name given it's type */
2950
2951 const char *
2952 get_command_name(int ctype)
2953 {
2954         int i;
2955         for (i = 0; cmdtab[i].name != NULL; i++) {
2956                 if (cmdtab[i].type == ctype)
2957                         return cmdtab[i].name;
2958         }
2959         return NULL;
2960
2961
2962 /* mk_cmdarg --- make an argument for command */
2963
2964 static CMDARG *
2965 mk_cmdarg(enum argtype type)
2966 {
2967         CMDARG *arg;
2968         emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg");
2969         memset(arg, 0, sizeof(CMDARG));
2970         arg->type = type;
2971         return arg;
2972 }
2973
2974 /* append_cmdarg --- append ARG to the list of arguments for the current command */
2975  
2976 static void
2977 append_cmdarg(CMDARG *arg)
2978 {
2979         static CMDARG *savetail;
2980
2981         if (arg_list == NULL)
2982                 arg_list = arg;
2983         else
2984                 savetail->next = arg;
2985         savetail = arg;
2986 }
2987
2988 /* free_cmdarg --- free all arguments in LIST */
2989
2990 void
2991 free_cmdarg(CMDARG *list)
2992 {
2993         CMDARG *arg, *nexta;
2994
2995         for (arg = list; arg != NULL; arg = nexta) {
2996                 nexta = arg->next;
2997
2998                 switch (arg->type) {
2999                 case D_variable:
3000                 case D_subscript:
3001                 case D_array:
3002                 case D_string:
3003                         if (arg->a_string != NULL)
3004                                 efree(arg->a_string);
3005                         break;
3006                 case D_node:
3007                 case D_field:
3008                         unref(arg->a_node);
3009                         break;
3010                 default:
3011                         break;
3012                 }
3013                 efree(arg);
3014         }
3015 }
3016
3017 /* yyerror --- print a syntax error message */
3018
3019 static void
3020 yyerror(const char *mesg, ...)
3021 {
3022         va_list args;
3023         va_start(args, mesg);
3024         fprintf(out_fp, _("error: "));
3025         vfprintf(out_fp, mesg, args);
3026         fprintf(out_fp, "\n");
3027         va_end(args);
3028         errcount++;
3029         repeat_idx = -1;
3030 }
3031
3032
3033 /* yylex --- read a command and turn it into tokens */
3034
3035 static int
3036 yylex(void)
3037 {
3038         static char *lexptr = NULL;
3039         static char *lexend;
3040         int c;
3041         char *tokstart;
3042         size_t toklen; 
3043
3044         yylval = (CMDARG *) NULL;
3045
3046         if (errcount > 0 && lexptr_begin == NULL) {
3047                 /* fake a new line */
3048                 errcount = 0;
3049                 return '\n';
3050         }
3051
3052         if (lexptr_begin == NULL) {
3053 again:
3054                 lexptr_begin = read_a_line(dPrompt);
3055                 if (lexptr_begin == NULL) {     /* EOF or error */
3056                         if (get_eof_status() == EXIT_FATAL) 
3057                                 exit(EXIT_FATAL);
3058                         if (get_eof_status() == EXIT_FAILURE) {
3059                                 static int seen_eof = 0;
3060
3061                                 /* force a quit, and let do_quit (in debug.c) exit */
3062                                 if (! seen_eof) {
3063                                         if (errno != 0) {
3064                                                 fprintf(stderr, _("can't read command (%s)\n"), strerror(errno));
3065                                                 exit_val = EXIT_FAILURE;
3066                                         } /* else
3067                                                 exit_val = EXIT_SUCCESS; */
3068
3069                                         seen_eof = 1;
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 */
3074                                 } else
3075                                         return '\n';    /* end command 'quit' */
3076                         }
3077                         if (errno != 0)
3078                                 d_error(_("can't read command (%s)"), strerror(errno));
3079                         if (pop_cmd_src() == 0)
3080                                 goto again;
3081                         exit(EXIT_FATAL);       /* shouldn't happen */
3082                 }
3083
3084                 if (! in_commands && ! in_eval  /* history expansion off in 'commands' and 'eval' */
3085                                 && input_from_tty
3086                 )
3087                         history_expand_line(&lexptr_begin);
3088         
3089                 lexptr = lexptr_begin;
3090                 lexend = lexptr + strlen(lexptr);
3091                 if (*lexptr == '\0'             /* blank line */
3092                                 && repeat_idx >= 0
3093                                 && input_from_tty
3094                                 && ! in_eval
3095                 ) {
3096 #ifdef HAVE_LIBREADLINE
3097                         HIST_ENTRY *h;
3098                         h = previous_history();
3099                         if (h != NULL)
3100                                 add_history(h->line);
3101 #endif
3102                         cmd_idx = repeat_idx;
3103                         return cmdtab[cmd_idx].class;   /* repeat last command */
3104                 }
3105                 repeat_idx = -1;
3106         }
3107         
3108         c = *lexptr;
3109
3110         while (c == ' ' || c == '\t')
3111                 c = *++lexptr;
3112
3113         if (! input_from_tty && c == '#')
3114                 return '\n'; 
3115
3116         tokstart = lexptr;
3117         if (lexptr >= lexend)
3118                 return '\n';
3119
3120         if (cmd_idx < 0) {      /* need a command */
3121                 if (c == '?' && tokstart[1] == '\0'     && ! in_eval) {
3122                         lexptr++;
3123                         cmd_idx = find_command("help", 4);
3124                         return D_HELP;
3125                 }
3126
3127                 while (c != '\0' && c != ' ' && c != '\t') {
3128                         if (! isalpha(c) && ! in_eval) {
3129                                 yyerror(_("invalid character in command"));
3130                                 return '\n';
3131                         }
3132                         c = *++lexptr;
3133                 }
3134
3135                 toklen = lexptr - tokstart;
3136
3137                 if (in_eval) {
3138                         if (toklen == 3
3139                                         && tokstart[3] == '\0'
3140                                         && tokstart[0] == 'e'
3141                                         && tokstart[1] == 'n'
3142                                         && tokstart[2] == 'd'
3143                         ) {
3144                                 cmd_idx = find_command(tokstart, toklen);
3145                                 return D_END;
3146                         }
3147                         lexptr = lexend;
3148                         return D_STATEMENT;
3149                 }
3150
3151                 cmd_idx = find_command(tokstart, toklen);
3152                 if (cmd_idx >= 0) {
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).
3157                                  */
3158                                 CMDARG *arg;
3159                                 arg = mk_cmdarg(D_string);
3160                                 arg->a_string = estrdup(lexptr_begin, lexend - lexptr_begin);
3161                                 append_cmdarg(arg);
3162                         }
3163                         return cmdtab[cmd_idx].class;
3164                 } else {
3165                         yyerror(_("unknown command - \"%.*s\", try help"), toklen, tokstart);
3166                         return '\n';
3167                 }
3168         }
3169
3170         c = *lexptr;
3171         
3172         if (cmdtab[cmd_idx].type == D_option) {
3173                 if (c == '=')
3174                         return *lexptr++;
3175         } else if (c == '-' || c == '+' || c == ':' || c == '|')
3176                 return *lexptr++;
3177
3178         if (c == '"') {
3179                 char *str, *p;
3180                 int flags = ALREADY_MALLOCED;
3181                 int esc_seen = FALSE;
3182
3183                 toklen = lexend - lexptr;
3184                 emalloc(str, char *, toklen + 2, "yylex");
3185                 p = str;
3186
3187                 while ((c = *++lexptr) != '"') {
3188                         if (lexptr == lexend) {
3189 err:
3190                                 efree(str);
3191                                 yyerror(_("unterminated string"));
3192                                 return '\n';
3193                         }
3194                         if (c == '\\') {
3195                                 c = *++lexptr;
3196                                 esc_seen = TRUE;
3197                                 if (want_nodeval || c != '"')
3198                                         *p++ = '\\';
3199                         }
3200                         if (lexptr == lexend)
3201                                 goto err;
3202                         *p++ = c;
3203                 }
3204                 lexptr++;
3205                 *p = '\0';
3206
3207                 if (! want_nodeval) {
3208                         yylval = mk_cmdarg(D_string);
3209                         yylval->a_string = estrdup(str, p - str);
3210                         append_cmdarg(yylval);
3211                         return D_STRING;
3212                 } else {        /* awk string */
3213                         if (esc_seen)
3214                                 flags |= SCAN;
3215                         yylval = mk_cmdarg(D_node);
3216                         yylval->a_node = make_str_node(str, p - str, flags);
3217                         append_cmdarg(yylval);
3218                         return D_NODE;
3219                 }
3220         }
3221
3222         if (! want_nodeval) {
3223                 while ((c = *++lexptr) != '\0' && c != ':' && c != '-'
3224                                         && c != ' ' && c != '\t' && c != '=')
3225                         ;
3226
3227                 /* Is it an integer? */
3228                 if (isdigit((unsigned char) tokstart[0]) && cmdtab[cmd_idx].type != D_option) {
3229                         char *end;
3230                         long l;
3231
3232                         errno = 0;
3233                         l = strtol(tokstart, &end, 0);
3234                         if (errno != 0) {
3235                                 yyerror(_("%s"), strerror(errno));
3236                                 errno = 0;
3237                                 return '\n';
3238                         }
3239
3240                         if (lexptr == end) {
3241                                 yylval = mk_cmdarg(D_int);
3242                                 yylval->a_int = l;
3243                                 append_cmdarg(yylval);
3244                                 return D_INT;
3245                         }
3246                 }
3247
3248                 /* Must be string */
3249                 yylval = mk_cmdarg(D_string);
3250                 yylval->a_string = estrdup(tokstart, lexptr - tokstart);
3251                 append_cmdarg(yylval);
3252                 return D_STRING;
3253         }
3254
3255         /* assert(want_nodval == TRUE); */
3256
3257         /* look for awk number */
3258
3259         if (isdigit((unsigned char) tokstart[0])) {
3260                 double d;
3261
3262                 errno = 0;
3263                 d = strtod(tokstart, &lexptr);
3264                 if (errno != 0) {
3265                         yyerror(strerror(errno));
3266                         errno = 0;
3267                         return '\n';
3268                 }
3269                 yylval = mk_cmdarg(D_node);
3270                 yylval->a_node = make_number(d);
3271                 append_cmdarg(yylval);
3272                 return D_NODE;
3273         }
3274
3275         c = *lexptr;
3276         if (c == '$' || c == '@'
3277                         || c == '[' || c == ']'
3278                         || c == ',' || c == '=')
3279                 return *lexptr++;
3280
3281         if (c != '_' && ! isalpha(c)) {
3282                 yyerror(_("invalid character"));
3283                 return '\n';
3284         }
3285
3286         while (isalnum(c) || c == '_')
3287                 c = *++lexptr;
3288         toklen = lexptr - tokstart;
3289
3290         /* awk variable */
3291         yylval = mk_cmdarg(D_variable);
3292         yylval->a_string = estrdup(tokstart, toklen);
3293         append_cmdarg(yylval);
3294         return D_VARIABLE;
3295 }
3296
3297 /* find_argument --- find index in 'argtab' for a command option */
3298
3299 static int
3300 find_argument(CMDARG *arg)
3301 {
3302         /* non-number argument */
3303         int idx;
3304         char *name, *p;
3305         size_t len;
3306         assert(cmd_idx >= 0);
3307         name = arg->a_string;
3308         len = strlen(name);
3309         for (idx = 0; (p = (char *) argtab[idx].name) != NULL; idx++) {
3310                 if (cmdtab[cmd_idx].type == argtab[idx].cmd
3311                                 && *p == *name
3312                                 && strlen(p) == len
3313                                 && strncmp(p, name, len) == 0
3314                 )
3315                         return idx;
3316         }
3317         return -1;      /* invalid option */
3318 }
3319
3320 /* concat_args --- concatenate argument strings into a single string NODE */
3321
3322 static NODE *
3323 concat_args(CMDARG *arg, int count)
3324 {
3325         NODE *n;
3326         NODE **tmp;
3327         char *str, *subsep, *p;
3328         long len, subseplen;
3329         int i;
3330
3331         if (count == 1) {
3332                 n = force_string(arg->a_node);
3333                 return dupnode(n);
3334         }
3335         
3336         emalloc(tmp, NODE **, count * sizeof(NODE *), "concat_args");
3337         subseplen = SUBSEP_node->var_value->stlen;
3338         subsep = SUBSEP_node->var_value->stptr;
3339         len = -subseplen;
3340
3341         for (i = 0; i < count; i++) {
3342                 n = force_string(arg->a_node);
3343                 len += n->stlen + subseplen;
3344                 tmp[i] = n;
3345                 arg = arg->next;
3346         }
3347
3348         emalloc(str, char *, len + 2, "concat_args");
3349         n = tmp[0];
3350         memcpy(str, n->stptr, n->stlen);
3351         p = str + n->stlen;
3352         for (i = 1; i < count; i++) {
3353                 if (subseplen == 1)
3354                         *p++ = *subsep;
3355                 else if (subseplen > 0) {
3356                         memcpy(p, subsep, subseplen);
3357                         p += subseplen;
3358                 }
3359
3360                 n = tmp[i];
3361                 memcpy(p, n->stptr, n->stlen);
3362                 p += n->stlen;
3363         }
3364         str[len] = '\0';
3365         efree(tmp);
3366         return make_str_node(str, len, ALREADY_MALLOCED);
3367 }
3368
3369 /* find_command --- find the index in 'cmdtab' using exact,
3370  *                  abbreviation or unique partial match 
3371  */
3372
3373 static int
3374 find_command(const char *token, size_t toklen)
3375 {
3376         char *name, *abrv;
3377         int i, k;
3378         int try_exact = TRUE;
3379         int abrv_match = -1;
3380         int partial_match = -1;
3381
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)
3385          */
3386         for (i = 0; i < toklen; i++) {
3387                 if (token[i] != tolower(token[i]))
3388                         return -1;
3389         }
3390 #endif
3391
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
3398                 )
3399                         return i;
3400                 if (*name > *token)
3401                         try_exact = FALSE;
3402                 if (abrv_match < 0) {
3403                         abrv = cmdtab[i].abbrvn;
3404                         if (abrv[0] == token[0]) {
3405                                 if (toklen == 1 && ! abrv[1])
3406                                         abrv_match = i;
3407                                 else if (toklen == 2 && abrv[1] == token[1])
3408                                         abrv_match = i;
3409                         }
3410                 }
3411                 if (! try_exact && abrv_match >= 0)
3412                         return abrv_match;
3413                 if (partial_match < 0) {
3414                         if (*token == *name
3415                                         && toklen < strlen(name)
3416                                         && strncmp(name, token, toklen) == 0
3417                         ) {
3418                                 if ((i == k - 1 || strncmp(cmdtab[i + 1].name, token, toklen) != 0)
3419                                         && (i == 0 || strncmp(cmdtab[i - 1].name, token, toklen) != 0)
3420                                 )
3421                                         partial_match = i;
3422                         }
3423                 }
3424         }
3425         return partial_match;
3426 }
3427
3428 /* do_help -- help command */
3429
3430 int
3431 do_help(CMDARG *arg, int cmd)
3432 {
3433         int i;
3434         if (arg == NULL) {
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));
3440                         }
3441                 }
3442         } else if (arg->type == D_string) {
3443                 char *name;
3444                 name = arg->a_string;
3445                 i = find_command(name, strlen(name));
3446                 if (i >= 0) {
3447                         fprintf(out_fp, "%s\n", cmdtab[i].help_txt);
3448                         if (strcmp(cmdtab[i].name, "option") == 0)
3449                                 option_help();
3450                 } else
3451                         fprintf(out_fp, _("undefined command: %s\n"), name);
3452         }
3453
3454         return FALSE;
3455 }
3456
3457
3458 /* next_word --- find the next word in a line to complete 
3459  *               (word seperation characters are space and tab).
3460  */
3461    
3462 static char *
3463 next_word(char *p, int len, char **endp)
3464 {
3465         char *q;
3466         int i;
3467
3468         if (p == NULL || len <= 0)
3469                 return NULL;
3470         for (i = 0; i < len; i++, p++)
3471                 if (*p != ' ' && *p != '\t')
3472                         break;
3473         if (i == len)
3474                 return NULL;
3475         if (endp != NULL) {
3476                 for (i++, q = p + 1; i < len; i++, q++)
3477                         if (*q == ' ' || *q == '\t')
3478                                 break;
3479                 *endp = q;
3480         }
3481         return p;
3482 }
3483
3484 #ifdef HAVE_LIBREADLINE
3485
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).
3489  */
3490
3491 #ifndef RL_READLINE_VERSION             /* < 4.2a */
3492 #define rl_completion_matches(x, y) completion_matches((char *) (x), (y))
3493 #endif
3494
3495
3496 char **
3497 command_completion(const char *text, int start, int end)
3498 {
3499         char *cmdtok, *e;
3500         int idx;
3501         int len;
3502
3503         rl_attempted_completion_over = TRUE;    /* no default filename completion please */
3504
3505         this_cmd = D_illegal;
3506         len = start;
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);
3510
3511         idx = find_command(cmdtok, e - cmdtok);
3512         if (idx < 0)
3513                 return NULL;
3514         this_cmd = cmdtab[idx].type;
3515
3516         if (! next_word(e, len, NULL)) {
3517                 switch (this_cmd) {
3518                 case D_break:
3519                 case D_list:
3520                 case D_until:
3521                 case D_tbreak:
3522                 case D_clear:
3523                         return rl_completion_matches(text, srcfile_generator);
3524                 case D_info:
3525                 case D_enable:
3526                 case D_trace:
3527                 case D_help:
3528                         return rl_completion_matches(text, argument_generator);
3529                 case D_option:
3530                         return rl_completion_matches(text, option_generator);
3531                 case D_print:
3532                 case D_printf:
3533                 case D_set:
3534                 case D_display:
3535                 case D_watch:
3536                         return rl_completion_matches(text, variable_generator);
3537                 default:
3538                         return NULL;
3539                 }
3540         }
3541         if (this_cmd == D_print || this_cmd == D_printf)
3542                 return rl_completion_matches(text, variable_generator);
3543         return NULL;
3544 }       
3545
3546 /* command_generator --- generator function for command completion */
3547  
3548 static char *
3549 command_generator(const char *text, int state)
3550 {
3551         static size_t textlen;
3552         static int idx = 0;
3553         char *name;
3554
3555         if (! state) {  /* first time */
3556                 textlen = strlen(text);
3557                 idx = 0;
3558         }
3559         while ((name = (char *) cmdtab[idx].name) != NULL) {
3560                 idx++;
3561                 if (strncmp(name, text, textlen) == 0)
3562                         return estrdup(name, strlen(name));
3563         }
3564         return NULL;
3565 }
3566
3567 /* srcfile_generator --- generator function for source file completion */
3568
3569 static char *
3570 srcfile_generator(const char *text, int state)
3571 {
3572         static size_t textlen;
3573         static SRCFILE *s;
3574         char *name;
3575         extern SRCFILE *srcfiles;
3576
3577         if (! state) {  /* first time */
3578                 textlen = strlen(text);
3579                 s = srcfiles->next;
3580         }
3581         while (s != srcfiles) {
3582                 if (s->stype != SRC_FILE && s->stype != SRC_INC) {
3583                         s = s->next;
3584                         continue;
3585                 }
3586                 name = s->src;
3587                 s = s->next;
3588                 if (strncmp(name, text, textlen) == 0)
3589                         return estrdup(name, strlen(name));
3590         }
3591         return NULL;
3592 }
3593
3594 /* argument_generator --- generator function for non-number argument completion */
3595
3596 static char *
3597 argument_generator(const char *text, int state)
3598 {
3599         static size_t textlen;
3600         static int idx;
3601         char *name;
3602
3603         if (! state) {  /* first time */
3604                 textlen = strlen(text);
3605                 idx = 0;
3606         }
3607
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));
3612                 }
3613         } else {
3614                 while ((name = (char *) argtab[idx].name) != NULL) {
3615                         if (this_cmd != argtab[idx++].cmd)
3616                                 continue;
3617                         if (strncmp(name, text, textlen) == 0)
3618                                 return estrdup(name, strlen(name));
3619                 }
3620         }               
3621         return NULL;
3622 }
3623
3624 /* variable_generator --- generator function for variable name completion */
3625
3626 static char *
3627 variable_generator(const char *text, int state)
3628 {
3629         static size_t textlen;
3630         static int idx = 0;
3631         static char **pnames = NULL;
3632         static NODE **var_table = NULL;
3633         char *name;
3634         NODE *hp;
3635
3636         if (! state) {  /* first time */
3637                 textlen = strlen(text);
3638                 if (var_table != NULL)
3639                         efree(var_table);
3640                 var_table = get_varlist();
3641                 idx = 0;
3642                 pnames = get_parmlist();  /* names of function params in
3643                                            * current context; the array
3644                                            * is NULL terminated in
3645                                            * awkgram.y (func_install).
3646                                            */
3647         }
3648
3649         /* function params */
3650         while (pnames != NULL) {
3651                 name = pnames[idx];
3652                 if (name == NULL) {
3653                         pnames = NULL;  /* don't try to match params again */
3654                         idx = 0;
3655                         break;
3656                 }
3657                 idx++;
3658                 if (strncmp(name, text, textlen) == 0)
3659                         return estrdup(name, strlen(name));
3660         }
3661
3662         /* globals */
3663         while ((hp = var_table[idx]) != NULL) {
3664                 idx++;
3665                 if (hp->hvalue->type == Node_func)
3666                         continue;
3667                 if (strncmp(hp->hname, text, textlen) == 0)
3668                         return estrdup(hp->hname, hp->hlength);
3669         }
3670         return NULL;
3671 }
3672
3673 /* history_expand_line ---  history expand the LINE */
3674
3675 static void
3676 history_expand_line(char **line)
3677 {
3678         int ret;
3679         char *expansion;
3680
3681         if (! *line || input_fd != 0 || ! input_from_tty)
3682                 return;
3683         using_history();
3684         ret = history_expand(*line, &expansion);
3685         if (ret < 0 || ret == 2)
3686                 efree(expansion);
3687         else {
3688                 efree(*line);
3689                 *line = expansion;
3690         }
3691 }
3692
3693 #endif
3694
3695