~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to awkgram.c

  • Committer: Arnold D. Robbins
  • Date: 2010-07-16 11:47:02 UTC
  • Revision ID: git-v1:315bd501ca696bc3e3c938b4604d8dac7a6f512f
Tags: gawk-3.1.5
Move to gawk 3.1.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* A Bison parser, made by GNU Bison 1.875.  */
 
1
/* A Bison parser, made by GNU Bison 2.0.  */
2
2
 
3
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
 
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
 
4
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
256
256
        char *sval;
257
257
        NODE *(*ptrval) P((void));
258
258
} YYSTYPE;
259
 
/* Line 191 of yacc.c.  */
260
 
#line 260 "y.tab.c"
 
259
/* Line 190 of yacc.c.  */
 
260
#line 261 "y.tab.c"
261
261
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
262
262
# define YYSTYPE_IS_DECLARED 1
263
263
# define YYSTYPE_IS_TRIVIAL 1
268
268
/* Copy the second part of user declarations.  */
269
269
 
270
270
 
271
 
/* Line 214 of yacc.c.  */
272
 
#line 272 "y.tab.c"
 
271
/* Line 213 of yacc.c.  */
 
272
#line 273 "y.tab.c"
273
273
 
274
274
#if ! defined (yyoverflow) || YYERROR_VERBOSE
275
275
 
 
276
# ifndef YYFREE
 
277
#  define YYFREE free
 
278
# endif
 
279
# ifndef YYMALLOC
 
280
#  define YYMALLOC malloc
 
281
# endif
 
282
 
276
283
/* The parser invokes alloca or malloc; define the necessary symbols.  */
277
284
 
278
 
#undef YYSTACK_USE_ALLOCA       /* Gawk: nuke alloca once and for all */
279
 
 
280
 
# if YYSTACK_USE_ALLOCA
281
 
#  define YYSTACK_ALLOC alloca
282
 
# else
283
 
#  ifndef YYSTACK_USE_ALLOCA
284
 
#   if defined (alloca) || defined (_ALLOCA_H)
 
285
# ifdef YYSTACK_USE_ALLOCA
 
286
#  if YYSTACK_USE_ALLOCA
 
287
#   ifdef __GNUC__
 
288
#    define YYSTACK_ALLOC __builtin_alloca
 
289
#   else
285
290
#    define YYSTACK_ALLOC alloca
286
 
#   else
287
 
#    ifdef __GNUC__
288
 
#     define YYSTACK_ALLOC __builtin_alloca
289
 
#    endif
290
291
#   endif
291
292
#  endif
292
293
# endif
299
300
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
300
301
#   define YYSIZE_T size_t
301
302
#  endif
302
 
#  define YYSTACK_ALLOC malloc
303
 
#  define YYSTACK_FREE free
 
303
#  define YYSTACK_ALLOC YYMALLOC
 
304
#  define YYSTACK_FREE YYFREE
304
305
# endif
305
306
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
306
307
 
307
308
 
308
 
#if (! defined (yyoverflow) \
309
 
     && (! defined (__cplusplus) \
310
 
         || (YYSTYPE_IS_TRIVIAL)))
 
309
#if (! defined (yyoverflow)      && (! defined (__cplusplus)     || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
311
310
 
312
311
/* A type that is properly aligned for any stack member.  */
313
312
union yyalloc
314
313
{
315
 
  short yyss;
 
314
  short int yyss;
316
315
  YYSTYPE yyvs;
317
316
  };
318
317
 
322
321
/* The size of an array large to enough to hold all stacks, each with
323
322
   N elements.  */
324
323
# define YYSTACK_BYTES(N) \
325
 
     ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
 
324
     ((N) * (sizeof (short int) + sizeof (YYSTYPE))                     \
326
325
      + YYSTACK_GAP_MAXIMUM)
327
326
 
328
327
/* Copy COUNT objects from FROM to TO.  The source and destination do
329
328
   not overlap.  */
330
329
# ifndef YYCOPY
331
 
#  if 1 < __GNUC__
 
330
#  if defined (__GNUC__) && 1 < __GNUC__
332
331
#   define YYCOPY(To, From, Count) \
333
332
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
334
333
#  else
364
363
#if defined (__STDC__) || defined (__cplusplus)
365
364
   typedef signed char yysigned_char;
366
365
#else
367
 
   typedef short yysigned_char;
 
366
   typedef short int yysigned_char;
368
367
#endif
369
368
 
370
369
/* YYFINAL -- State number of the termination state. */
427
426
#if YYDEBUG
428
427
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
429
428
   YYRHS.  */
430
 
static const unsigned short yyprhs[] =
 
429
static const unsigned short int yyprhs[] =
431
430
{
432
431
       0,     0,     3,     7,     8,    11,    14,    17,    20,    23,
433
432
      24,    26,    30,    32,    34,    40,    42,    44,    46,    48,
503
502
};
504
503
 
505
504
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
506
 
static const unsigned short yyrline[] =
 
505
static const unsigned short int yyrline[] =
507
506
{
508
507
       0,   171,   171,   177,   179,   184,   196,   200,   215,   226,
509
508
     229,   233,   243,   248,   256,   261,   263,   265,   276,   277,
510
 
     282,   281,   305,   304,   328,   329,   334,   335,   353,   358,
511
 
     359,   363,   365,   367,   369,   371,   373,   375,   417,   421,
512
 
     426,   429,   432,   441,   461,   464,   463,   473,   485,   485,
513
 
     516,   518,   532,   547,   553,   554,   559,   612,   613,   630,
514
 
     635,   637,   642,   644,   649,   651,   653,   658,   659,   667,
515
 
     668,   674,   679,   679,   691,   696,   703,   704,   707,   709,
516
 
     714,   715,   721,   722,   727,   729,   731,   733,   735,   742,
517
 
     743,   749,   750,   755,   757,   763,   765,   767,   769,   774,
518
 
     793,   795,   797,   803,   805,   811,   813,   818,   820,   822,
519
 
     827,   829,   833,   834,   839,   841,   849,   851,   853,   858,
520
 
     860,   862,   864,   866,   868,   870,   872,   878,   883,   885,
521
 
     890,   892,   894,   897,   899,   907,   915,   916,   918,   920,
522
 
     922,   925,   933,   945,   946,   951,   953,   967,   972,   976,
523
 
     980,   983,   985,   989,   993,   996
 
509
     282,   281,   305,   304,   330,   331,   336,   337,   355,   360,
 
510
     361,   365,   367,   369,   371,   373,   375,   377,   421,   425,
 
511
     430,   433,   436,   445,   465,   468,   467,   477,   489,   489,
 
512
     520,   522,   536,   551,   557,   558,   563,   616,   617,   634,
 
513
     639,   641,   646,   648,   653,   655,   657,   662,   663,   671,
 
514
     672,   678,   683,   683,   695,   700,   707,   708,   711,   713,
 
515
     718,   719,   725,   726,   731,   733,   735,   737,   739,   746,
 
516
     747,   753,   754,   759,   761,   767,   769,   771,   773,   778,
 
517
     797,   799,   801,   807,   809,   815,   817,   822,   824,   826,
 
518
     831,   833,   837,   838,   843,   845,   853,   855,   857,   862,
 
519
     864,   866,   868,   870,   872,   874,   876,   882,   887,   889,
 
520
     894,   896,   898,   901,   903,   911,   919,   920,   922,   924,
 
521
     926,   929,   937,   949,   950,   955,   957,   971,   982,   986,
 
522
     990,   993,   995,   999,  1003,  1006
524
523
};
525
524
#endif
526
525
 
529
528
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
530
529
static const char *const yytname[] =
531
530
{
532
 
  "$end", "error", "$undefined", "FUNC_CALL", "NAME", "REGEXP", "ERROR", 
533
 
  "YNUMBER", "YSTRING", "RELOP", "IO_OUT", "IO_IN", "ASSIGNOP", "ASSIGN", 
534
 
  "MATCHOP", "CONCAT_OP", "LEX_BEGIN", "LEX_END", "LEX_IF", "LEX_ELSE", 
535
 
  "LEX_RETURN", "LEX_DELETE", "LEX_SWITCH", "LEX_CASE", "LEX_DEFAULT", 
536
 
  "LEX_WHILE", "LEX_DO", "LEX_FOR", "LEX_BREAK", "LEX_CONTINUE", 
537
 
  "LEX_PRINT", "LEX_PRINTF", "LEX_NEXT", "LEX_EXIT", "LEX_FUNCTION", 
538
 
  "LEX_GETLINE", "LEX_NEXTFILE", "LEX_IN", "LEX_AND", "LEX_OR", 
539
 
  "INCREMENT", "DECREMENT", "LEX_BUILTIN", "LEX_LENGTH", "NEWLINE", 
540
 
  "SLASH_BEFORE_EQUAL", "'?'", "':'", "','", "'<'", "'>'", "'+'", "'-'", 
541
 
  "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", "'('", "')'", "'['", 
542
 
  "']'", "'{'", "'}'", "';'", "$accept", "start", "program", "rule", 
543
 
  "pattern", "action", "func_name", "lex_builtin", "function_prologue", 
544
 
  "@1", "regexp", "@2", "a_slash", "statements", "statement_term", 
545
 
  "statement", "@3", "simple_stmt", "@4", "opt_simple_stmt", 
546
 
  "switch_body", "case_statements", "case_statement", "case_value", 
547
 
  "print", "print_expression_list", "output_redir", "@5", "if_statement", 
548
 
  "nls", "opt_nls", "input_redir", "opt_param_list", "param_list", 
549
 
  "opt_exp", "opt_expression_list", "expression_list", "exp", 
550
 
  "assign_operator", "relop_or_less", "a_relop", "common_exp", "simp_exp", 
551
 
  "non_post_simp_exp", "opt_variable", "variable", "l_brace", "r_brace", 
 
531
  "$end", "error", "$undefined", "FUNC_CALL", "NAME", "REGEXP", "ERROR",
 
532
  "YNUMBER", "YSTRING", "RELOP", "IO_OUT", "IO_IN", "ASSIGNOP", "ASSIGN",
 
533
  "MATCHOP", "CONCAT_OP", "LEX_BEGIN", "LEX_END", "LEX_IF", "LEX_ELSE",
 
534
  "LEX_RETURN", "LEX_DELETE", "LEX_SWITCH", "LEX_CASE", "LEX_DEFAULT",
 
535
  "LEX_WHILE", "LEX_DO", "LEX_FOR", "LEX_BREAK", "LEX_CONTINUE",
 
536
  "LEX_PRINT", "LEX_PRINTF", "LEX_NEXT", "LEX_EXIT", "LEX_FUNCTION",
 
537
  "LEX_GETLINE", "LEX_NEXTFILE", "LEX_IN", "LEX_AND", "LEX_OR",
 
538
  "INCREMENT", "DECREMENT", "LEX_BUILTIN", "LEX_LENGTH", "NEWLINE",
 
539
  "SLASH_BEFORE_EQUAL", "'?'", "':'", "','", "'<'", "'>'", "'+'", "'-'",
 
540
  "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", "'('", "')'", "'['",
 
541
  "']'", "'{'", "'}'", "';'", "$accept", "start", "program", "rule",
 
542
  "pattern", "action", "func_name", "lex_builtin", "function_prologue",
 
543
  "@1", "regexp", "@2", "a_slash", "statements", "statement_term",
 
544
  "statement", "@3", "simple_stmt", "@4", "opt_simple_stmt", "switch_body",
 
545
  "case_statements", "case_statement", "case_value", "print",
 
546
  "print_expression_list", "output_redir", "@5", "if_statement", "nls",
 
547
  "opt_nls", "input_redir", "opt_param_list", "param_list", "opt_exp",
 
548
  "opt_expression_list", "expression_list", "exp", "assign_operator",
 
549
  "relop_or_less", "a_relop", "common_exp", "simp_exp",
 
550
  "non_post_simp_exp", "opt_variable", "variable", "l_brace", "r_brace",
552
551
  "r_paren", "opt_semi", "semi", "colon", "comma", 0
553
552
};
554
553
#endif
556
555
# ifdef YYPRINT
557
556
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
558
557
   token YYLEX-NUM.  */
559
 
static const unsigned short yytoknum[] =
 
558
static const unsigned short int yytoknum[] =
560
559
{
561
560
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
562
561
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
648
647
};
649
648
 
650
649
/* YYDEFGOTO[NTERM-NUM]. */
651
 
static const short yydefgoto[] =
 
650
static const short int yydefgoto[] =
652
651
{
653
652
      -1,     2,     7,    28,    29,    62,   102,   103,    30,    41,
654
653
      31,    68,    32,   116,    63,   162,   178,   163,   193,   211,
661
660
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
662
661
   STATE-NUM.  */
663
662
#define YYPACT_NINF -236
664
 
static const short yypact[] =
 
663
static const short int yypact[] =
665
664
{
666
665
     -15,  -236,    31,    -3,  -236,  -236,  -236,   292,  -236,    -8,
667
666
      -2,  -236,  -236,  -236,  -236,  -236,    26,    26,    26,     4,
696
695
};
697
696
 
698
697
/* YYPGOTO[NTERM-NUM].  */
699
 
static const short yypgoto[] =
 
698
static const short int yypgoto[] =
700
699
{
701
700
    -236,  -236,  -236,  -236,  -236,   165,  -236,  -236,  -236,  -236,
702
701
     -24,  -236,  -236,  -150,   152,  -178,  -236,  -165,  -236,  -235,
711
710
   number is the opposite.  If zero, do what YYDEFACT says.
712
711
   If YYTABLE_NINF, syntax error.  */
713
712
#define YYTABLE_NINF -93
714
 
static const short yytable[] =
 
713
static const short int yytable[] =
715
714
{
716
715
      33,    53,    43,    44,    45,   208,   179,    64,    51,    51,
717
716
      58,    51,    56,   216,   106,   107,   -93,   194,   109,   210,
816
815
       0,     0,     0,     0,    74,     0,     0,    76,    77
817
816
};
818
817
 
819
 
static const short yycheck[] =
 
818
static const short int yycheck[] =
820
819
{
821
820
       7,    25,    16,    17,    18,   183,     4,    29,    22,    23,
822
821
      27,    25,    26,   194,    46,    47,     9,   167,     1,   184,
980
979
 
981
980
#define YYACCEPT        goto yyacceptlab
982
981
#define YYABORT         goto yyabortlab
983
 
#define YYERROR         goto yyerrlab1
 
982
#define YYERROR         goto yyerrorlab
 
983
 
984
984
 
985
985
/* Like YYERROR except do call yyerror.  This remains here temporarily
986
986
   to ease the transition to the new meaning of YYERROR, for GCC.
1007
1007
    }                                                           \
1008
1008
while (0)
1009
1009
 
 
1010
 
1010
1011
#define YYTERROR        1
1011
1012
#define YYERRCODE       256
1012
1013
 
1013
 
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
1014
 
   are run).  */
1015
 
 
 
1014
 
 
1015
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
 
1016
   If N is 0, then set CURRENT to the empty location which ends
 
1017
   the previous symbol: RHS[0] (always defined).  */
 
1018
 
 
1019
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1016
1020
#ifndef YYLLOC_DEFAULT
1017
 
# define YYLLOC_DEFAULT(Current, Rhs, N)         \
1018
 
  Current.first_line   = Rhs[1].first_line;      \
1019
 
  Current.first_column = Rhs[1].first_column;    \
1020
 
  Current.last_line    = Rhs[N].last_line;       \
1021
 
  Current.last_column  = Rhs[N].last_column;
1022
 
#endif
 
1021
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
1022
    do                                                                  \
 
1023
      if (N)                                                            \
 
1024
        {                                                               \
 
1025
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 
1026
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 
1027
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 
1028
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 
1029
        }                                                               \
 
1030
      else                                                              \
 
1031
        {                                                               \
 
1032
          (Current).first_line   = (Current).last_line   =              \
 
1033
            YYRHSLOC (Rhs, 0).last_line;                                \
 
1034
          (Current).first_column = (Current).last_column =              \
 
1035
            YYRHSLOC (Rhs, 0).last_column;                              \
 
1036
        }                                                               \
 
1037
    while (0)
 
1038
#endif
 
1039
 
 
1040
 
 
1041
/* YY_LOCATION_PRINT -- Print the location on the stream.
 
1042
   This macro was not mandated originally: define only if we know
 
1043
   we won't break user code: when these are the locations we know.  */
 
1044
 
 
1045
#ifndef YY_LOCATION_PRINT
 
1046
# if YYLTYPE_IS_TRIVIAL
 
1047
#  define YY_LOCATION_PRINT(File, Loc)                  \
 
1048
     fprintf (File, "%d.%d-%d.%d",                      \
 
1049
              (Loc).first_line, (Loc).first_column,     \
 
1050
              (Loc).last_line,  (Loc).last_column)
 
1051
# else
 
1052
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 
1053
# endif
 
1054
#endif
 
1055
 
1023
1056
 
1024
1057
/* YYLEX -- calling `yylex' with the right arguments.  */
1025
1058
 
1043
1076
    YYFPRINTF Args;                             \
1044
1077
} while (0)
1045
1078
 
1046
 
# define YYDSYMPRINT(Args)                      \
1047
 
do {                                            \
1048
 
  if (yydebug)                                  \
1049
 
    yysymprint Args;                            \
1050
 
} while (0)
1051
 
 
1052
 
# define YYDSYMPRINTF(Title, Token, Value, Location)            \
 
1079
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)          \
1053
1080
do {                                                            \
1054
1081
  if (yydebug)                                                  \
1055
1082
    {                                                           \
1056
1083
      YYFPRINTF (stderr, "%s ", Title);                         \
1057
1084
      yysymprint (stderr,                                       \
1058
 
                  Token, Value);        \
 
1085
                  Type, Value); \
1059
1086
      YYFPRINTF (stderr, "\n");                                 \
1060
1087
    }                                                           \
1061
1088
} while (0)
1062
1089
 
1063
1090
/*------------------------------------------------------------------.
1064
1091
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1065
 
| TOP (cinluded).                                                   |
 
1092
| TOP (included).                                                   |
1066
1093
`------------------------------------------------------------------*/
1067
1094
 
1068
1095
#if defined (__STDC__) || defined (__cplusplus)
1069
1096
static void
1070
 
yy_stack_print (short *bottom, short *top)
 
1097
yy_stack_print (short int *bottom, short int *top)
1071
1098
#else
1072
1099
static void
1073
1100
yy_stack_print (bottom, top)
1074
 
    short *bottom;
1075
 
    short *top;
 
1101
    short int *bottom;
 
1102
    short int *top;
1076
1103
#endif
1077
1104
{
1078
1105
  YYFPRINTF (stderr, "Stack now");
1102
1129
#endif
1103
1130
{
1104
1131
  int yyi;
1105
 
  unsigned int yylineno = yyrline[yyrule];
 
1132
  unsigned int yylno = yyrline[yyrule];
1106
1133
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1107
 
             yyrule - 1, yylineno);
 
1134
             yyrule - 1, yylno);
1108
1135
  /* Print the symbols being reduced, and their result.  */
1109
1136
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1110
1137
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1122
1149
int yydebug;
1123
1150
#else /* !YYDEBUG */
1124
1151
# define YYDPRINTF(Args)
1125
 
# define YYDSYMPRINT(Args)
1126
 
# define YYDSYMPRINTF(Title, Token, Value, Location)
 
1152
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1127
1153
# define YY_STACK_PRINT(Bottom, Top)
1128
1154
# define YY_REDUCE_PRINT(Rule)
1129
1155
#endif /* !YYDEBUG */
1141
1167
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
1142
1168
   evaluated with infinite-precision integer arithmetic.  */
1143
1169
 
1144
 
#if YYMAXDEPTH == 0
1145
 
# undef YYMAXDEPTH
1146
 
#endif
1147
 
 
1148
1170
#ifndef YYMAXDEPTH
1149
1171
# define YYMAXDEPTH 10000
1150
1172
#endif
1226
1248
  (void) yyvaluep;
1227
1249
 
1228
1250
  if (yytype < YYNTOKENS)
1229
 
    {
1230
 
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1231
 
# ifdef YYPRINT
1232
 
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1233
 
# endif
1234
 
    }
 
1251
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1235
1252
  else
1236
1253
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1237
1254
 
 
1255
 
 
1256
# ifdef YYPRINT
 
1257
  if (yytype < YYNTOKENS)
 
1258
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 
1259
# endif
1238
1260
  switch (yytype)
1239
1261
    {
1240
1262
      default:
1250
1272
 
1251
1273
#if defined (__STDC__) || defined (__cplusplus)
1252
1274
static void
1253
 
yydestruct (int yytype, YYSTYPE *yyvaluep)
 
1275
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1254
1276
#else
1255
1277
static void
1256
 
yydestruct (yytype, yyvaluep)
 
1278
yydestruct (yymsg, yytype, yyvaluep)
 
1279
    const char *yymsg;
1257
1280
    int yytype;
1258
1281
    YYSTYPE *yyvaluep;
1259
1282
#endif
1261
1284
  /* Pacify ``unused variable'' warnings.  */
1262
1285
  (void) yyvaluep;
1263
1286
 
 
1287
  if (!yymsg)
 
1288
    yymsg = "Deleting";
 
1289
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 
1290
 
1264
1291
  switch (yytype)
1265
1292
    {
1266
1293
 
1288
1315
 
1289
1316
 
1290
1317
 
1291
 
/* The lookahead symbol.  */
 
1318
/* The look-ahead symbol.  */
1292
1319
int yychar;
1293
1320
 
1294
 
/* The semantic value of the lookahead symbol.  */
 
1321
/* The semantic value of the look-ahead symbol.  */
1295
1322
YYSTYPE yylval;
1296
1323
 
1297
1324
/* Number of syntax errors so far.  */
1327
1354
  int yyresult;
1328
1355
  /* Number of tokens to shift before error messages enabled.  */
1329
1356
  int yyerrstatus;
1330
 
  /* Lookahead token as an internal (translated) token number.  */
 
1357
  /* Look-ahead token as an internal (translated) token number.  */
1331
1358
  int yytoken = 0;
1332
1359
 
1333
1360
  /* Three stacks and their tools:
1339
1366
     to reallocate them elsewhere.  */
1340
1367
 
1341
1368
  /* The state stack.  */
1342
 
  short yyssa[YYINITDEPTH];
1343
 
  short *yyss = yyssa;
1344
 
  register short *yyssp;
 
1369
  short int yyssa[YYINITDEPTH];
 
1370
  short int *yyss = yyssa;
 
1371
  register short int *yyssp;
1345
1372
 
1346
1373
  /* The semantic value stack.  */
1347
1374
  YYSTYPE yyvsa[YYINITDEPTH];
1378
1405
  yyssp = yyss;
1379
1406
  yyvsp = yyvs;
1380
1407
 
 
1408
 
 
1409
  yyvsp[0] = yylval;
 
1410
 
1381
1411
  goto yysetstate;
1382
1412
 
1383
1413
/*------------------------------------------------------------.
1403
1433
           these so that the &'s don't force the real ones into
1404
1434
           memory.  */
1405
1435
        YYSTYPE *yyvs1 = yyvs;
1406
 
        short *yyss1 = yyss;
 
1436
        short int *yyss1 = yyss;
1407
1437
 
1408
1438
 
1409
1439
        /* Each stack pointer address is followed by the size of the
1431
1461
        yystacksize = YYMAXDEPTH;
1432
1462
 
1433
1463
      {
1434
 
        short *yyss1 = yyss;
 
1464
        short int *yyss1 = yyss;
1435
1465
        union yyalloc *yyptr =
1436
1466
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1437
1467
        if (! yyptr)
1467
1497
yybackup:
1468
1498
 
1469
1499
/* Do appropriate processing given the current state.  */
1470
 
/* Read a lookahead token if we need one and don't already have one.  */
 
1500
/* Read a look-ahead token if we need one and don't already have one.  */
1471
1501
/* yyresume: */
1472
1502
 
1473
 
  /* First try to decide what to do without reference to lookahead token.  */
 
1503
  /* First try to decide what to do without reference to look-ahead token.  */
1474
1504
 
1475
1505
  yyn = yypact[yystate];
1476
1506
  if (yyn == YYPACT_NINF)
1477
1507
    goto yydefault;
1478
1508
 
1479
 
  /* Not known => get a lookahead token if don't already have one.  */
 
1509
  /* Not known => get a look-ahead token if don't already have one.  */
1480
1510
 
1481
 
  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
 
1511
  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1482
1512
  if (yychar == YYEMPTY)
1483
1513
    {
1484
1514
      YYDPRINTF ((stderr, "Reading a token: "));
1493
1523
  else
1494
1524
    {
1495
1525
      yytoken = YYTRANSLATE (yychar);
1496
 
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
 
1526
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1497
1527
    }
1498
1528
 
1499
1529
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1513
1543
  if (yyn == YYFINAL)
1514
1544
    YYACCEPT;
1515
1545
 
1516
 
  /* Shift the lookahead token.  */
1517
 
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
 
1546
  /* Shift the look-ahead token.  */
 
1547
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1518
1548
 
1519
1549
  /* Discard the token being shifted unless it is eof.  */
1520
1550
  if (yychar != YYEOF)
1593
1623
  case 6:
1594
1624
#line 197 "awkgram.y"
1595
1625
    {
1596
 
                yyvsp[-1].nodeval->rnode = yyvsp[0].nodeval;
 
1626
                (yyvsp[-1].nodeval)->rnode = (yyvsp[0].nodeval);
1597
1627
          }
1598
1628
    break;
1599
1629
 
1600
1630
  case 7:
1601
1631
#line 201 "awkgram.y"
1602
1632
    {
1603
 
                if (yyvsp[-1].nodeval->lnode != NULL) {
 
1633
                if ((yyvsp[-1].nodeval)->lnode != NULL) {
1604
1634
                        /* pattern rule with non-empty pattern */
1605
 
                        yyvsp[-1].nodeval->rnode = node(NULL, Node_K_print_rec, NULL);
 
1635
                        (yyvsp[-1].nodeval)->rnode = node(NULL, Node_K_print_rec, NULL);
1606
1636
                } else {
1607
1637
                        /* an error */
1608
1638
                        if (begin_or_end_rule)
1619
1649
#line 216 "awkgram.y"
1620
1650
    {
1621
1651
                can_return = FALSE;
1622
 
                if (yyvsp[-1].nodeval)
1623
 
                        func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
 
1652
                if ((yyvsp[-1].nodeval))
 
1653
                        func_install((yyvsp[-1].nodeval), (yyvsp[0].nodeval));
1624
1654
                yyerrok;
1625
1655
          }
1626
1656
    break;
1628
1658
  case 9:
1629
1659
#line 226 "awkgram.y"
1630
1660
    {
1631
 
                yyval.nodeval = append_pattern(&expression_value, (NODE *) NULL);
 
1661
                (yyval.nodeval) = append_pattern(&expression_value, (NODE *) NULL);
1632
1662
          }
1633
1663
    break;
1634
1664
 
1635
1665
  case 10:
1636
1666
#line 230 "awkgram.y"
1637
1667
    {
1638
 
                yyval.nodeval = append_pattern(&expression_value, yyvsp[0].nodeval);
 
1668
                (yyval.nodeval) = append_pattern(&expression_value, (yyvsp[0].nodeval));
1639
1669
          }
1640
1670
    break;
1641
1671
 
1646
1676
 
1647
1677
                getnode(r);
1648
1678
                r->type = Node_line_range;
1649
 
                r->condpair = node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval);
 
1679
                r->condpair = node((yyvsp[-2].nodeval), Node_cond_pair, (yyvsp[0].nodeval));
1650
1680
                r->triggered = FALSE;
1651
 
                yyval.nodeval = append_pattern(&expression_value, r);
 
1681
                (yyval.nodeval) = append_pattern(&expression_value, r);
1652
1682
          }
1653
1683
    break;
1654
1684
 
1656
1686
#line 244 "awkgram.y"
1657
1687
    {
1658
1688
                begin_or_end_rule = TRUE;
1659
 
                yyval.nodeval = append_pattern(&begin_block, (NODE *) NULL);
 
1689
                (yyval.nodeval) = append_pattern(&begin_block, (NODE *) NULL);
1660
1690
          }
1661
1691
    break;
1662
1692
 
1664
1694
#line 249 "awkgram.y"
1665
1695
    {
1666
1696
                begin_or_end_rule = parsing_end_rule = TRUE;
1667
 
                yyval.nodeval = append_pattern(&end_block, (NODE *) NULL);
 
1697
                (yyval.nodeval) = append_pattern(&end_block, (NODE *) NULL);
1668
1698
          }
1669
1699
    break;
1670
1700
 
1671
1701
  case 14:
1672
1702
#line 257 "awkgram.y"
1673
 
    { yyval.nodeval = yyvsp[-3].nodeval; }
 
1703
    { (yyval.nodeval) = (yyvsp[-3].nodeval); }
1674
1704
    break;
1675
1705
 
1676
1706
  case 15:
1677
1707
#line 262 "awkgram.y"
1678
 
    { yyval.sval = yyvsp[0].sval; }
 
1708
    { (yyval.sval) = (yyvsp[0].sval); }
1679
1709
    break;
1680
1710
 
1681
1711
  case 16:
1682
1712
#line 264 "awkgram.y"
1683
 
    { yyval.sval = yyvsp[0].sval; }
 
1713
    { (yyval.sval) = (yyvsp[0].sval); }
1684
1714
    break;
1685
1715
 
1686
1716
  case 17:
1689
1719
                yyerror(_("`%s' is a built-in function, it cannot be redefined"),
1690
1720
                        tokstart);
1691
1721
                errcount++;
1692
 
                yyval.sval = builtin_func;
 
1722
                (yyval.sval) = builtin_func;
1693
1723
                /* yyerrok; */
1694
1724
          }
1695
1725
    break;
1706
1736
    {
1707
1737
                        NODE *t;
1708
1738
 
1709
 
                        t = make_param(yyvsp[-4].sval);
 
1739
                        t = make_param((yyvsp[-4].sval));
1710
1740
                        t->flags |= FUNC;
1711
 
                        yyval.nodeval = append_right(t, yyvsp[-2].nodeval);
 
1741
                        (yyval.nodeval) = append_right(t, (yyvsp[-2].nodeval));
1712
1742
                        can_return = TRUE;
1713
1743
                        /* check for duplicate parameter names */
1714
 
                        if (dup_parms(yyval.nodeval))
 
1744
                        if (dup_parms((yyval.nodeval)))
1715
1745
                                errcount++;
1716
1746
                }
1717
1747
    break;
1725
1755
#line 307 "awkgram.y"
1726
1756
    {
1727
1757
                  NODE *n;
1728
 
                  size_t len = strlen(yyvsp[0].sval);
 
1758
                  size_t len = strlen((yyvsp[0].sval));
1729
1759
 
1730
 
                  if (do_lint && (yyvsp[0].sval)[0] == '*') {
1731
 
                        /* possible C comment */
1732
 
                        if ((yyvsp[0].sval)[len-1] == '*')
 
1760
                  if (do_lint) {
 
1761
                        if (len == 0)
 
1762
                                lintwarn(_("regexp constant `//' looks like a C++ comment, but is not"));
 
1763
                        else if (((yyvsp[0].sval))[0] == '*' && ((yyvsp[0].sval))[len-1] == '*')
 
1764
                                /* possible C comment */
1733
1765
                                lintwarn(_("regexp constant `/%s/' looks like a C comment, but is not"), tokstart);
1734
1766
                  }
1735
1767
                  getnode(n);
1736
1768
                  n->type = Node_regex;
1737
 
                  n->re_exp = make_string(yyvsp[0].sval, len);
1738
 
                  n->re_reg = make_regexp(yyvsp[0].sval, len, FALSE, TRUE);
 
1769
                  n->re_exp = make_string((yyvsp[0].sval), len);
 
1770
                  n->re_reg = make_regexp((yyvsp[0].sval), len, FALSE, TRUE);
1739
1771
                  n->re_text = NULL;
1740
1772
                  n->re_flags = CONST;
1741
1773
                  n->re_cnt = 1;
1742
 
                  yyval.nodeval = n;
 
1774
                  (yyval.nodeval) = n;
1743
1775
                }
1744
1776
    break;
1745
1777
 
1746
1778
  case 26:
1747
 
#line 334 "awkgram.y"
1748
 
    { yyval.nodeval = NULL; }
 
1779
#line 336 "awkgram.y"
 
1780
    { (yyval.nodeval) = NULL; }
1749
1781
    break;
1750
1782
 
1751
1783
  case 27:
1752
 
#line 336 "awkgram.y"
 
1784
#line 338 "awkgram.y"
1753
1785
    {
1754
 
                if (yyvsp[0].nodeval == NULL)
1755
 
                        yyval.nodeval = yyvsp[-1].nodeval;
 
1786
                if ((yyvsp[0].nodeval) == NULL)
 
1787
                        (yyval.nodeval) = (yyvsp[-1].nodeval);
1756
1788
                else {
1757
 
                        if (do_lint && isnoeffect(yyvsp[0].nodeval->type))
 
1789
                        if (do_lint && isnoeffect((yyvsp[0].nodeval)->type))
1758
1790
                                lintwarn(_("statement may have no effect"));
1759
 
                        if (yyvsp[-1].nodeval == NULL)
1760
 
                                yyval.nodeval = yyvsp[0].nodeval;
 
1791
                        if ((yyvsp[-1].nodeval) == NULL)
 
1792
                                (yyval.nodeval) = (yyvsp[0].nodeval);
1761
1793
                        else
1762
 
                                yyval.nodeval = append_right(
1763
 
                                        (yyvsp[-1].nodeval->type == Node_statement_list ? yyvsp[-1].nodeval
1764
 
                                          : node(yyvsp[-1].nodeval, Node_statement_list, (NODE *) NULL)),
1765
 
                                        (yyvsp[0].nodeval->type == Node_statement_list ? yyvsp[0].nodeval
1766
 
                                          : node(yyvsp[0].nodeval, Node_statement_list, (NODE *) NULL)));
 
1794
                                (yyval.nodeval) = append_right(
 
1795
                                        ((yyvsp[-1].nodeval)->type == Node_statement_list ? (yyvsp[-1].nodeval)
 
1796
                                          : node((yyvsp[-1].nodeval), Node_statement_list, (NODE *) NULL)),
 
1797
                                        ((yyvsp[0].nodeval)->type == Node_statement_list ? (yyvsp[0].nodeval)
 
1798
                                          : node((yyvsp[0].nodeval), Node_statement_list, (NODE *) NULL)));
1767
1799
                }
1768
1800
                yyerrok;
1769
1801
          }
1770
1802
    break;
1771
1803
 
1772
1804
  case 28:
1773
 
#line 354 "awkgram.y"
1774
 
    { yyval.nodeval = NULL; }
 
1805
#line 356 "awkgram.y"
 
1806
    { (yyval.nodeval) = NULL; }
1775
1807
    break;
1776
1808
 
1777
1809
  case 31:
1778
 
#line 364 "awkgram.y"
1779
 
    { yyval.nodeval = NULL; }
 
1810
#line 366 "awkgram.y"
 
1811
    { (yyval.nodeval) = NULL; }
1780
1812
    break;
1781
1813
 
1782
1814
  case 32:
1783
 
#line 366 "awkgram.y"
1784
 
    { yyval.nodeval = yyvsp[-1].nodeval; }
 
1815
#line 368 "awkgram.y"
 
1816
    { (yyval.nodeval) = (yyvsp[-1].nodeval); }
1785
1817
    break;
1786
1818
 
1787
1819
  case 33:
1788
 
#line 368 "awkgram.y"
1789
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
1820
#line 370 "awkgram.y"
 
1821
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
1790
1822
    break;
1791
1823
 
1792
1824
  case 34:
1793
 
#line 370 "awkgram.y"
1794
 
    { yyval.nodeval = node(yyvsp[-6].nodeval, Node_K_switch, yyvsp[-2].nodeval); }
 
1825
#line 372 "awkgram.y"
 
1826
    { (yyval.nodeval) = node((yyvsp[-6].nodeval), Node_K_switch, (yyvsp[-2].nodeval)); }
1795
1827
    break;
1796
1828
 
1797
1829
  case 35:
1798
 
#line 372 "awkgram.y"
1799
 
    { yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); }
 
1830
#line 374 "awkgram.y"
 
1831
    { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_while, (yyvsp[0].nodeval)); }
1800
1832
    break;
1801
1833
 
1802
1834
  case 36:
1803
 
#line 374 "awkgram.y"
1804
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); }
 
1835
#line 376 "awkgram.y"
 
1836
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_K_do, (yyvsp[-5].nodeval)); }
1805
1837
    break;
1806
1838
 
1807
1839
  case 37:
1808
 
#line 376 "awkgram.y"
 
1840
#line 378 "awkgram.y"
1809
1841
    {
1810
1842
                /*
1811
1843
                 * Efficiency hack.  Recognize the special case of
1820
1852
                 * Check that the body is a `delete a[i]' statement,
1821
1853
                 * and that both the loop var and array names match.
1822
1854
                 */
1823
 
                if (yyvsp[0].nodeval != NULL && yyvsp[0].nodeval->type == Node_K_delete && yyvsp[0].nodeval->rnode != NULL) {
 
1855
                if ((yyvsp[0].nodeval) != NULL && (yyvsp[0].nodeval)->type == Node_K_delete && (yyvsp[0].nodeval)->rnode != NULL) {
1824
1856
                        NODE *arr, *sub;
1825
1857
 
1826
 
                        assert(yyvsp[0].nodeval->rnode->type == Node_expression_list);
1827
 
                        arr = yyvsp[0].nodeval->lnode;  /* array var */
1828
 
                        sub = yyvsp[0].nodeval->rnode->lnode;   /* index var */
 
1858
                        assert((yyvsp[0].nodeval)->rnode->type == Node_expression_list);
 
1859
                        arr = (yyvsp[0].nodeval)->lnode;        /* array var */
 
1860
                        sub = (yyvsp[0].nodeval)->rnode->lnode; /* index var */
1829
1861
 
1830
1862
                        if (   (arr->type == Node_var_new
1831
1863
                                || arr->type == Node_var_array
1833
1865
                            && (sub->type == Node_var_new
1834
1866
                                || sub->type == Node_var
1835
1867
                                || sub->type == Node_param_list)
1836
 
                            && strcmp(yyvsp[-5].sval, sub->vname) == 0
1837
 
                            && strcmp(yyvsp[-3].sval, arr->vname) == 0) {
1838
 
                                yyvsp[0].nodeval->type = Node_K_delete_loop;
1839
 
                                yyval.nodeval = yyvsp[0].nodeval;
 
1868
                            && strcmp((yyvsp[-5].sval), sub->vname) == 0
 
1869
                            && strcmp((yyvsp[-3].sval), arr->vname) == 0) {
 
1870
                                (yyvsp[0].nodeval)->type = Node_K_delete_loop;
 
1871
                                (yyval.nodeval) = (yyvsp[0].nodeval);
 
1872
                                free((yyvsp[-5].sval)); /* thanks to valgrind for pointing these out */
 
1873
                                free((yyvsp[-3].sval));
1840
1874
                        }
1841
1875
                        else
1842
1876
                                goto regular_loop;
1843
1877
                } else {
1844
1878
        regular_loop:
1845
 
                        yyval.nodeval = node(yyvsp[0].nodeval, Node_K_arrayfor,
1846
 
                                make_for_loop(variable(yyvsp[-5].sval, CAN_FREE, Node_var),
1847
 
                                (NODE *) NULL, variable(yyvsp[-3].sval, CAN_FREE, Node_var_array)));
 
1879
                        (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_arrayfor,
 
1880
                                make_for_loop(variable((yyvsp[-5].sval), CAN_FREE, Node_var),
 
1881
                                (NODE *) NULL, variable((yyvsp[-3].sval), CAN_FREE, Node_var_array)));
1848
1882
                }
1849
1883
          }
1850
1884
    break;
1851
1885
 
1852
1886
  case 38:
1853
 
#line 418 "awkgram.y"
 
1887
#line 422 "awkgram.y"
1854
1888
    {
1855
 
                yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *) make_for_loop(yyvsp[-9].nodeval, yyvsp[-6].nodeval, yyvsp[-3].nodeval));
 
1889
                (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_for, (NODE *) make_for_loop((yyvsp[-9].nodeval), (yyvsp[-6].nodeval), (yyvsp[-3].nodeval)));
1856
1890
          }
1857
1891
    break;
1858
1892
 
1859
1893
  case 39:
1860
 
#line 422 "awkgram.y"
 
1894
#line 426 "awkgram.y"
1861
1895
    {
1862
 
                yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for,
1863
 
                        (NODE *) make_for_loop(yyvsp[-8].nodeval, (NODE *) NULL, yyvsp[-3].nodeval));
 
1896
                (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_for,
 
1897
                        (NODE *) make_for_loop((yyvsp[-8].nodeval), (NODE *) NULL, (yyvsp[-3].nodeval)));
1864
1898
          }
1865
1899
    break;
1866
1900
 
1867
1901
  case 40:
1868
 
#line 428 "awkgram.y"
1869
 
    { yyval.nodeval = node((NODE *) NULL, Node_K_break, (NODE *) NULL); }
 
1902
#line 432 "awkgram.y"
 
1903
    { (yyval.nodeval) = node((NODE *) NULL, Node_K_break, (NODE *) NULL); }
1870
1904
    break;
1871
1905
 
1872
1906
  case 41:
1873
 
#line 431 "awkgram.y"
1874
 
    { yyval.nodeval = node((NODE *) NULL, Node_K_continue, (NODE *) NULL); }
 
1907
#line 435 "awkgram.y"
 
1908
    { (yyval.nodeval) = node((NODE *) NULL, Node_K_continue, (NODE *) NULL); }
1875
1909
    break;
1876
1910
 
1877
1911
  case 42:
1878
 
#line 433 "awkgram.y"
 
1912
#line 437 "awkgram.y"
1879
1913
    { NODETYPE type;
1880
1914
 
1881
1915
                  if (begin_or_end_rule)
1882
1916
                        yyerror(_("`%s' used in %s action"), "next",
1883
1917
                                (parsing_end_rule ? "END" : "BEGIN"));
1884
1918
                  type = Node_K_next;
1885
 
                  yyval.nodeval = node((NODE *) NULL, type, (NODE *) NULL);
 
1919
                  (yyval.nodeval) = node((NODE *) NULL, type, (NODE *) NULL);
1886
1920
                }
1887
1921
    break;
1888
1922
 
1889
1923
  case 43:
1890
 
#line 442 "awkgram.y"
 
1924
#line 446 "awkgram.y"
1891
1925
    {
1892
1926
                  if (do_traditional) {
1893
1927
                        /*
1905
1939
                        error(_("`%s' used in %s action"), "nextfile",
1906
1940
                                (parsing_end_rule ? "END" : "BEGIN"));
1907
1941
                  }
1908
 
                  yyval.nodeval = node((NODE *) NULL, Node_K_nextfile, (NODE *) NULL);
 
1942
                  (yyval.nodeval) = node((NODE *) NULL, Node_K_nextfile, (NODE *) NULL);
1909
1943
                }
1910
1944
    break;
1911
1945
 
1912
1946
  case 44:
1913
 
#line 462 "awkgram.y"
1914
 
    { yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_exit, (NODE *) NULL); }
 
1947
#line 466 "awkgram.y"
 
1948
    { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_K_exit, (NODE *) NULL); }
1915
1949
    break;
1916
1950
 
1917
1951
  case 45:
1918
 
#line 464 "awkgram.y"
 
1952
#line 468 "awkgram.y"
1919
1953
    {
1920
1954
                  if (! can_return)
1921
1955
                        yyerror(_("`return' used outside function context"));
1923
1957
    break;
1924
1958
 
1925
1959
  case 46:
1926
 
#line 469 "awkgram.y"
 
1960
#line 473 "awkgram.y"
1927
1961
    {
1928
 
                  yyval.nodeval = node(yyvsp[-1].nodeval == NULL ? Nnull_string : yyvsp[-1].nodeval,
 
1962
                  (yyval.nodeval) = node((yyvsp[-1].nodeval) == NULL ? Nnull_string : (yyvsp[-1].nodeval),
1929
1963
                        Node_K_return, (NODE *) NULL);
1930
1964
                }
1931
1965
    break;
1932
1966
 
1933
1967
  case 48:
1934
 
#line 485 "awkgram.y"
 
1968
#line 489 "awkgram.y"
1935
1969
    { in_print = TRUE; in_parens = 0; }
1936
1970
    break;
1937
1971
 
1938
1972
  case 49:
1939
 
#line 486 "awkgram.y"
 
1973
#line 490 "awkgram.y"
1940
1974
    {
1941
1975
                /*
1942
1976
                 * Optimization: plain `print' has no expression list, so $3 is null.
1944
1978
                 * and lnode is a field spec for field 0, we have `print $0'.
1945
1979
                 * For both, use Node_K_print_rec, which is faster for these two cases.
1946
1980
                 */
1947
 
                if (yyvsp[-3].nodetypeval == Node_K_print &&
1948
 
                    (yyvsp[-1].nodeval == NULL
1949
 
                     || (yyvsp[-1].nodeval->type == Node_expression_list
1950
 
                        && yyvsp[-1].nodeval->rnode == NULL
1951
 
                        && yyvsp[-1].nodeval->lnode->type == Node_field_spec
1952
 
                        && yyvsp[-1].nodeval->lnode->lnode->type == Node_val
1953
 
                        && yyvsp[-1].nodeval->lnode->lnode->numbr == 0.0))
 
1981
                if ((yyvsp[-3].nodetypeval) == Node_K_print &&
 
1982
                    ((yyvsp[-1].nodeval) == NULL
 
1983
                     || ((yyvsp[-1].nodeval)->type == Node_expression_list
 
1984
                        && (yyvsp[-1].nodeval)->rnode == NULL
 
1985
                        && (yyvsp[-1].nodeval)->lnode->type == Node_field_spec
 
1986
                        && (yyvsp[-1].nodeval)->lnode->lnode->type == Node_val
 
1987
                        && (yyvsp[-1].nodeval)->lnode->lnode->numbr == 0.0))
1954
1988
                ) {
1955
1989
                        static int warned = FALSE;
1956
1990
 
1957
 
                        yyval.nodeval = node(NULL, Node_K_print_rec, yyvsp[0].nodeval);
 
1991
                        (yyval.nodeval) = node(NULL, Node_K_print_rec, (yyvsp[0].nodeval));
1958
1992
 
1959
 
                        if (do_lint && yyvsp[-1].nodeval == NULL && begin_or_end_rule && ! warned) {
 
1993
                        if (do_lint && (yyvsp[-1].nodeval) == NULL && begin_or_end_rule && ! warned) {
1960
1994
                                warned = TRUE;
1961
1995
                                lintwarn(
1962
1996
        _("plain `print' in BEGIN or END rule should probably be `print \"\"'"));
1963
1997
                        }
1964
1998
                } else {
1965
 
                        yyval.nodeval = node(yyvsp[-1].nodeval, yyvsp[-3].nodetypeval, yyvsp[0].nodeval);
1966
 
                        if (yyval.nodeval->type == Node_K_printf)
1967
 
                                count_args(yyval.nodeval);
 
1999
                        (yyval.nodeval) = node((yyvsp[-1].nodeval), (yyvsp[-3].nodetypeval), (yyvsp[0].nodeval));
 
2000
                        if ((yyval.nodeval)->type == Node_K_printf)
 
2001
                                count_args((yyval.nodeval));
1968
2002
                }
1969
2003
          }
1970
2004
    break;
1971
2005
 
1972
2006
  case 50:
1973
 
#line 517 "awkgram.y"
1974
 
    { yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_K_delete, yyvsp[-1].nodeval); }
 
2007
#line 521 "awkgram.y"
 
2008
    { (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_K_delete, (yyvsp[-1].nodeval)); }
1975
2009
    break;
1976
2010
 
1977
2011
  case 51:
1978
 
#line 519 "awkgram.y"
 
2012
#line 523 "awkgram.y"
1979
2013
    {
1980
2014
                  if (do_lint)
1981
2015
                        lintwarn(_("`delete array' is a gawk extension"));
1987
2021
                        errcount++;
1988
2022
                        error(_("`delete array' is a gawk extension"));
1989
2023
                  }
1990
 
                  yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
 
2024
                  (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
1991
2025
                }
1992
2026
    break;
1993
2027
 
1994
2028
  case 52:
1995
 
#line 533 "awkgram.y"
 
2029
#line 537 "awkgram.y"
1996
2030
    {
1997
2031
                  /* this is for tawk compatibility. maybe the warnings should always be done. */
1998
2032
                  if (do_lint)
2005
2039
                        errcount++;
2006
2040
                        error(_("`delete(array)' is a non-portable tawk extension"));
2007
2041
                  }
2008
 
                  yyval.nodeval = node(variable(yyvsp[-1].sval, CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
 
2042
                  (yyval.nodeval) = node(variable((yyvsp[-1].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL);
2009
2043
                }
2010
2044
    break;
2011
2045
 
2012
2046
  case 53:
2013
 
#line 548 "awkgram.y"
2014
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2047
#line 552 "awkgram.y"
 
2048
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2015
2049
    break;
2016
2050
 
2017
2051
  case 54:
2018
 
#line 553 "awkgram.y"
2019
 
    { yyval.nodeval = NULL; }
 
2052
#line 557 "awkgram.y"
 
2053
    { (yyval.nodeval) = NULL; }
2020
2054
    break;
2021
2055
 
2022
2056
  case 55:
2023
 
#line 555 "awkgram.y"
2024
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2057
#line 559 "awkgram.y"
 
2058
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2025
2059
    break;
2026
2060
 
2027
2061
  case 56:
2028
 
#line 560 "awkgram.y"
 
2062
#line 564 "awkgram.y"
2029
2063
    {
2030
 
                if (yyvsp[0].nodeval == NULL) {
2031
 
                        yyval.nodeval = NULL;
 
2064
                if ((yyvsp[0].nodeval) == NULL) {
 
2065
                        (yyval.nodeval) = NULL;
2032
2066
                } else {
2033
2067
                        NODE *dflt = NULL;
2034
 
                        NODE *head = yyvsp[0].nodeval;
 
2068
                        NODE *head = (yyvsp[0].nodeval);
2035
2069
                        NODE *curr;
2036
2070
        
2037
2071
                        const char **case_values = NULL;
2041
2075
                        int i;
2042
2076
        
2043
2077
                        emalloc(case_values, const char **, sizeof(char*) * maxcount, "switch_body");
2044
 
                        for (curr = yyvsp[0].nodeval; curr != NULL; curr = curr->rnode) {
 
2078
                        for (curr = (yyvsp[0].nodeval); curr != NULL; curr = curr->rnode) {
2045
2079
                                /* Assure that case statement values are unique. */
2046
2080
                                if (curr->lnode->type == Node_K_case) {
2047
2081
                                        char *caseval;
2071
2105
                        free(case_values);
2072
2106
        
2073
2107
                        /* Create the switch body. */
2074
 
                        yyval.nodeval = node(head, Node_switch_body, dflt);
 
2108
                        (yyval.nodeval) = node(head, Node_switch_body, dflt);
2075
2109
                }
2076
2110
        }
2077
2111
    break;
2078
2112
 
2079
2113
  case 57:
2080
 
#line 612 "awkgram.y"
2081
 
    { yyval.nodeval = NULL; }
 
2114
#line 616 "awkgram.y"
 
2115
    { (yyval.nodeval) = NULL; }
2082
2116
    break;
2083
2117
 
2084
2118
  case 58:
2085
 
#line 614 "awkgram.y"
 
2119
#line 618 "awkgram.y"
2086
2120
    {
2087
 
                if (yyvsp[0].nodeval == NULL)
2088
 
                        yyval.nodeval = yyvsp[-1].nodeval;
 
2121
                if ((yyvsp[0].nodeval) == NULL)
 
2122
                        (yyval.nodeval) = (yyvsp[-1].nodeval);
2089
2123
                else {
2090
 
                        if (do_lint && isnoeffect(yyvsp[0].nodeval->type))
 
2124
                        if (do_lint && isnoeffect((yyvsp[0].nodeval)->type))
2091
2125
                                lintwarn(_("statement may have no effect"));
2092
 
                        if (yyvsp[-1].nodeval == NULL)
2093
 
                                yyval.nodeval = node(yyvsp[0].nodeval, Node_case_list, (NODE *) NULL);
 
2126
                        if ((yyvsp[-1].nodeval) == NULL)
 
2127
                                (yyval.nodeval) = node((yyvsp[0].nodeval), Node_case_list, (NODE *) NULL);
2094
2128
                        else
2095
 
                                yyval.nodeval = append_right(
2096
 
                                        (yyvsp[-1].nodeval->type == Node_case_list ? yyvsp[-1].nodeval : node(yyvsp[-1].nodeval, Node_case_list, (NODE *) NULL)),
2097
 
                                        (yyvsp[0].nodeval->type == Node_case_list ? yyvsp[0].nodeval : node(yyvsp[0].nodeval, Node_case_list, (NODE *) NULL))
 
2129
                                (yyval.nodeval) = append_right(
 
2130
                                        ((yyvsp[-1].nodeval)->type == Node_case_list ? (yyvsp[-1].nodeval) : node((yyvsp[-1].nodeval), Node_case_list, (NODE *) NULL)),
 
2131
                                        ((yyvsp[0].nodeval)->type == Node_case_list ? (yyvsp[0].nodeval) : node((yyvsp[0].nodeval), Node_case_list, (NODE *) NULL))
2098
2132
                                );
2099
2133
                }
2100
2134
                yyerrok;
2102
2136
    break;
2103
2137
 
2104
2138
  case 59:
2105
 
#line 631 "awkgram.y"
2106
 
    { yyval.nodeval = NULL; }
 
2139
#line 635 "awkgram.y"
 
2140
    { (yyval.nodeval) = NULL; }
2107
2141
    break;
2108
2142
 
2109
2143
  case 60:
2110
 
#line 636 "awkgram.y"
2111
 
    { yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_case, yyvsp[0].nodeval); }
 
2144
#line 640 "awkgram.y"
 
2145
    { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_case, (yyvsp[0].nodeval)); }
2112
2146
    break;
2113
2147
 
2114
2148
  case 61:
2115
 
#line 638 "awkgram.y"
2116
 
    { yyval.nodeval = node((NODE *) NULL, Node_K_default, yyvsp[0].nodeval); }
 
2149
#line 642 "awkgram.y"
 
2150
    { (yyval.nodeval) = node((NODE *) NULL, Node_K_default, (yyvsp[0].nodeval)); }
2117
2151
    break;
2118
2152
 
2119
2153
  case 62:
2120
 
#line 643 "awkgram.y"
2121
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2154
#line 647 "awkgram.y"
 
2155
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2122
2156
    break;
2123
2157
 
2124
2158
  case 63:
2125
 
#line 645 "awkgram.y"
 
2159
#line 649 "awkgram.y"
2126
2160
    {
2127
 
                yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
2128
 
                yyval.nodeval = yyvsp[0].nodeval;
 
2161
                (yyvsp[0].nodeval)->numbr = -(force_number((yyvsp[0].nodeval)));
 
2162
                (yyval.nodeval) = (yyvsp[0].nodeval);
2129
2163
          }
2130
2164
    break;
2131
2165
 
2132
2166
  case 64:
2133
 
#line 650 "awkgram.y"
2134
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2167
#line 654 "awkgram.y"
 
2168
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2135
2169
    break;
2136
2170
 
2137
2171
  case 65:
2138
 
#line 652 "awkgram.y"
2139
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2172
#line 656 "awkgram.y"
 
2173
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2140
2174
    break;
2141
2175
 
2142
2176
  case 66:
2143
 
#line 654 "awkgram.y"
2144
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2177
#line 658 "awkgram.y"
 
2178
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2145
2179
    break;
2146
2180
 
2147
2181
  case 70:
2148
 
#line 669 "awkgram.y"
2149
 
    { yyval.nodeval = node(yyvsp[-3].nodeval, Node_expression_list, yyvsp[-1].nodeval); }
 
2182
#line 673 "awkgram.y"
 
2183
    { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_expression_list, (yyvsp[-1].nodeval)); }
2150
2184
    break;
2151
2185
 
2152
2186
  case 71:
2153
 
#line 674 "awkgram.y"
 
2187
#line 678 "awkgram.y"
2154
2188
    {
2155
2189
                in_print = FALSE;
2156
2190
                in_parens = 0;
2157
 
                yyval.nodeval = NULL;
 
2191
                (yyval.nodeval) = NULL;
2158
2192
          }
2159
2193
    break;
2160
2194
 
2161
2195
  case 72:
2162
 
#line 679 "awkgram.y"
 
2196
#line 683 "awkgram.y"
2163
2197
    { in_print = FALSE; in_parens = 0; }
2164
2198
    break;
2165
2199
 
2166
2200
  case 73:
2167
 
#line 680 "awkgram.y"
 
2201
#line 684 "awkgram.y"
2168
2202
    {
2169
 
                yyval.nodeval = node(yyvsp[0].nodeval, yyvsp[-2].nodetypeval, (NODE *) NULL);
2170
 
                if (yyvsp[-2].nodetypeval == Node_redirect_twoway
2171
 
                    && yyvsp[0].nodeval->type == Node_K_getline
2172
 
                    && yyvsp[0].nodeval->rnode != NULL
2173
 
                    && yyvsp[0].nodeval->rnode->type == Node_redirect_twoway)
 
2203
                (yyval.nodeval) = node((yyvsp[0].nodeval), (yyvsp[-2].nodetypeval), (NODE *) NULL);
 
2204
                if ((yyvsp[-2].nodetypeval) == Node_redirect_twoway
 
2205
                    && (yyvsp[0].nodeval)->type == Node_K_getline
 
2206
                    && (yyvsp[0].nodeval)->rnode != NULL
 
2207
                    && (yyvsp[0].nodeval)->rnode->type == Node_redirect_twoway)
2174
2208
                        yyerror(_("multistage two-way pipelines don't work"));
2175
2209
          }
2176
2210
    break;
2177
2211
 
2178
2212
  case 74:
2179
 
#line 692 "awkgram.y"
 
2213
#line 696 "awkgram.y"
2180
2214
    {
2181
 
                yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, 
2182
 
                        node(yyvsp[0].nodeval, Node_if_branches, (NODE *) NULL));
 
2215
                (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_if, 
 
2216
                        node((yyvsp[0].nodeval), Node_if_branches, (NODE *) NULL));
2183
2217
          }
2184
2218
    break;
2185
2219
 
2186
2220
  case 75:
2187
 
#line 698 "awkgram.y"
2188
 
    { yyval.nodeval = node(yyvsp[-6].nodeval, Node_K_if,
2189
 
                                node(yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); }
 
2221
#line 702 "awkgram.y"
 
2222
    { (yyval.nodeval) = node((yyvsp[-6].nodeval), Node_K_if,
 
2223
                                node((yyvsp[-3].nodeval), Node_if_branches, (yyvsp[0].nodeval))); }
2190
2224
    break;
2191
2225
 
2192
2226
  case 80:
2193
 
#line 714 "awkgram.y"
2194
 
    { yyval.nodeval = NULL; }
 
2227
#line 718 "awkgram.y"
 
2228
    { (yyval.nodeval) = NULL; }
2195
2229
    break;
2196
2230
 
2197
2231
  case 81:
2198
 
#line 716 "awkgram.y"
2199
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_redirect_input, (NODE *) NULL); }
 
2232
#line 720 "awkgram.y"
 
2233
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_redirect_input, (NODE *) NULL); }
2200
2234
    break;
2201
2235
 
2202
2236
  case 82:
2203
 
#line 721 "awkgram.y"
2204
 
    { yyval.nodeval = NULL; }
 
2237
#line 725 "awkgram.y"
 
2238
    { (yyval.nodeval) = NULL; }
2205
2239
    break;
2206
2240
 
2207
2241
  case 83:
2208
 
#line 723 "awkgram.y"
2209
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2242
#line 727 "awkgram.y"
 
2243
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2210
2244
    break;
2211
2245
 
2212
2246
  case 84:
2213
 
#line 728 "awkgram.y"
2214
 
    { yyval.nodeval = make_param(yyvsp[0].sval); }
 
2247
#line 732 "awkgram.y"
 
2248
    { (yyval.nodeval) = make_param((yyvsp[0].sval)); }
2215
2249
    break;
2216
2250
 
2217
2251
  case 85:
2218
 
#line 730 "awkgram.y"
2219
 
    { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; }
 
2252
#line 734 "awkgram.y"
 
2253
    { (yyval.nodeval) = append_right((yyvsp[-2].nodeval), make_param((yyvsp[0].sval))); yyerrok; }
2220
2254
    break;
2221
2255
 
2222
2256
  case 86:
2223
 
#line 732 "awkgram.y"
2224
 
    { yyval.nodeval = NULL; }
 
2257
#line 736 "awkgram.y"
 
2258
    { (yyval.nodeval) = NULL; }
2225
2259
    break;
2226
2260
 
2227
2261
  case 87:
2228
 
#line 734 "awkgram.y"
2229
 
    { yyval.nodeval = NULL; }
 
2262
#line 738 "awkgram.y"
 
2263
    { (yyval.nodeval) = NULL; }
2230
2264
    break;
2231
2265
 
2232
2266
  case 88:
2233
 
#line 736 "awkgram.y"
2234
 
    { yyval.nodeval = NULL; }
 
2267
#line 740 "awkgram.y"
 
2268
    { (yyval.nodeval) = NULL; }
2235
2269
    break;
2236
2270
 
2237
2271
  case 89:
2238
 
#line 742 "awkgram.y"
2239
 
    { yyval.nodeval = NULL; }
 
2272
#line 746 "awkgram.y"
 
2273
    { (yyval.nodeval) = NULL; }
2240
2274
    break;
2241
2275
 
2242
2276
  case 90:
2243
 
#line 744 "awkgram.y"
2244
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2277
#line 748 "awkgram.y"
 
2278
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2245
2279
    break;
2246
2280
 
2247
2281
  case 91:
2248
 
#line 749 "awkgram.y"
2249
 
    { yyval.nodeval = NULL; }
 
2282
#line 753 "awkgram.y"
 
2283
    { (yyval.nodeval) = NULL; }
2250
2284
    break;
2251
2285
 
2252
2286
  case 92:
2253
 
#line 751 "awkgram.y"
2254
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2287
#line 755 "awkgram.y"
 
2288
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2255
2289
    break;
2256
2290
 
2257
2291
  case 93:
2258
 
#line 756 "awkgram.y"
2259
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL); }
 
2292
#line 760 "awkgram.y"
 
2293
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_expression_list, (NODE *) NULL); }
2260
2294
    break;
2261
2295
 
2262
2296
  case 94:
2263
 
#line 758 "awkgram.y"
 
2297
#line 762 "awkgram.y"
2264
2298
    {
2265
 
                        yyval.nodeval = append_right(yyvsp[-2].nodeval,
2266
 
                                node(yyvsp[0].nodeval, Node_expression_list, (NODE *) NULL));
 
2299
                        (yyval.nodeval) = append_right((yyvsp[-2].nodeval),
 
2300
                                node((yyvsp[0].nodeval), Node_expression_list, (NODE *) NULL));
2267
2301
                        yyerrok;
2268
2302
                }
2269
2303
    break;
2270
2304
 
2271
2305
  case 95:
2272
 
#line 764 "awkgram.y"
2273
 
    { yyval.nodeval = NULL; }
 
2306
#line 768 "awkgram.y"
 
2307
    { (yyval.nodeval) = NULL; }
2274
2308
    break;
2275
2309
 
2276
2310
  case 96:
2277
 
#line 766 "awkgram.y"
2278
 
    { yyval.nodeval = NULL; }
 
2311
#line 770 "awkgram.y"
 
2312
    { (yyval.nodeval) = NULL; }
2279
2313
    break;
2280
2314
 
2281
2315
  case 97:
2282
 
#line 768 "awkgram.y"
2283
 
    { yyval.nodeval = NULL; }
 
2316
#line 772 "awkgram.y"
 
2317
    { (yyval.nodeval) = NULL; }
2284
2318
    break;
2285
2319
 
2286
2320
  case 98:
2287
 
#line 770 "awkgram.y"
2288
 
    { yyval.nodeval = NULL; }
 
2321
#line 774 "awkgram.y"
 
2322
    { (yyval.nodeval) = NULL; }
2289
2323
    break;
2290
2324
 
2291
2325
  case 99:
2292
 
#line 775 "awkgram.y"
 
2326
#line 779 "awkgram.y"
2293
2327
    {
2294
 
                  if (do_lint && yyvsp[0].nodeval->type == Node_regex)
 
2328
                  if (do_lint && (yyvsp[0].nodeval)->type == Node_regex)
2295
2329
                        lintwarn(_("regular expression on right of assignment"));
2296
2330
                  /*
2297
2331
                   * Optimization of `x = x y'.  Can save lots of time
2298
2332
                   * if done a lot.
2299
2333
                   */
2300
 
                  if ((    yyvsp[-2].nodeval->type == Node_var
2301
 
                        || yyvsp[-2].nodeval->type == Node_var_new
2302
 
                        || yyvsp[-2].nodeval->type == Node_param_list)
2303
 
                      && yyvsp[-1].nodetypeval == Node_assign
2304
 
                      && yyvsp[0].nodeval->type == Node_concat
2305
 
                      && yyvsp[0].nodeval->lnode == yyvsp[-2].nodeval) {
2306
 
                        yyvsp[0].nodeval->type = Node_assign_concat;    /* Just change the type */
2307
 
                        yyval.nodeval = yyvsp[0].nodeval;                       /* And use it directly */
 
2334
                  if ((    (yyvsp[-2].nodeval)->type == Node_var
 
2335
                        || (yyvsp[-2].nodeval)->type == Node_var_new
 
2336
                        || (yyvsp[-2].nodeval)->type == Node_param_list)
 
2337
                      && (yyvsp[-1].nodetypeval) == Node_assign
 
2338
                      && (yyvsp[0].nodeval)->type == Node_concat
 
2339
                      && (yyvsp[0].nodeval)->lnode == (yyvsp[-2].nodeval)) {
 
2340
                        (yyvsp[0].nodeval)->type = Node_assign_concat;  /* Just change the type */
 
2341
                        (yyval.nodeval) = (yyvsp[0].nodeval);                   /* And use it directly */
2308
2342
                  } else
2309
 
                        yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
 
2343
                        (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), (yyvsp[0].nodeval));
2310
2344
                }
2311
2345
    break;
2312
2346
 
2313
2347
  case 100:
2314
 
#line 794 "awkgram.y"
2315
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); }
 
2348
#line 798 "awkgram.y"
 
2349
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_and, (yyvsp[0].nodeval)); }
2316
2350
    break;
2317
2351
 
2318
2352
  case 101:
2319
 
#line 796 "awkgram.y"
2320
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); }
 
2353
#line 800 "awkgram.y"
 
2354
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_or, (yyvsp[0].nodeval)); }
2321
2355
    break;
2322
2356
 
2323
2357
  case 102:
2324
 
#line 798 "awkgram.y"
 
2358
#line 802 "awkgram.y"
2325
2359
    {
2326
 
                  if (yyvsp[-2].nodeval->type == Node_regex)
 
2360
                  if ((yyvsp[-2].nodeval)->type == Node_regex)
2327
2361
                        warning(_("regular expression on left of `~' or `!~' operator"));
2328
 
                  yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
 
2362
                  (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), mk_rexp((yyvsp[0].nodeval)));
2329
2363
                }
2330
2364
    break;
2331
2365
 
2332
2366
  case 103:
2333
 
#line 804 "awkgram.y"
2334
 
    { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-2].nodeval); }
 
2367
#line 808 "awkgram.y"
 
2368
    { (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[-2].nodeval)); }
2335
2369
    break;
2336
2370
 
2337
2371
  case 104:
2338
 
#line 806 "awkgram.y"
 
2372
#line 810 "awkgram.y"
2339
2373
    {
2340
 
                  if (do_lint && yyvsp[0].nodeval->type == Node_regex)
 
2374
                  if (do_lint && (yyvsp[0].nodeval)->type == Node_regex)
2341
2375
                        lintwarn(_("regular expression on right of comparison"));
2342
 
                  yyval.nodeval = node(yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
 
2376
                  (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), (yyvsp[0].nodeval));
2343
2377
                }
2344
2378
    break;
2345
2379
 
2346
2380
  case 105:
2347
 
#line 812 "awkgram.y"
2348
 
    { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));}
 
2381
#line 816 "awkgram.y"
 
2382
    { (yyval.nodeval) = node((yyvsp[-4].nodeval), Node_cond_exp, node((yyvsp[-2].nodeval), Node_if_branches, (yyvsp[0].nodeval)));}
2349
2383
    break;
2350
2384
 
2351
2385
  case 106:
2352
 
#line 814 "awkgram.y"
2353
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2386
#line 818 "awkgram.y"
 
2387
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2354
2388
    break;
2355
2389
 
2356
2390
  case 107:
2357
 
#line 819 "awkgram.y"
2358
 
    { yyval.nodetypeval = yyvsp[0].nodetypeval; }
 
2391
#line 823 "awkgram.y"
 
2392
    { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); }
2359
2393
    break;
2360
2394
 
2361
2395
  case 108:
2362
 
#line 821 "awkgram.y"
2363
 
    { yyval.nodetypeval = yyvsp[0].nodetypeval; }
 
2396
#line 825 "awkgram.y"
 
2397
    { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); }
2364
2398
    break;
2365
2399
 
2366
2400
  case 109:
2367
 
#line 823 "awkgram.y"
2368
 
    { yyval.nodetypeval = Node_assign_quotient; }
 
2401
#line 827 "awkgram.y"
 
2402
    { (yyval.nodetypeval) = Node_assign_quotient; }
2369
2403
    break;
2370
2404
 
2371
2405
  case 110:
2372
 
#line 828 "awkgram.y"
2373
 
    { yyval.nodetypeval = yyvsp[0].nodetypeval; }
 
2406
#line 832 "awkgram.y"
 
2407
    { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); }
2374
2408
    break;
2375
2409
 
2376
2410
  case 111:
2377
 
#line 830 "awkgram.y"
2378
 
    { yyval.nodetypeval = Node_less; }
 
2411
#line 834 "awkgram.y"
 
2412
    { (yyval.nodetypeval) = Node_less; }
2379
2413
    break;
2380
2414
 
2381
2415
  case 113:
2382
 
#line 835 "awkgram.y"
2383
 
    { yyval.nodetypeval = Node_greater; }
 
2416
#line 839 "awkgram.y"
 
2417
    { (yyval.nodetypeval) = Node_greater; }
2384
2418
    break;
2385
2419
 
2386
2420
  case 114:
2387
 
#line 840 "awkgram.y"
2388
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2421
#line 844 "awkgram.y"
 
2422
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2389
2423
    break;
2390
2424
 
2391
2425
  case 115:
2392
 
#line 842 "awkgram.y"
 
2426
#line 846 "awkgram.y"
2393
2427
    {
2394
 
                  yyval.nodeval = node(node(make_number(0.0),
 
2428
                  (yyval.nodeval) = node(node(make_number(0.0),
2395
2429
                                 Node_field_spec,
2396
2430
                                 (NODE *) NULL),
2397
2431
                            Node_nomatch,
2398
 
                            yyvsp[0].nodeval);
 
2432
                            (yyvsp[0].nodeval));
2399
2433
                }
2400
2434
    break;
2401
2435
 
2402
2436
  case 116:
2403
 
#line 850 "awkgram.y"
2404
 
    { yyval.nodeval = node(variable(yyvsp[0].sval, CAN_FREE, Node_var_array), Node_in_array, yyvsp[-3].nodeval); }
 
2437
#line 854 "awkgram.y"
 
2438
    { (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[-3].nodeval)); }
2405
2439
    break;
2406
2440
 
2407
2441
  case 117:
2408
 
#line 852 "awkgram.y"
2409
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2442
#line 856 "awkgram.y"
 
2443
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2410
2444
    break;
2411
2445
 
2412
2446
  case 118:
2413
 
#line 854 "awkgram.y"
2414
 
    { yyval.nodeval = node(yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); }
 
2447
#line 858 "awkgram.y"
 
2448
    { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_concat, (yyvsp[0].nodeval)); }
2415
2449
    break;
2416
2450
 
2417
2451
  case 120:
2418
 
#line 861 "awkgram.y"
2419
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); }
 
2452
#line 865 "awkgram.y"
 
2453
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_exp, (yyvsp[0].nodeval)); }
2420
2454
    break;
2421
2455
 
2422
2456
  case 121:
2423
 
#line 863 "awkgram.y"
2424
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); }
 
2457
#line 867 "awkgram.y"
 
2458
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_times, (yyvsp[0].nodeval)); }
2425
2459
    break;
2426
2460
 
2427
2461
  case 122:
2428
 
#line 865 "awkgram.y"
2429
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); }
 
2462
#line 869 "awkgram.y"
 
2463
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_quotient, (yyvsp[0].nodeval)); }
2430
2464
    break;
2431
2465
 
2432
2466
  case 123:
2433
 
#line 867 "awkgram.y"
2434
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); }
 
2467
#line 871 "awkgram.y"
 
2468
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_mod, (yyvsp[0].nodeval)); }
2435
2469
    break;
2436
2470
 
2437
2471
  case 124:
2438
 
#line 869 "awkgram.y"
2439
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); }
 
2472
#line 873 "awkgram.y"
 
2473
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_plus, (yyvsp[0].nodeval)); }
2440
2474
    break;
2441
2475
 
2442
2476
  case 125:
2443
 
#line 871 "awkgram.y"
2444
 
    { yyval.nodeval = node(yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); }
 
2477
#line 875 "awkgram.y"
 
2478
    { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_minus, (yyvsp[0].nodeval)); }
2445
2479
    break;
2446
2480
 
2447
2481
  case 126:
2448
 
#line 873 "awkgram.y"
 
2482
#line 877 "awkgram.y"
2449
2483
    {
2450
 
                  if (do_lint && parsing_end_rule && yyvsp[0].nodeval == NULL)
 
2484
                  if (do_lint && parsing_end_rule && (yyvsp[0].nodeval) == NULL)
2451
2485
                        lintwarn(_("non-redirected `getline' undefined inside END action"));
2452
 
                  yyval.nodeval = node(yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
 
2486
                  (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_K_getline, (yyvsp[0].nodeval));
2453
2487
                }
2454
2488
    break;
2455
2489
 
2456
2490
  case 127:
2457
 
#line 879 "awkgram.y"
 
2491
#line 883 "awkgram.y"
2458
2492
    {
2459
 
                  yyval.nodeval = node(yyvsp[0].nodeval, Node_K_getline,
2460
 
                         node(yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, (NODE *) NULL));
 
2493
                  (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_getline,
 
2494
                         node((yyvsp[-3].nodeval), (yyvsp[-2].nodetypeval), (NODE *) NULL));
2461
2495
                }
2462
2496
    break;
2463
2497
 
2464
2498
  case 128:
2465
 
#line 884 "awkgram.y"
2466
 
    { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postincrement, (NODE *) NULL); }
 
2499
#line 888 "awkgram.y"
 
2500
    { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_postincrement, (NODE *) NULL); }
2467
2501
    break;
2468
2502
 
2469
2503
  case 129:
2470
 
#line 886 "awkgram.y"
2471
 
    { yyval.nodeval = node(yyvsp[-1].nodeval, Node_postdecrement, (NODE *) NULL); }
 
2504
#line 890 "awkgram.y"
 
2505
    { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_postdecrement, (NODE *) NULL); }
2472
2506
    break;
2473
2507
 
2474
2508
  case 130:
2475
 
#line 891 "awkgram.y"
2476
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_not, (NODE *) NULL); }
 
2509
#line 895 "awkgram.y"
 
2510
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_not, (NODE *) NULL); }
2477
2511
    break;
2478
2512
 
2479
2513
  case 131:
2480
 
#line 893 "awkgram.y"
2481
 
    { yyval.nodeval = yyvsp[-1].nodeval; }
 
2514
#line 897 "awkgram.y"
 
2515
    { (yyval.nodeval) = (yyvsp[-1].nodeval); }
2482
2516
    break;
2483
2517
 
2484
2518
  case 132:
2485
 
#line 896 "awkgram.y"
2486
 
    { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); }
 
2519
#line 900 "awkgram.y"
 
2520
    { (yyval.nodeval) = snode((yyvsp[-1].nodeval), Node_builtin, (int) (yyvsp[-3].lval)); }
2487
2521
    break;
2488
2522
 
2489
2523
  case 133:
2490
 
#line 898 "awkgram.y"
2491
 
    { yyval.nodeval = snode(yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); }
 
2524
#line 902 "awkgram.y"
 
2525
    { (yyval.nodeval) = snode((yyvsp[-1].nodeval), Node_builtin, (int) (yyvsp[-3].lval)); }
2492
2526
    break;
2493
2527
 
2494
2528
  case 134:
2495
 
#line 900 "awkgram.y"
 
2529
#line 904 "awkgram.y"
2496
2530
    {
2497
2531
                if (do_lint)
2498
2532
                        lintwarn(_("call of `length' without parentheses is not portable"));
2499
 
                yyval.nodeval = snode((NODE *) NULL, Node_builtin, (int) yyvsp[0].lval);
 
2533
                (yyval.nodeval) = snode((NODE *) NULL, Node_builtin, (int) (yyvsp[0].lval));
2500
2534
                if (do_posix)
2501
2535
                        warning(_("call of `length' without parentheses is deprecated by POSIX"));
2502
2536
          }
2503
2537
    break;
2504
2538
 
2505
2539
  case 135:
2506
 
#line 908 "awkgram.y"
 
2540
#line 912 "awkgram.y"
2507
2541
    {
2508
 
                yyval.nodeval = node(yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
2509
 
                yyval.nodeval->funcbody = NULL;
2510
 
                func_use(yyvsp[-3].sval, FUNC_USE);
2511
 
                param_sanity(yyvsp[-1].nodeval);
2512
 
                free(yyvsp[-3].sval);
 
2542
                (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_func_call, make_string((yyvsp[-3].sval), strlen((yyvsp[-3].sval))));
 
2543
                (yyval.nodeval)->funcbody = NULL;
 
2544
                func_use((yyvsp[-3].sval), FUNC_USE);
 
2545
                param_sanity((yyvsp[-1].nodeval));
 
2546
                free((yyvsp[-3].sval));
2513
2547
          }
2514
2548
    break;
2515
2549
 
2516
2550
  case 137:
2517
 
#line 917 "awkgram.y"
2518
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_preincrement, (NODE *) NULL); }
 
2551
#line 921 "awkgram.y"
 
2552
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_preincrement, (NODE *) NULL); }
2519
2553
    break;
2520
2554
 
2521
2555
  case 138:
2522
 
#line 919 "awkgram.y"
2523
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_predecrement, (NODE *) NULL); }
 
2556
#line 923 "awkgram.y"
 
2557
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_predecrement, (NODE *) NULL); }
2524
2558
    break;
2525
2559
 
2526
2560
  case 139:
2527
 
#line 921 "awkgram.y"
2528
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2561
#line 925 "awkgram.y"
 
2562
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2529
2563
    break;
2530
2564
 
2531
2565
  case 140:
2532
 
#line 923 "awkgram.y"
2533
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2566
#line 927 "awkgram.y"
 
2567
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2534
2568
    break;
2535
2569
 
2536
2570
  case 141:
2537
 
#line 926 "awkgram.y"
 
2571
#line 930 "awkgram.y"
2538
2572
    {
2539
 
                  if (yyvsp[0].nodeval->type == Node_val && (yyvsp[0].nodeval->flags & (STRCUR|STRING)) == 0) {
2540
 
                        yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
2541
 
                        yyval.nodeval = yyvsp[0].nodeval;
 
2573
                  if ((yyvsp[0].nodeval)->type == Node_val && ((yyvsp[0].nodeval)->flags & (STRCUR|STRING)) == 0) {
 
2574
                        (yyvsp[0].nodeval)->numbr = -(force_number((yyvsp[0].nodeval)));
 
2575
                        (yyval.nodeval) = (yyvsp[0].nodeval);
2542
2576
                  } else
2543
 
                        yyval.nodeval = node(yyvsp[0].nodeval, Node_unary_minus, (NODE *) NULL);
 
2577
                        (yyval.nodeval) = node((yyvsp[0].nodeval), Node_unary_minus, (NODE *) NULL);
2544
2578
                }
2545
2579
    break;
2546
2580
 
2547
2581
  case 142:
2548
 
#line 934 "awkgram.y"
 
2582
#line 938 "awkgram.y"
2549
2583
    {
2550
2584
                  /*
2551
2585
                   * was: $$ = $2
2552
2586
                   * POSIX semantics: force a conversion to numeric type
2553
2587
                   */
2554
 
                  yyval.nodeval = node (make_number(0.0), Node_plus, yyvsp[0].nodeval);
 
2588
                  (yyval.nodeval) = node (make_number(0.0), Node_plus, (yyvsp[0].nodeval));
2555
2589
                }
2556
2590
    break;
2557
2591
 
2558
2592
  case 143:
2559
 
#line 945 "awkgram.y"
2560
 
    { yyval.nodeval = NULL; }
 
2593
#line 949 "awkgram.y"
 
2594
    { (yyval.nodeval) = NULL; }
2561
2595
    break;
2562
2596
 
2563
2597
  case 144:
2564
 
#line 947 "awkgram.y"
2565
 
    { yyval.nodeval = yyvsp[0].nodeval; }
 
2598
#line 951 "awkgram.y"
 
2599
    { (yyval.nodeval) = (yyvsp[0].nodeval); }
2566
2600
    break;
2567
2601
 
2568
2602
  case 145:
2569
 
#line 952 "awkgram.y"
2570
 
    { yyval.nodeval = variable(yyvsp[0].sval, CAN_FREE, Node_var_new); }
 
2603
#line 956 "awkgram.y"
 
2604
    { (yyval.nodeval) = variable((yyvsp[0].sval), CAN_FREE, Node_var_new); }
2571
2605
    break;
2572
2606
 
2573
2607
  case 146:
2574
 
#line 954 "awkgram.y"
 
2608
#line 958 "awkgram.y"
2575
2609
    {
2576
2610
                NODE *n;
2577
2611
 
2578
 
                if ((n = lookup(yyvsp[-3].sval)) != NULL && ! isarray(n))
 
2612
                if ((n = lookup((yyvsp[-3].sval))) != NULL && ! isarray(n))
2579
2613
                        yyerror(_("use of non-array as array"));
2580
 
                else if (yyvsp[-1].nodeval == NULL) {
 
2614
                else if ((yyvsp[-1].nodeval) == NULL) {
2581
2615
                        fatal(_("invalid subscript expression"));
2582
 
                } else if (yyvsp[-1].nodeval->rnode == NULL) {
2583
 
                        yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval->lnode);
2584
 
                        freenode(yyvsp[-1].nodeval);
 
2616
                } else if ((yyvsp[-1].nodeval)->rnode == NULL) {
 
2617
                        (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[-1].nodeval)->lnode);
 
2618
                        freenode((yyvsp[-1].nodeval));
2585
2619
                } else
2586
 
                        yyval.nodeval = node(variable(yyvsp[-3].sval, CAN_FREE, Node_var_array), Node_subscript, yyvsp[-1].nodeval);
 
2620
                        (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[-1].nodeval));
2587
2621
          }
2588
2622
    break;
2589
2623
 
2590
2624
  case 147:
2591
 
#line 968 "awkgram.y"
2592
 
    { yyval.nodeval = node(yyvsp[0].nodeval, Node_field_spec, (NODE *) NULL); }
 
2625
#line 972 "awkgram.y"
 
2626
    { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_field_spec, (NODE *) NULL); }
2593
2627
    break;
2594
2628
 
2595
2629
  case 149:
2596
 
#line 976 "awkgram.y"
 
2630
#line 986 "awkgram.y"
2597
2631
    { yyerrok; }
2598
2632
    break;
2599
2633
 
2600
2634
  case 150:
2601
 
#line 980 "awkgram.y"
 
2635
#line 990 "awkgram.y"
2602
2636
    { yyerrok; }
2603
2637
    break;
2604
2638
 
2605
2639
  case 153:
2606
 
#line 989 "awkgram.y"
 
2640
#line 999 "awkgram.y"
2607
2641
    { yyerrok; }
2608
2642
    break;
2609
2643
 
2610
2644
  case 154:
2611
 
#line 993 "awkgram.y"
 
2645
#line 1003 "awkgram.y"
2612
2646
    { yyerrok; }
2613
2647
    break;
2614
2648
 
2615
2649
  case 155:
2616
 
#line 996 "awkgram.y"
 
2650
#line 1006 "awkgram.y"
2617
2651
    { yyerrok; }
2618
2652
    break;
2619
2653
 
2620
2654
 
2621
2655
    }
2622
2656
 
2623
 
/* Line 991 of yacc.c.  */
2624
 
#line 2622 "y.tab.c"
 
2657
/* Line 1037 of yacc.c.  */
 
2658
#line 2661 "y.tab.c"
2625
2659
 
2626
2660
  yyvsp -= yylen;
2627
2661
  yyssp -= yylen;
2662
2696
        {
2663
2697
          YYSIZE_T yysize = 0;
2664
2698
          int yytype = YYTRANSLATE (yychar);
 
2699
          const char* yyprefix;
2665
2700
          char *yymsg;
2666
 
          int yyx, yycount;
 
2701
          int yyx;
2667
2702
 
2668
 
          yycount = 0;
2669
2703
          /* Start YYX at -YYN if negative to avoid negative indexes in
2670
2704
             YYCHECK.  */
2671
 
          for (yyx = yyn < 0 ? -yyn : 0;
2672
 
               yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
 
2705
          int yyxbegin = yyn < 0 ? -yyn : 0;
 
2706
 
 
2707
          /* Stay within bounds of both yycheck and yytname.  */
 
2708
          int yychecklim = YYLAST - yyn;
 
2709
          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
2710
          int yycount = 0;
 
2711
 
 
2712
          yyprefix = ", expecting ";
 
2713
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2673
2714
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2674
 
              yysize += yystrlen (yytname[yyx]) + 15, yycount++;
2675
 
          yysize += yystrlen ("syntax error, unexpected ") + 1;
2676
 
          yysize += yystrlen (yytname[yytype]);
 
2715
              {
 
2716
                yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
 
2717
                yycount += 1;
 
2718
                if (yycount == 5)
 
2719
                  {
 
2720
                    yysize = 0;
 
2721
                    break;
 
2722
                  }
 
2723
              }
 
2724
          yysize += (sizeof ("syntax error, unexpected ")
 
2725
                     + yystrlen (yytname[yytype]));
2677
2726
          yymsg = (char *) YYSTACK_ALLOC (yysize);
2678
2727
          if (yymsg != 0)
2679
2728
            {
2682
2731
 
2683
2732
              if (yycount < 5)
2684
2733
                {
2685
 
                  yycount = 0;
2686
 
                  for (yyx = yyn < 0 ? -yyn : 0;
2687
 
                       yyx < (int) (sizeof (yytname) / sizeof (char *));
2688
 
                       yyx++)
 
2734
                  yyprefix = ", expecting ";
 
2735
                  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2689
2736
                    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2690
2737
                      {
2691
 
                        const char *yyq = ! yycount ? ", expecting " : " or ";
2692
 
                        yyp = yystpcpy (yyp, yyq);
 
2738
                        yyp = yystpcpy (yyp, yyprefix);
2693
2739
                        yyp = yystpcpy (yyp, yytname[yyx]);
2694
 
                        yycount++;
 
2740
                        yyprefix = " or ";
2695
2741
                      }
2696
2742
                }
2697
2743
              yyerror (yymsg);
2709
2755
 
2710
2756
  if (yyerrstatus == 3)
2711
2757
    {
2712
 
      /* If just tried and failed to reuse lookahead token after an
 
2758
      /* If just tried and failed to reuse look-ahead token after an
2713
2759
         error, discard it.  */
2714
2760
 
2715
 
      /* Return failure if at end of input.  */
2716
 
      if (yychar == YYEOF)
 
2761
      if (yychar <= YYEOF)
2717
2762
        {
2718
 
          /* Pop the error token.  */
2719
 
          YYPOPSTACK;
2720
 
          /* Pop the rest of the stack.  */
2721
 
          while (yyss < yyssp)
2722
 
            {
2723
 
              YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2724
 
              yydestruct (yystos[*yyssp], yyvsp);
2725
 
              YYPOPSTACK;
2726
 
            }
2727
 
          YYABORT;
 
2763
          /* If at end of input, pop the error token,
 
2764
             then the rest of the stack, then return failure.  */
 
2765
          if (yychar == YYEOF)
 
2766
             for (;;)
 
2767
               {
 
2768
 
 
2769
                 YYPOPSTACK;
 
2770
                 if (yyssp == yyss)
 
2771
                   YYABORT;
 
2772
                 yydestruct ("Error: popping",
 
2773
                             yystos[*yyssp], yyvsp);
 
2774
               }
2728
2775
        }
2729
 
 
2730
 
      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2731
 
      yydestruct (yytoken, &yylval);
2732
 
      yychar = YYEMPTY;
2733
 
 
 
2776
      else
 
2777
        {
 
2778
          yydestruct ("Error: discarding", yytoken, &yylval);
 
2779
          yychar = YYEMPTY;
 
2780
        }
2734
2781
    }
2735
2782
 
2736
 
  /* Else will try to reuse lookahead token after shifting the error
 
2783
  /* Else will try to reuse look-ahead token after shifting the error
2737
2784
     token.  */
2738
 
  goto yyerrlab2;
2739
 
 
2740
 
 
2741
 
/*----------------------------------------------------.
2742
 
| yyerrlab1 -- error raised explicitly by an action.  |
2743
 
`----------------------------------------------------*/
 
2785
  goto yyerrlab1;
 
2786
 
 
2787
 
 
2788
/*---------------------------------------------------.
 
2789
| yyerrorlab -- error raised explicitly by YYERROR.  |
 
2790
`---------------------------------------------------*/
 
2791
yyerrorlab:
 
2792
 
 
2793
#ifdef __GNUC__
 
2794
  /* Pacify GCC when the user code never invokes YYERROR and the label
 
2795
     yyerrorlab therefore never appears in user code.  */
 
2796
  if (0)
 
2797
     goto yyerrorlab;
 
2798
#endif
 
2799
 
 
2800
yyvsp -= yylen;
 
2801
  yyssp -= yylen;
 
2802
  yystate = *yyssp;
 
2803
  goto yyerrlab1;
 
2804
 
 
2805
 
 
2806
/*-------------------------------------------------------------.
 
2807
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
 
2808
`-------------------------------------------------------------*/
2744
2809
yyerrlab1:
2745
 
 
2746
 
  /* Suppress GCC warning that yyerrlab1 is unused when no action
2747
 
     invokes YYERROR.  */
2748
 
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
2749
 
  __attribute__ ((__unused__))
2750
 
#endif
2751
 
 
2752
 
 
2753
 
  goto yyerrlab2;
2754
 
 
2755
 
 
2756
 
/*---------------------------------------------------------------.
2757
 
| yyerrlab2 -- pop states until the error token can be shifted.  |
2758
 
`---------------------------------------------------------------*/
2759
 
yyerrlab2:
2760
2810
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2761
2811
 
2762
2812
  for (;;)
2777
2827
      if (yyssp == yyss)
2778
2828
        YYABORT;
2779
2829
 
2780
 
      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2781
 
      yydestruct (yystos[yystate], yyvsp);
2782
 
      yyvsp--;
2783
 
      yystate = *--yyssp;
2784
2830
 
 
2831
      yydestruct ("Error: popping", yystos[yystate], yyvsp);
 
2832
      YYPOPSTACK;
 
2833
      yystate = *yyssp;
2785
2834
      YY_STACK_PRINT (yyss, yyssp);
2786
2835
    }
2787
2836
 
2788
2837
  if (yyn == YYFINAL)
2789
2838
    YYACCEPT;
2790
2839
 
2791
 
  YYDPRINTF ((stderr, "Shifting error token, "));
2792
 
 
2793
2840
  *++yyvsp = yylval;
2794
2841
 
2795
2842
 
 
2843
  /* Shift the error token. */
 
2844
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
2845
 
2796
2846
  yystate = yyn;
2797
2847
  goto yynewstate;
2798
2848
 
2808
2858
| yyabortlab -- YYABORT comes here.  |
2809
2859
`-----------------------------------*/
2810
2860
yyabortlab:
 
2861
  yydestruct ("Error: discarding lookahead",
 
2862
              yytoken, &yylval);
 
2863
  yychar = YYEMPTY;
2811
2864
  yyresult = 1;
2812
2865
  goto yyreturn;
2813
2866
 
2830
2883
}
2831
2884
 
2832
2885
 
2833
 
#line 999 "awkgram.y"
 
2886
#line 1009 "awkgram.y"
2834
2887
 
2835
2888
 
2836
2889
struct token {
2940
2993
/* This macro means that last nextc() return a singlebyte character
2941
2994
   or 1st byte of a multibyte character.  */
2942
2995
#define nextc_is_1stbyte (cur_char_ring[cur_ring_idx] == 1)
 
2996
#else /* MBS_SUPPORT */
 
2997
/* a dummy */
 
2998
#define nextc_is_1stbyte 1
2943
2999
#endif /* MBS_SUPPORT */
2944
3000
 
2945
3001
/* getfname --- return name of a builtin function (for pretty printing) */
3267
3323
static int
3268
3324
nextc(void)
3269
3325
{
3270
 
        if (gawk_mb_cur_max > 1)        {
 
3326
        if (gawk_mb_cur_max > 1) {
 
3327
                if (!lexptr || lexptr >= lexend) {
 
3328
                        if (! get_src_buf())
 
3329
                                return EOF;
 
3330
                }
 
3331
 
3271
3332
                /* Update the buffer index.  */
3272
3333
                cur_ring_idx = (cur_ring_idx == RING_BUFFER_SIZE - 1)? 0 :
3273
3334
                        cur_ring_idx + 1;
3279
3340
                        mbstate_t tmp_state;
3280
3341
                        size_t mbclen;
3281
3342
 
3282
 
                        if (!lexptr || lexptr >= lexend)
3283
 
                                if (!get_src_buf()) {
3284
 
                                        return EOF;
3285
 
                                }
3286
 
 
3287
3343
                        for (idx = 0 ; lexptr + idx < lexend ; idx++) {
3288
3344
                                tmp_state = cur_mbstate;
3289
3345
                                mbclen = mbrlen(lexptr, idx + 1, &tmp_state);
3357
3413
 
3358
3414
/* pushback --- push a character back on the input */
3359
3415
 
3360
 
#ifdef MBS_SUPPORT
3361
 
 
3362
 
static void
 
3416
static inline void
3363
3417
pushback(void)
3364
3418
{
3365
 
        if (gawk_mb_cur_max > 1) {
 
3419
#ifdef MBS_SUPPORT
 
3420
        if (gawk_mb_cur_max > 1)
3366
3421
                cur_ring_idx = (cur_ring_idx == 0)? RING_BUFFER_SIZE - 1 :
3367
3422
                        cur_ring_idx - 1;
3368
 
                (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
3369
 
        } else
3370
 
                (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
 
3423
#endif
 
3424
        (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
3371
3425
}
3372
3426
 
3373
 
#else
3374
 
 
3375
 
#define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
3376
 
 
3377
 
#endif /* MBS_SUPPORT */
3378
3427
 
3379
3428
/* allow_newline --- allow newline after &&, ||, ? and : */
3380
3429
 
3465
3514
                tok = tokstart;
3466
3515
                for (;;) {
3467
3516
                        c = nextc();
3468
 
#ifdef MBS_SUPPORT
3469
 
                        if (gawk_mb_cur_max == 1 || nextc_is_1stbyte)
3470
 
#endif
3471
 
                        switch (c) {
 
3517
 
 
3518
                        if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) switch (c) {
3472
3519
                        case '[':
3473
3520
                                /* one day check for `.' and `=' too */
3474
3521
                                if (nextc() == ':' || in_brack == 0)
3503
3550
end_regexp:
3504
3551
                                tokadd('\0');
3505
3552
                                yylval.sval = tokstart;
 
3553
                                if (do_lint) {
 
3554
                                        int peek = nextc();
 
3555
 
 
3556
                                        pushback();
 
3557
                                        if (peek == 'i' || peek == 's') {
 
3558
                                                if (source)
 
3559
                                                        lintwarn(
 
3560
                                                _("%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk"),
 
3561
                                                                source, sourceline, peek);
 
3562
                                                else
 
3563
                                                        lintwarn(
 
3564
                                                _("tawk regex modifier `/.../%c' doesn't work in gawk"),
 
3565
                                                                peek);
 
3566
                                        }
 
3567
                                }
3506
3568
                                return lasttok = REGEXP;
3507
3569
                        case '\n':
3508
3570
                                pushback();
3516
3578
                }
3517
3579
        }
3518
3580
retry:
3519
 
        while ((c = nextc()) == ' ' || c == '\t')
 
3581
 
 
3582
        /* skipping \r is a hack, but windows is just too pervasive. sigh. */
 
3583
        while ((c = nextc()) == ' ' || c == '\t' || c == '\r')
3520
3584
                continue;
3521
3585
 
3522
3586
        lexeme = lexptr ? lexptr - 1 : lexptr;
3524
3588
        tok = tokstart;
3525
3589
        yylval.nodetypeval = Node_illegal;
3526
3590
 
3527
 
#ifdef MBS_SUPPORT
3528
 
        if (gawk_mb_cur_max == 1 || nextc_is_1stbyte)
3529
 
#endif
3530
 
        switch (c) {
 
3591
        if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) switch (c) {
3531
3592
        case EOF:
3532
3593
                if (lasttok != NEWLINE) {
3533
3594
                        lasttok = NEWLINE;
3571
3632
                 */
3572
3633
                if (! do_traditional) {
3573
3634
                        /* strip trailing white-space and/or comment */
3574
 
                        while ((c = nextc()) == ' ' || c == '\t')
 
3635
                        while ((c = nextc()) == ' ' || c == '\t' || c == '\r')
3575
3636
                                continue;
3576
3637
                        if (c == '#') {
3577
3638
                                if (do_lint)
3772
3833
                                yyerror(_("unterminated string"));
3773
3834
                                exit(1);
3774
3835
                        }
3775
 
#ifdef MBS_SUPPORT
3776
 
                        if (gawk_mb_cur_max == 1 || nextc_is_1stbyte)
3777
 
#endif
3778
 
                        if (c == '\\') {
 
3836
                        if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) &&
 
3837
                            c == '\\') {
3779
3838
                                c = nextc();
3780
3839
                                if (c == '\n') {
3781
3840
                                        sourceline++;
3841
3900
                        case 'X':
3842
3901
                                if (do_traditional)
3843
3902
                                        goto done;
3844
 
                                if (tok == tokstart + 2)
3845
 
                                        inhex = TRUE;
 
3903
                                if (tok == tokstart + 2) {
 
3904
                                        int peek = nextc();
 
3905
 
 
3906
                                        if (ISXDIGIT(peek)) {
 
3907
                                                inhex = TRUE;
 
3908
                                                pushback();     /* following digit */
 
3909
                                        } else {
 
3910
                                                pushback();     /* x or X */
 
3911
                                                goto done;
 
3912
                                        }
 
3913
                                }
3846
3914
                                break;
3847
3915
                        case '.':
3848
 
                                if (seen_point) {
 
3916
                                /* period ends exponent part of floating point number */
 
3917
                                if (seen_point || seen_e) {
3849
3918
                                        gotnumber = TRUE;
3850
3919
                                        break;
3851
3920
                                }
3860
3929
                                        break;
3861
3930
                                }
3862
3931
                                seen_e = TRUE;
3863
 
                                if ((c = nextc()) == '-' || c == '+')
3864
 
                                        tokadd(c);
3865
 
                                else
3866
 
                                        pushback();
 
3932
                                if ((c = nextc()) == '-' || c == '+') {
 
3933
                                        int c2 = nextc();
 
3934
 
 
3935
                                        if (ISDIGIT(c2)) {
 
3936
                                                tokadd(c);
 
3937
                                                tokadd(c2);
 
3938
                                        } else {
 
3939
                                                pushback();     /* non-digit after + or - */
 
3940
                                                pushback();     /* + or - */
 
3941
                                                pushback();     /* e or E */
 
3942
                                        }
 
3943
                                } else if (! ISDIGIT(c)) {
 
3944
                                        pushback();     /* character after e or E */
 
3945
                                        pushback();     /* e or E */
 
3946
                                } else {
 
3947
                                        pushback();     /* digit */
 
3948
                                }
3867
3949
                                break;
3868
3950
                        case 'a':
3869
3951
                        case 'A':
3904
3986
                        eof_warned = TRUE;
3905
3987
                }
3906
3988
                tokadd('\0');
3907
 
                if (! do_traditional && isnondecimal(tokstart)) {
3908
 
                        static short warned = FALSE;
3909
 
                        if (do_lint && ! warned) {
3910
 
                                warned = TRUE;
3911
 
                                lintwarn("numeric constant `%.*s' treated as octal or hexadecimal",
3912
 
                                        strlen(tokstart)-1, tokstart);
 
3989
                if (! do_traditional && isnondecimal(tokstart, FALSE)) {
 
3990
                        if (do_lint) {
 
3991
                                if (ISDIGIT(tokstart[1]))       /* not an 'x' or 'X' */
 
3992
                                        lintwarn("numeric constant `%.*s' treated as octal",
 
3993
                                                (int) strlen(tokstart)-1, tokstart);
 
3994
                                else if (tokstart[1] == 'x' || tokstart[1] == 'X')
 
3995
                                        lintwarn("numeric constant `%.*s' treated as hexadecimal",
 
3996
                                                (int) strlen(tokstart)-1, tokstart);
3913
3997
                        }
3914
3998
                        yylval.nodeval = make_number(nondec2awknum(tokstart, strlen(tokstart)));
3915
3999
                } else
3955
4039
         *
3956
4040
         * print "xyzzy"$_"foo"
3957
4041
         *
3958
 
         * Without the check for ` lasttok != '$'' ', this is parsed as
 
4042
         * Without the check for ` lasttok != '$' ', this is parsed as
3959
4043
         *
3960
4044
         * print "xxyzz" $(_"foo")
3961
4045
         *
4856
4940
        }
4857
4941
}
4858
4942
 
 
4943
/* deferred varibles --- those that are only defined if needed. */
 
4944
 
 
4945
/*
 
4946
 * Is there any reason to use a hash table for deferred variables?  At the
 
4947
 * moment, there are only 1 to 3 such variables, so it may not be worth
 
4948
 * the overhead.  If more modules start using this facility, it should
 
4949
 * probably be converted into a hash table.
 
4950
 */
 
4951
 
 
4952
static struct deferred_variable {
 
4953
        NODE *(*load_func)(void);
 
4954
        struct deferred_variable *next;
 
4955
        char name[1];   /* variable-length array */
 
4956
} *deferred_variables;
 
4957
 
 
4958
/* register_deferred_variable --- add a var name and loading function to the list */
 
4959
 
 
4960
void
 
4961
register_deferred_variable(const char *name, NODE *(*load_func)(void))
 
4962
{
 
4963
        struct deferred_variable *dv;
 
4964
        size_t sl = strlen(name);
 
4965
 
 
4966
        emalloc(dv, struct deferred_variable *, sizeof(*dv)+sl,
 
4967
                "register_deferred_variable");
 
4968
        dv->load_func = load_func;
 
4969
        dv->next = deferred_variables;
 
4970
        memcpy(dv->name, name, sl+1);
 
4971
        deferred_variables = dv;
 
4972
}
 
4973
 
4859
4974
/* variable --- make sure NAME is in the symbol table */
4860
4975
 
4861
4976
NODE *
4870
4985
 
4871
4986
        } else {
4872
4987
                /* not found */
4873
 
                if (! do_traditional && STREQ(name, "PROCINFO"))
4874
 
                        r = load_procinfo();
4875
 
                else if (STREQ(name, "ENVIRON"))
4876
 
                        r = load_environ();
4877
 
                else {
4878
 
                        /*
4879
 
                         * This is the only case in which we may not free the string.
4880
 
                         */
4881
 
                        NODE *n;
4882
 
 
4883
 
                        if (type == Node_var_array)
4884
 
                                n = node((NODE *) NULL, type, (NODE *) NULL);
4885
 
                        else
4886
 
                                n = node(Nnull_string, type, (NODE *) NULL);
4887
 
 
4888
 
                        return install(name, n);
 
4988
                struct deferred_variable *dv;
 
4989
 
 
4990
                for (dv = deferred_variables; TRUE; dv = dv->next) {
 
4991
                        if (dv == NULL) {
 
4992
                                /*
 
4993
                                 * This is the only case in which we may not
 
4994
                                 * free the string.
 
4995
                                 */
 
4996
                                NODE *n;
 
4997
 
 
4998
                                if (type == Node_var_array)
 
4999
                                        n = node(NULL, type, NULL);
 
5000
                                else
 
5001
                                        n = node(Nnull_string, type, NULL);
 
5002
 
 
5003
                                return install(name, n);
 
5004
                        }
 
5005
                        if (STREQ(name, dv->name)) {
 
5006
                                r = (*dv->load_func)();
 
5007
                                break;
 
5008
                        }
4889
5009
                }
4890
5010
        }
4891
5011
        if (can_free)