diff options
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 2456 |
1 files changed, 1612 insertions, 844 deletions
@@ -1,30 +1,39 @@ -/* A Bison parser, made by GNU Bison 2.0. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* A Bison parser, made by GNU Bison 2.4.1. */ - This program is free software; you can redistribute it and/or modify +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -36,118 +45,29 @@ /* Identify Bison output. */ #define YYBISON 1 +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 -/* Using locations. */ -#define YYLSP_NEEDED 0 - - +/* Push parsers. */ +#define YYPUSH 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - FUNC_CALL = 258, - NAME = 259, - REGEXP = 260, - ERROR = 261, - YNUMBER = 262, - YSTRING = 263, - RELOP = 264, - IO_OUT = 265, - IO_IN = 266, - ASSIGNOP = 267, - ASSIGN = 268, - MATCHOP = 269, - CONCAT_OP = 270, - LEX_BEGIN = 271, - LEX_END = 272, - LEX_IF = 273, - LEX_ELSE = 274, - LEX_RETURN = 275, - LEX_DELETE = 276, - LEX_SWITCH = 277, - LEX_CASE = 278, - LEX_DEFAULT = 279, - LEX_WHILE = 280, - LEX_DO = 281, - LEX_FOR = 282, - LEX_BREAK = 283, - LEX_CONTINUE = 284, - LEX_PRINT = 285, - LEX_PRINTF = 286, - LEX_NEXT = 287, - LEX_EXIT = 288, - LEX_FUNCTION = 289, - LEX_GETLINE = 290, - LEX_NEXTFILE = 291, - LEX_IN = 292, - LEX_AND = 293, - LEX_OR = 294, - INCREMENT = 295, - DECREMENT = 296, - LEX_BUILTIN = 297, - LEX_LENGTH = 298, - NEWLINE = 299, - SLASH_BEFORE_EQUAL = 300, - UNARY = 301 - }; -#endif -#define FUNC_CALL 258 -#define NAME 259 -#define REGEXP 260 -#define ERROR 261 -#define YNUMBER 262 -#define YSTRING 263 -#define RELOP 264 -#define IO_OUT 265 -#define IO_IN 266 -#define ASSIGNOP 267 -#define ASSIGN 268 -#define MATCHOP 269 -#define CONCAT_OP 270 -#define LEX_BEGIN 271 -#define LEX_END 272 -#define LEX_IF 273 -#define LEX_ELSE 274 -#define LEX_RETURN 275 -#define LEX_DELETE 276 -#define LEX_SWITCH 277 -#define LEX_CASE 278 -#define LEX_DEFAULT 279 -#define LEX_WHILE 280 -#define LEX_DO 281 -#define LEX_FOR 282 -#define LEX_BREAK 283 -#define LEX_CONTINUE 284 -#define LEX_PRINT 285 -#define LEX_PRINTF 286 -#define LEX_NEXT 287 -#define LEX_EXIT 288 -#define LEX_FUNCTION 289 -#define LEX_GETLINE 290 -#define LEX_NEXTFILE 291 -#define LEX_IN 292 -#define LEX_AND 293 -#define LEX_OR 294 -#define INCREMENT 295 -#define DECREMENT 296 -#define LEX_BUILTIN 297 -#define LEX_LENGTH 298 -#define NEWLINE 299 -#define SLASH_BEFORE_EQUAL 300 -#define UNARY 301 +/* Pull parsers. */ +#define YYPULL 1 +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 26 "awkgram.y" #ifdef GAWKDEBUG @@ -197,6 +117,9 @@ static void check_funcs P((void)); static ssize_t read_one_line P((int fd, void *buffer, size_t count)); static int one_line_close P((int fd)); +static NODE *constant_fold P((NODE *left, NODETYPE op, NODE *right)); +static NODE *optimize_concat P((NODE *left, NODETYPE op, NODE *right)); + static int want_regexp; /* lexical scanning kludge */ static int can_return; /* parsing kludge */ static int begin_or_end_rule = FALSE; /* parsing kludge */ @@ -240,6 +163,9 @@ extern NODE *end_block; static char builtin_func[] = "@builtin"; +/* Line 189 of yacc.c */ +#line 168 "y.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -253,39 +179,229 @@ static char builtin_func[] = "@builtin"; # define YYERROR_VERBOSE 0 #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 117 "awkgram.y" -typedef union YYSTYPE { +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + FUNC_CALL = 258, + NAME = 259, + REGEXP = 260, + ERROR = 261, + YNUMBER = 262, + YSTRING = 263, + RELOP = 264, + IO_OUT = 265, + IO_IN = 266, + ASSIGNOP = 267, + ASSIGN = 268, + MATCHOP = 269, + CONCAT_OP = 270, + LEX_BEGIN = 271, + LEX_END = 272, + LEX_IF = 273, + LEX_ELSE = 274, + LEX_RETURN = 275, + LEX_DELETE = 276, + LEX_SWITCH = 277, + LEX_CASE = 278, + LEX_DEFAULT = 279, + LEX_WHILE = 280, + LEX_DO = 281, + LEX_FOR = 282, + LEX_BREAK = 283, + LEX_CONTINUE = 284, + LEX_PRINT = 285, + LEX_PRINTF = 286, + LEX_NEXT = 287, + LEX_EXIT = 288, + LEX_FUNCTION = 289, + LEX_GETLINE = 290, + LEX_NEXTFILE = 291, + LEX_IN = 292, + LEX_AND = 293, + LEX_OR = 294, + INCREMENT = 295, + DECREMENT = 296, + LEX_BUILTIN = 297, + LEX_LENGTH = 298, + NEWLINE = 299, + SLASH_BEFORE_EQUAL = 300, + UNARY = 301 + }; +#endif +/* Tokens. */ +#define FUNC_CALL 258 +#define NAME 259 +#define REGEXP 260 +#define ERROR 261 +#define YNUMBER 262 +#define YSTRING 263 +#define RELOP 264 +#define IO_OUT 265 +#define IO_IN 266 +#define ASSIGNOP 267 +#define ASSIGN 268 +#define MATCHOP 269 +#define CONCAT_OP 270 +#define LEX_BEGIN 271 +#define LEX_END 272 +#define LEX_IF 273 +#define LEX_ELSE 274 +#define LEX_RETURN 275 +#define LEX_DELETE 276 +#define LEX_SWITCH 277 +#define LEX_CASE 278 +#define LEX_DEFAULT 279 +#define LEX_WHILE 280 +#define LEX_DO 281 +#define LEX_FOR 282 +#define LEX_BREAK 283 +#define LEX_CONTINUE 284 +#define LEX_PRINT 285 +#define LEX_PRINTF 286 +#define LEX_NEXT 287 +#define LEX_EXIT 288 +#define LEX_FUNCTION 289 +#define LEX_GETLINE 290 +#define LEX_NEXTFILE 291 +#define LEX_IN 292 +#define LEX_AND 293 +#define LEX_OR 294 +#define INCREMENT 295 +#define DECREMENT 296 +#define LEX_BUILTIN 297 +#define LEX_LENGTH 298 +#define NEWLINE 299 +#define SLASH_BEFORE_EQUAL 300 +#define UNARY 301 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 120 "awkgram.y" + long lval; AWKNUM fval; NODE *nodeval; NODETYPE nodetypeval; char *sval; NODE *(*ptrval) P((void)); + + + +/* Line 214 of yacc.c */ +#line 307 "y.tab.c" } YYSTYPE; -/* Line 185 of yacc.c. */ -#line 268 "y.tab.c" +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 213 of yacc.c. */ -#line 280 "y.tab.c" +/* Line 264 of yacc.c */ +#line 319 "y.tab.c" -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#ifdef short +# undef short +#endif -# ifndef YYFREE -# define YYFREE free +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int # endif -# ifndef YYMALLOC -# define YYMALLOC malloc +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid # endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -293,34 +409,78 @@ typedef union YYSTYPE { # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca # else # define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif +# else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) && (! defined (__cplusplus) || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short int yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -328,24 +488,24 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ - register YYSIZE_T yyi; \ + YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -354,48 +514,42 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 5 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 1088 -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 67 -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS 56 -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES 165 -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 308 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 301 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -433,7 +587,7 @@ static const unsigned char yytranslate[] = #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned short int yyprhs[] = +static const yytype_uint16 yyprhs[] = { 0, 0, 3, 7, 8, 11, 14, 17, 20, 23, 24, 26, 30, 32, 34, 40, 42, 44, 46, 48, @@ -454,8 +608,8 @@ static const unsigned short int yyprhs[] = 517, 519, 520, 522, 524, 526 }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = { 68, 0, -1, 97, 69, 97, -1, -1, 69, 70, -1, 69, 1, -1, 71, 72, -1, 71, 81, -1, @@ -513,31 +667,31 @@ static const yysigned_char yyrhs[] = }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = +static const yytype_uint16 yyrline[] = { - 0, 178, 178, 184, 186, 191, 203, 207, 222, 233, - 236, 240, 250, 259, 271, 276, 278, 280, 291, 292, - 297, 296, 320, 319, 345, 346, 351, 352, 370, 375, - 376, 380, 382, 384, 386, 388, 390, 392, 436, 440, - 445, 448, 451, 460, 484, 487, 486, 496, 508, 508, - 539, 541, 559, 581, 587, 588, 593, 646, 647, 664, - 669, 671, 676, 678, 683, 685, 687, 692, 693, 701, - 702, 708, 713, 713, 725, 730, 737, 738, 741, 743, - 748, 749, 755, 756, 761, 763, 765, 767, 769, 776, - 777, 783, 784, 789, 791, 797, 799, 801, 803, 808, - 827, 829, 831, 837, 843, 849, 851, 856, 858, 860, - 865, 867, 871, 872, 877, 879, 881, 886, 888, 890, - 892, 894, 896, 898, 900, 906, 908, 910, 923, 928, - 930, 932, 934, 936, 938, 943, 945, 947, 949, 952, - 954, 968, 976, 977, 979, 981, 983, 986, 994, 1006, - 1007, 1012, 1014, 1029, 1039, 1054, 1055, 1056, 1060, 1064, - 1068, 1071, 1073, 1077, 1081, 1084 + 0, 181, 181, 187, 189, 194, 206, 210, 225, 236, + 239, 243, 253, 262, 274, 279, 281, 283, 294, 295, + 300, 299, 323, 322, 348, 349, 354, 355, 373, 378, + 379, 383, 385, 387, 389, 391, 393, 395, 439, 443, + 448, 451, 454, 463, 487, 490, 489, 499, 511, 511, + 542, 544, 562, 584, 590, 591, 596, 649, 650, 667, + 672, 674, 679, 681, 686, 688, 690, 695, 696, 704, + 705, 711, 716, 716, 728, 733, 740, 741, 744, 746, + 751, 752, 758, 759, 764, 766, 768, 770, 772, 779, + 780, 786, 787, 792, 794, 800, 802, 804, 806, 811, + 817, 819, 821, 827, 833, 839, 841, 846, 848, 850, + 855, 857, 861, 862, 867, 869, 871, 876, 878, 880, + 882, 884, 886, 888, 890, 896, 898, 900, 913, 918, + 920, 922, 924, 926, 928, 933, 935, 937, 939, 942, + 944, 958, 966, 967, 969, 971, 973, 976, 984, 996, + 997, 1002, 1004, 1019, 1029, 1044, 1045, 1046, 1050, 1054, + 1058, 1061, 1063, 1067, 1071, 1074 }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "FUNC_CALL", "NAME", "REGEXP", "ERROR", @@ -552,23 +706,23 @@ static const char *const yytname[] = "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", "'('", "')'", "'['", "']'", "'{'", "'}'", "';'", "$accept", "start", "program", "rule", "pattern", "action", "func_name", "lex_builtin", "function_prologue", - "@1", "regexp", "@2", "a_slash", "statements", "statement_term", - "statement", "@3", "simple_stmt", "@4", "opt_simple_stmt", "switch_body", - "case_statements", "case_statement", "case_value", "print", - "print_expression_list", "output_redir", "@5", "if_statement", "nls", - "opt_nls", "input_redir", "opt_param_list", "param_list", "opt_exp", - "opt_expression_list", "expression_list", "exp", "assign_operator", - "relop_or_less", "a_relop", "common_exp", "simp_exp", "simp_exp_nc", - "non_post_simp_exp", "opt_variable", "variable", "field_spec", - "opt_incdec", "l_brace", "r_brace", "r_paren", "opt_semi", "semi", - "colon", "comma", 0 + "$@1", "regexp", "$@2", "a_slash", "statements", "statement_term", + "statement", "$@3", "simple_stmt", "$@4", "opt_simple_stmt", + "switch_body", "case_statements", "case_statement", "case_value", + "print", "print_expression_list", "output_redir", "$@5", "if_statement", + "nls", "opt_nls", "input_redir", "opt_param_list", "param_list", + "opt_exp", "opt_expression_list", "expression_list", "exp", + "assign_operator", "relop_or_less", "a_relop", "common_exp", "simp_exp", + "simp_exp_nc", "non_post_simp_exp", "opt_variable", "variable", + "field_spec", "opt_incdec", "l_brace", "r_brace", "r_paren", "opt_semi", + "semi", "colon", "comma", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -581,7 +735,7 @@ static const unsigned short int yytoknum[] = # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = +static const yytype_uint8 yyr1[] = { 0, 67, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 71, 72, 73, 73, 73, 74, 74, @@ -603,7 +757,7 @@ static const unsigned char yyr1[] = }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = +static const yytype_uint8 yyr2[] = { 0, 2, 3, 0, 2, 2, 2, 2, 2, 0, 1, 3, 1, 1, 5, 1, 1, 1, 1, 1, @@ -627,7 +781,7 @@ static const unsigned char yyr2[] = /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const unsigned char yydefact[] = +static const yytype_uint8 yydefact[] = { 78, 76, 0, 79, 3, 1, 77, 0, 5, 0, 151, 145, 146, 12, 13, 20, 149, 0, 0, 0, @@ -662,8 +816,8 @@ static const unsigned char yydefact[] = 78, 0, 26, 0, 0, 39, 0, 38 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = { -1, 2, 7, 28, 29, 62, 108, 109, 30, 43, 31, 68, 32, 125, 63, 177, 193, 178, 208, 226, @@ -676,7 +830,7 @@ static const short int yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -221 -static const short int yypact[] = +static const yytype_int16 yypact[] = { -32, -221, 35, -3, -221, -221, -221, 343, -221, -13, -4, -221, -221, -221, -221, -221, 32, 32, 32, -6, @@ -712,7 +866,7 @@ static const short int yypact[] = }; /* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = +static const yytype_int16 yypgoto[] = { -221, -221, -221, -221, -221, 169, -221, -221, -221, -221, -85, -221, -221, -173, -39, -169, -221, -184, -221, -220, @@ -727,7 +881,7 @@ static const short int yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -93 -static const short int yytable[] = +static const yytype_int16 yytable[] = { 33, 45, 46, 47, 58, 65, 65, 51, 51, 209, 51, 56, 1, 112, 113, 225, -93, 231, 1, 103, @@ -840,7 +994,7 @@ static const short int yytable[] = 23, 0, 24, 0, 25, 0, 0, 26, 54 }; -static const short int yycheck[] = +static const yytype_int16 yycheck[] = { 7, 16, 17, 18, 27, 29, 30, 22, 23, 182, 25, 26, 44, 48, 49, 199, 9, 209, 44, 42, @@ -955,7 +1109,7 @@ static const short int yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const unsigned char yystos[] = +static const yytype_uint8 yystos[] = { 0, 44, 68, 96, 97, 0, 44, 69, 1, 3, 4, 7, 8, 16, 17, 34, 35, 40, 41, 42, @@ -990,22 +1144,6 @@ static const unsigned char yystos[] = 118, 97, 97, 80, 97, 82, 80, 82 }; -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -1031,15 +1169,15 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ - { \ - yyerror ("syntax error: cannot back up");\ + { \ + yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) #define YYTERROR 1 @@ -1054,7 +1192,7 @@ while (0) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ - if (N) \ + if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ @@ -1068,7 +1206,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (YYID (0)) #endif @@ -1080,8 +1218,8 @@ while (0) # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -1108,37 +1246,100 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (short int *bottom, short int *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - short int *bottom; - short int *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -1146,37 +1347,45 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void -yy_reduce_print (yyrule) +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; int yyrule; #endif { + int yynrhs = yyr2[yyrule]; int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1198,7 +1407,7 @@ int yydebug; if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH @@ -1210,45 +1419,47 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else +#else +static YYSIZE_T yystrlen (yystr) - const char *yystr; -# endif + const char *yystr; +#endif { - register const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else +#else +static char * yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif + char *yydest; + const char *yysrc; +#endif { - register char *yyd = yydest; - register const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; @@ -1258,53 +1469,171 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } - + if (! yyres) + return yystrlen (yystr); -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ + return yystpcpy (yyres, yystr) - yyres; +} +# endif -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + int yyn = yypact[yystate]; - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - default: - break; + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - YYFPRINTF (yyoutput, ")"); } +#endif /* YYERROR_VERBOSE */ + -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else @@ -1315,8 +1644,7 @@ yydestruct (yymsg, yytype, yyvaluep) YYSTYPE *yyvaluep; #endif { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; @@ -1326,21 +1654,19 @@ yydestruct (yymsg, yytype, yyvaluep) { default: - break; + break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); -# else +#else int yyparse (); -# endif +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); @@ -1348,11 +1674,10 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ - -/* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ @@ -1360,19 +1685,23 @@ int yynerrs; -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else @@ -1382,66 +1711,71 @@ yyparse () #endif #endif { - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - register short int *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK (yyvsp--, yyssp--) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; - - yyvsp[0] = yylval; - goto yysetstate; /*------------------------------------------------------------. @@ -1449,8 +1783,7 @@ yyparse () `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -1463,21 +1796,19 @@ yyparse () #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; - + yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", + yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1485,24 +1816,23 @@ yyparse () } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1513,7 +1843,6 @@ yyparse () yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1523,6 +1852,9 @@ yyparse () YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1530,19 +1862,17 @@ yyparse () `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to look-ahead token. */ + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1574,25 +1904,20 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + yystate = yyn; + *++yyvsp = yylval; + goto yynewstate; @@ -1628,14 +1953,18 @@ yyreduce: switch (yyn) { case 2: -#line 179 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 182 "awkgram.y" { check_funcs(); } break; case 4: -#line 187 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 190 "awkgram.y" { begin_or_end_rule = parsing_end_rule = FALSE; yyerrok; @@ -1643,7 +1972,9 @@ yyreduce: break; case 5: -#line 192 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 195 "awkgram.y" { begin_or_end_rule = parsing_end_rule = FALSE; /* @@ -1655,18 +1986,22 @@ yyreduce: break; case 6: -#line 204 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 207 "awkgram.y" { - (yyvsp[-1].nodeval)->rnode = (yyvsp[0].nodeval); + (yyvsp[(1) - (2)].nodeval)->rnode = (yyvsp[(2) - (2)].nodeval); } break; case 7: -#line 208 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 211 "awkgram.y" { - if ((yyvsp[-1].nodeval)->lnode != NULL) { + if ((yyvsp[(1) - (2)].nodeval)->lnode != NULL) { /* pattern rule with non-empty pattern */ - (yyvsp[-1].nodeval)->rnode = node(NULL, Node_K_print_rec, NULL); + (yyvsp[(1) - (2)].nodeval)->rnode = node(NULL, Node_K_print_rec, NULL); } else { /* an error */ if (begin_or_end_rule) @@ -1680,44 +2015,54 @@ yyreduce: break; case 8: -#line 223 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 226 "awkgram.y" { can_return = FALSE; - if ((yyvsp[-1].nodeval)) - func_install((yyvsp[-1].nodeval), (yyvsp[0].nodeval)); + if ((yyvsp[(1) - (2)].nodeval)) + func_install((yyvsp[(1) - (2)].nodeval), (yyvsp[(2) - (2)].nodeval)); yyerrok; } break; case 9: -#line 233 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 236 "awkgram.y" { (yyval.nodeval) = append_pattern(&expression_value, (NODE *) NULL); } break; case 10: -#line 237 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 240 "awkgram.y" { - (yyval.nodeval) = append_pattern(&expression_value, (yyvsp[0].nodeval)); + (yyval.nodeval) = append_pattern(&expression_value, (yyvsp[(1) - (1)].nodeval)); } break; case 11: -#line 241 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 244 "awkgram.y" { NODE *r; getnode(r); r->type = Node_line_range; - r->condpair = node((yyvsp[-2].nodeval), Node_cond_pair, (yyvsp[0].nodeval)); + r->condpair = node((yyvsp[(1) - (3)].nodeval), Node_cond_pair, (yyvsp[(3) - (3)].nodeval)); r->triggered = FALSE; (yyval.nodeval) = append_pattern(&expression_value, r); } break; case 12: -#line 251 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 254 "awkgram.y" { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -1729,7 +2074,9 @@ yyreduce: break; case 13: -#line 260 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 263 "awkgram.y" { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -1741,22 +2088,30 @@ yyreduce: break; case 14: -#line 272 "awkgram.y" - { (yyval.nodeval) = (yyvsp[-3].nodeval); } + +/* Line 1455 of yacc.c */ +#line 275 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(2) - (5)].nodeval); } break; case 15: -#line 277 "awkgram.y" - { (yyval.sval) = (yyvsp[0].sval); } + +/* Line 1455 of yacc.c */ +#line 280 "awkgram.y" + { (yyval.sval) = (yyvsp[(1) - (1)].sval); } break; case 16: -#line 279 "awkgram.y" - { (yyval.sval) = (yyvsp[0].sval); } + +/* Line 1455 of yacc.c */ +#line 282 "awkgram.y" + { (yyval.sval) = (yyvsp[(1) - (1)].sval); } break; case 17: -#line 281 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 284 "awkgram.y" { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); @@ -1767,20 +2122,24 @@ yyreduce: break; case 20: -#line 297 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 300 "awkgram.y" { param_counter = 0; } break; case 21: -#line 301 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 304 "awkgram.y" { NODE *t; - t = make_param((yyvsp[-4].sval)); + t = make_param((yyvsp[(3) - (7)].sval)); t->flags |= FUNC; - (yyval.nodeval) = append_right(t, (yyvsp[-2].nodeval)); + (yyval.nodeval) = append_right(t, (yyvsp[(5) - (7)].nodeval)); can_return = TRUE; /* check for duplicate parameter names */ if (dup_parms((yyval.nodeval))) @@ -1789,97 +2148,121 @@ yyreduce: break; case 22: -#line 320 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 323 "awkgram.y" { ++want_regexp; } break; case 23: -#line 322 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 325 "awkgram.y" { NODE *n; - size_t len = strlen((yyvsp[0].sval)); + size_t len = strlen((yyvsp[(3) - (3)].sval)); if (do_lint) { if (len == 0) lintwarn(_("regexp constant `//' looks like a C++ comment, but is not")); - else if (((yyvsp[0].sval))[0] == '*' && ((yyvsp[0].sval))[len-1] == '*') + else if (((yyvsp[(3) - (3)].sval))[0] == '*' && ((yyvsp[(3) - (3)].sval))[len-1] == '*') /* possible C comment */ lintwarn(_("regexp constant `/%s/' looks like a C comment, but is not"), tokstart); } getnode(n); n->type = Node_regex; - n->re_exp = make_string((yyvsp[0].sval), len); - n->re_reg = make_regexp((yyvsp[0].sval), len, FALSE, TRUE); + n->re_exp = make_string((yyvsp[(3) - (3)].sval), len); + n->re_reg = make_regexp((yyvsp[(3) - (3)].sval), len, FALSE, TRUE); n->re_text = NULL; - n->re_flags = CONST; + n->re_flags = CONSTANT; n->re_cnt = 1; (yyval.nodeval) = n; } break; case 26: -#line 351 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 354 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 27: -#line 353 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 356 "awkgram.y" { - if ((yyvsp[0].nodeval) == NULL) - (yyval.nodeval) = (yyvsp[-1].nodeval); + if ((yyvsp[(2) - (2)].nodeval) == NULL) + (yyval.nodeval) = (yyvsp[(1) - (2)].nodeval); else { - if (do_lint && isnoeffect((yyvsp[0].nodeval)->type)) + if (do_lint && isnoeffect((yyvsp[(2) - (2)].nodeval)->type)) lintwarn(_("statement may have no effect")); - if ((yyvsp[-1].nodeval) == NULL) - (yyval.nodeval) = (yyvsp[0].nodeval); + if ((yyvsp[(1) - (2)].nodeval) == NULL) + (yyval.nodeval) = (yyvsp[(2) - (2)].nodeval); else (yyval.nodeval) = append_right( - ((yyvsp[-1].nodeval)->type == Node_statement_list ? (yyvsp[-1].nodeval) - : node((yyvsp[-1].nodeval), Node_statement_list, (NODE *) NULL)), - ((yyvsp[0].nodeval)->type == Node_statement_list ? (yyvsp[0].nodeval) - : node((yyvsp[0].nodeval), Node_statement_list, (NODE *) NULL))); + ((yyvsp[(1) - (2)].nodeval)->type == Node_statement_list ? (yyvsp[(1) - (2)].nodeval) + : node((yyvsp[(1) - (2)].nodeval), Node_statement_list, (NODE *) NULL)), + ((yyvsp[(2) - (2)].nodeval)->type == Node_statement_list ? (yyvsp[(2) - (2)].nodeval) + : node((yyvsp[(2) - (2)].nodeval), Node_statement_list, (NODE *) NULL))); } yyerrok; } break; case 28: -#line 371 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 374 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 31: -#line 381 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 384 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 32: -#line 383 "awkgram.y" - { (yyval.nodeval) = (yyvsp[-1].nodeval); } + +/* Line 1455 of yacc.c */ +#line 386 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(2) - (3)].nodeval); } break; case 33: -#line 385 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 388 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 34: -#line 387 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-6].nodeval), Node_K_switch, (yyvsp[-2].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 390 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(3) - (9)].nodeval), Node_K_switch, (yyvsp[(7) - (9)].nodeval)); } break; case 35: -#line 389 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_while, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 392 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(3) - (6)].nodeval), Node_K_while, (yyvsp[(6) - (6)].nodeval)); } break; case 36: -#line 391 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_K_do, (yyvsp[-5].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 394 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(6) - (8)].nodeval), Node_K_do, (yyvsp[(3) - (8)].nodeval)); } break; case 37: -#line 393 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 396 "awkgram.y" { /* * Efficiency hack. Recognize the special case of @@ -1894,12 +2277,12 @@ yyreduce: * Check that the body is a `delete a[i]' statement, * and that both the loop var and array names match. */ - if ((yyvsp[0].nodeval) != NULL && (yyvsp[0].nodeval)->type == Node_K_delete && (yyvsp[0].nodeval)->rnode != NULL) { + if ((yyvsp[(8) - (8)].nodeval) != NULL && (yyvsp[(8) - (8)].nodeval)->type == Node_K_delete && (yyvsp[(8) - (8)].nodeval)->rnode != NULL) { NODE *arr, *sub; - assert((yyvsp[0].nodeval)->rnode->type == Node_expression_list); - arr = (yyvsp[0].nodeval)->lnode; /* array var */ - sub = (yyvsp[0].nodeval)->rnode->lnode; /* index var */ + assert((yyvsp[(8) - (8)].nodeval)->rnode->type == Node_expression_list); + arr = (yyvsp[(8) - (8)].nodeval)->lnode; /* array var */ + sub = (yyvsp[(8) - (8)].nodeval)->rnode->lnode; /* index var */ if ( (arr->type == Node_var_new || arr->type == Node_var_array @@ -1907,51 +2290,61 @@ yyreduce: && (sub->type == Node_var_new || sub->type == Node_var || sub->type == Node_param_list) - && strcmp((yyvsp[-5].sval), sub->vname) == 0 - && strcmp((yyvsp[-3].sval), arr->vname) == 0) { - (yyvsp[0].nodeval)->type = Node_K_delete_loop; - (yyval.nodeval) = (yyvsp[0].nodeval); - free((yyvsp[-5].sval)); /* thanks to valgrind for pointing these out */ - free((yyvsp[-3].sval)); + && strcmp((yyvsp[(3) - (8)].sval), sub->vname) == 0 + && strcmp((yyvsp[(5) - (8)].sval), arr->vname) == 0) { + (yyvsp[(8) - (8)].nodeval)->type = Node_K_delete_loop; + (yyval.nodeval) = (yyvsp[(8) - (8)].nodeval); + free((yyvsp[(3) - (8)].sval)); /* thanks to valgrind for pointing these out */ + free((yyvsp[(5) - (8)].sval)); } else goto regular_loop; } else { regular_loop: - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_arrayfor, - make_for_loop(variable((yyvsp[-5].sval), CAN_FREE, Node_var), - (NODE *) NULL, variable((yyvsp[-3].sval), CAN_FREE, Node_var_array))); + (yyval.nodeval) = node((yyvsp[(8) - (8)].nodeval), Node_K_arrayfor, + make_for_loop(variable((yyvsp[(3) - (8)].sval), CAN_FREE, Node_var), + (NODE *) NULL, variable((yyvsp[(5) - (8)].sval), CAN_FREE, Node_var_array))); } } break; case 38: -#line 437 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 440 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_for, (NODE *) make_for_loop((yyvsp[-9].nodeval), (yyvsp[-6].nodeval), (yyvsp[-3].nodeval))); + (yyval.nodeval) = node((yyvsp[(12) - (12)].nodeval), Node_K_for, (NODE *) make_for_loop((yyvsp[(3) - (12)].nodeval), (yyvsp[(6) - (12)].nodeval), (yyvsp[(9) - (12)].nodeval))); } break; case 39: -#line 441 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 444 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_for, - (NODE *) make_for_loop((yyvsp[-8].nodeval), (NODE *) NULL, (yyvsp[-3].nodeval))); + (yyval.nodeval) = node((yyvsp[(11) - (11)].nodeval), Node_K_for, + (NODE *) make_for_loop((yyvsp[(3) - (11)].nodeval), (NODE *) NULL, (yyvsp[(8) - (11)].nodeval))); } break; case 40: -#line 447 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 450 "awkgram.y" { (yyval.nodeval) = node((NODE *) NULL, Node_K_break, (NODE *) NULL); } break; case 41: -#line 450 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 453 "awkgram.y" { (yyval.nodeval) = node((NODE *) NULL, Node_K_continue, (NODE *) NULL); } break; case 42: -#line 452 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 455 "awkgram.y" { NODETYPE type; if (begin_or_end_rule) @@ -1963,7 +2356,9 @@ yyreduce: break; case 43: -#line 461 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 464 "awkgram.y" { static short warned = FALSE; @@ -1990,12 +2385,16 @@ yyreduce: break; case 44: -#line 485 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_K_exit, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 488 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (3)].nodeval), Node_K_exit, (NODE *) NULL); } break; case 45: -#line 487 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 490 "awkgram.y" { if (! can_return) yyerror(_("`return' used outside function context")); @@ -2003,20 +2402,26 @@ yyreduce: break; case 46: -#line 492 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 495 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[-1].nodeval) == NULL ? Nnull_string : (yyvsp[-1].nodeval), + (yyval.nodeval) = node((yyvsp[(3) - (4)].nodeval) == NULL ? Nnull_string : (yyvsp[(3) - (4)].nodeval), Node_K_return, (NODE *) NULL); } break; case 48: -#line 508 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 511 "awkgram.y" { in_print = TRUE; in_parens = 0; } break; case 49: -#line 509 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 512 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2024,25 +2429,25 @@ yyreduce: * and lnode is a field spec for field 0, we have `print $0'. * For both, use Node_K_print_rec, which is faster for these two cases. */ - if ((yyvsp[-3].nodetypeval) == Node_K_print && - ((yyvsp[-1].nodeval) == NULL - || ((yyvsp[-1].nodeval)->type == Node_expression_list - && (yyvsp[-1].nodeval)->rnode == NULL - && (yyvsp[-1].nodeval)->lnode->type == Node_field_spec - && (yyvsp[-1].nodeval)->lnode->lnode->type == Node_val - && (yyvsp[-1].nodeval)->lnode->lnode->numbr == 0.0)) + if ((yyvsp[(1) - (4)].nodetypeval) == Node_K_print && + ((yyvsp[(3) - (4)].nodeval) == NULL + || ((yyvsp[(3) - (4)].nodeval)->type == Node_expression_list + && (yyvsp[(3) - (4)].nodeval)->rnode == NULL + && (yyvsp[(3) - (4)].nodeval)->lnode->type == Node_field_spec + && (yyvsp[(3) - (4)].nodeval)->lnode->lnode->type == Node_val + && (yyvsp[(3) - (4)].nodeval)->lnode->lnode->numbr == 0.0)) ) { static short warned = FALSE; - (yyval.nodeval) = node(NULL, Node_K_print_rec, (yyvsp[0].nodeval)); + (yyval.nodeval) = node(NULL, Node_K_print_rec, (yyvsp[(4) - (4)].nodeval)); - if (do_lint && (yyvsp[-1].nodeval) == NULL && begin_or_end_rule && ! warned) { + if (do_lint && (yyvsp[(3) - (4)].nodeval) == NULL && begin_or_end_rule && ! warned) { warned = TRUE; lintwarn( _("plain `print' in BEGIN or END rule should probably be `print \"\"'")); } } else { - (yyval.nodeval) = node((yyvsp[-1].nodeval), (yyvsp[-3].nodetypeval), (yyvsp[0].nodeval)); + (yyval.nodeval) = node((yyvsp[(3) - (4)].nodeval), (yyvsp[(1) - (4)].nodetypeval), (yyvsp[(4) - (4)].nodeval)); if ((yyval.nodeval)->type == Node_K_printf) count_args((yyval.nodeval)); } @@ -2050,12 +2455,16 @@ yyreduce: break; case 50: -#line 540 "awkgram.y" - { (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_K_delete, (yyvsp[-1].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 543 "awkgram.y" + { (yyval.nodeval) = node(variable((yyvsp[(2) - (5)].sval), CAN_FREE, Node_var_array), Node_K_delete, (yyvsp[(4) - (5)].nodeval)); } break; case 51: -#line 542 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 545 "awkgram.y" { static short warned = FALSE; @@ -2071,12 +2480,14 @@ yyreduce: errcount++; error(_("`delete array' is a gawk extension")); } - (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL); + (yyval.nodeval) = node(variable((yyvsp[(2) - (2)].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL); } break; case 52: -#line 560 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 563 "awkgram.y" { /* * this is for tawk compatibility. maybe the warnings @@ -2096,33 +2507,41 @@ yyreduce: errcount++; error(_("`delete(array)' is a non-portable tawk extension")); } - (yyval.nodeval) = node(variable((yyvsp[-1].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL); + (yyval.nodeval) = node(variable((yyvsp[(3) - (4)].sval), CAN_FREE, Node_var_array), Node_K_delete, (NODE *) NULL); } break; case 53: -#line 582 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 585 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 54: -#line 587 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 590 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 55: -#line 589 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 592 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 56: -#line 594 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 597 "awkgram.y" { - if ((yyvsp[0].nodeval) == NULL) { + if ((yyvsp[(1) - (1)].nodeval) == NULL) { (yyval.nodeval) = NULL; } else { NODE *dflt = NULL; - NODE *head = (yyvsp[0].nodeval); + NODE *head = (yyvsp[(1) - (1)].nodeval); NODE *curr; const char **case_values = NULL; @@ -2132,7 +2551,7 @@ yyreduce: int i; emalloc(case_values, const char **, sizeof(char*) * maxcount, "switch_body"); - for (curr = (yyvsp[0].nodeval); curr != NULL; curr = curr->rnode) { + for (curr = (yyvsp[(1) - (1)].nodeval); curr != NULL; curr = curr->rnode) { /* Assure that case statement values are unique. */ if (curr->lnode->type == Node_K_case) { char *caseval; @@ -2168,24 +2587,28 @@ yyreduce: break; case 57: -#line 646 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 649 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 58: -#line 648 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 651 "awkgram.y" { - if ((yyvsp[0].nodeval) == NULL) - (yyval.nodeval) = (yyvsp[-1].nodeval); + if ((yyvsp[(2) - (2)].nodeval) == NULL) + (yyval.nodeval) = (yyvsp[(1) - (2)].nodeval); else { - if (do_lint && isnoeffect((yyvsp[0].nodeval)->type)) + if (do_lint && isnoeffect((yyvsp[(2) - (2)].nodeval)->type)) lintwarn(_("statement may have no effect")); - if ((yyvsp[-1].nodeval) == NULL) - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_case_list, (NODE *) NULL); + if ((yyvsp[(1) - (2)].nodeval) == NULL) + (yyval.nodeval) = node((yyvsp[(2) - (2)].nodeval), Node_case_list, (NODE *) NULL); else (yyval.nodeval) = append_right( - ((yyvsp[-1].nodeval)->type == Node_case_list ? (yyvsp[-1].nodeval) : node((yyvsp[-1].nodeval), Node_case_list, (NODE *) NULL)), - ((yyvsp[0].nodeval)->type == Node_case_list ? (yyvsp[0].nodeval) : node((yyvsp[0].nodeval), Node_case_list, (NODE *) NULL)) + ((yyvsp[(1) - (2)].nodeval)->type == Node_case_list ? (yyvsp[(1) - (2)].nodeval) : node((yyvsp[(1) - (2)].nodeval), Node_case_list, (NODE *) NULL)), + ((yyvsp[(2) - (2)].nodeval)->type == Node_case_list ? (yyvsp[(2) - (2)].nodeval) : node((yyvsp[(2) - (2)].nodeval), Node_case_list, (NODE *) NULL)) ); } yyerrok; @@ -2193,55 +2616,75 @@ yyreduce: break; case 59: -#line 665 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 668 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 60: -#line 670 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_case, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 673 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (5)].nodeval), Node_K_case, (yyvsp[(5) - (5)].nodeval)); } break; case 61: -#line 672 "awkgram.y" - { (yyval.nodeval) = node((NODE *) NULL, Node_K_default, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 675 "awkgram.y" + { (yyval.nodeval) = node((NODE *) NULL, Node_K_default, (yyvsp[(4) - (4)].nodeval)); } break; case 62: -#line 677 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 680 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 63: -#line 679 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 682 "awkgram.y" { - (yyvsp[0].nodeval)->numbr = -(force_number((yyvsp[0].nodeval))); - (yyval.nodeval) = (yyvsp[0].nodeval); + (yyvsp[(2) - (2)].nodeval)->numbr = -(force_number((yyvsp[(2) - (2)].nodeval))); + (yyval.nodeval) = (yyvsp[(2) - (2)].nodeval); } break; case 64: -#line 684 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 687 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(2) - (2)].nodeval); } break; case 65: -#line 686 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 689 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 66: -#line 688 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 691 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 70: -#line 703 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_expression_list, (yyvsp[-1].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 706 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (5)].nodeval), Node_expression_list, (yyvsp[(4) - (5)].nodeval)); } break; case 71: -#line 708 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 711 "awkgram.y" { in_print = FALSE; in_parens = 0; @@ -2250,374 +2693,487 @@ yyreduce: break; case 72: -#line 713 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 716 "awkgram.y" { in_print = FALSE; in_parens = 0; } break; case 73: -#line 714 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 717 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[0].nodeval), (yyvsp[-2].nodetypeval), (NODE *) NULL); - if ((yyvsp[-2].nodetypeval) == Node_redirect_twoway - && (yyvsp[0].nodeval)->type == Node_K_getline - && (yyvsp[0].nodeval)->rnode != NULL - && (yyvsp[0].nodeval)->rnode->type == Node_redirect_twoway) + (yyval.nodeval) = node((yyvsp[(3) - (3)].nodeval), (yyvsp[(1) - (3)].nodetypeval), (NODE *) NULL); + if ((yyvsp[(1) - (3)].nodetypeval) == Node_redirect_twoway + && (yyvsp[(3) - (3)].nodeval)->type == Node_K_getline + && (yyvsp[(3) - (3)].nodeval)->rnode != NULL + && (yyvsp[(3) - (3)].nodeval)->rnode->type == Node_redirect_twoway) yyerror(_("multistage two-way pipelines don't work")); } break; case 74: -#line 726 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 729 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[-3].nodeval), Node_K_if, - node((yyvsp[0].nodeval), Node_if_branches, (NODE *) NULL)); + (yyval.nodeval) = node((yyvsp[(3) - (6)].nodeval), Node_K_if, + node((yyvsp[(6) - (6)].nodeval), Node_if_branches, (NODE *) NULL)); } break; case 75: -#line 732 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-6].nodeval), Node_K_if, - node((yyvsp[-3].nodeval), Node_if_branches, (yyvsp[0].nodeval))); } + +/* Line 1455 of yacc.c */ +#line 735 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(3) - (9)].nodeval), Node_K_if, + node((yyvsp[(6) - (9)].nodeval), Node_if_branches, (yyvsp[(9) - (9)].nodeval))); } break; case 80: -#line 748 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 751 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 81: -#line 750 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_redirect_input, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 753 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (2)].nodeval), Node_redirect_input, (NODE *) NULL); } break; case 82: -#line 755 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 758 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 83: -#line 757 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 760 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 84: -#line 762 "awkgram.y" - { (yyval.nodeval) = make_param((yyvsp[0].sval)); } + +/* Line 1455 of yacc.c */ +#line 765 "awkgram.y" + { (yyval.nodeval) = make_param((yyvsp[(1) - (1)].sval)); } break; case 85: -#line 764 "awkgram.y" - { (yyval.nodeval) = append_right((yyvsp[-2].nodeval), make_param((yyvsp[0].sval))); yyerrok; } + +/* Line 1455 of yacc.c */ +#line 767 "awkgram.y" + { (yyval.nodeval) = append_right((yyvsp[(1) - (3)].nodeval), make_param((yyvsp[(3) - (3)].sval))); yyerrok; } break; case 86: -#line 766 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 769 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 87: -#line 768 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 771 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 88: -#line 770 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 773 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 89: -#line 776 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 779 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 90: -#line 778 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 781 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 91: -#line 783 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 786 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 92: -#line 785 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 788 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 93: -#line 790 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_expression_list, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 793 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (1)].nodeval), Node_expression_list, (NODE *) NULL); } break; case 94: -#line 792 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 795 "awkgram.y" { - (yyval.nodeval) = append_right((yyvsp[-2].nodeval), - node((yyvsp[0].nodeval), Node_expression_list, (NODE *) NULL)); + (yyval.nodeval) = append_right((yyvsp[(1) - (3)].nodeval), + node((yyvsp[(3) - (3)].nodeval), Node_expression_list, (NODE *) NULL)); yyerrok; } break; case 95: -#line 798 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 801 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 96: -#line 800 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 803 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 97: -#line 802 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 805 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 98: -#line 804 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 807 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 99: -#line 809 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 812 "awkgram.y" { - if (do_lint && (yyvsp[0].nodeval)->type == Node_regex) + if (do_lint && (yyvsp[(3) - (3)].nodeval)->type == Node_regex) lintwarn(_("regular expression on right of assignment")); - /* - * Optimization of `x = x y'. Can save lots of time - * if done a lot. - */ - if (( (yyvsp[-2].nodeval)->type == Node_var - || (yyvsp[-2].nodeval)->type == Node_var_new - || (yyvsp[-2].nodeval)->type == Node_param_list) - && (yyvsp[-1].nodetypeval) == Node_assign - && (yyvsp[0].nodeval)->type == Node_concat - && (yyvsp[0].nodeval)->lnode == (yyvsp[-2].nodeval)) { - (yyvsp[0].nodeval)->type = Node_assign_concat; /* Just change the type */ - (yyval.nodeval) = (yyvsp[0].nodeval); /* And use it directly */ - } else - (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), (yyvsp[0].nodeval)); + (yyval.nodeval) = optimize_concat((yyvsp[(1) - (3)].nodeval), (yyvsp[(2) - (3)].nodetypeval), (yyvsp[(3) - (3)].nodeval)); } break; case 100: -#line 828 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_and, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 818 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_and, (yyvsp[(3) - (3)].nodeval)); } break; case 101: -#line 830 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_or, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 820 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_or, (yyvsp[(3) - (3)].nodeval)); } break; case 102: -#line 832 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 822 "awkgram.y" { - if ((yyvsp[-2].nodeval)->type == Node_regex) + if ((yyvsp[(1) - (3)].nodeval)->type == Node_regex) warning(_("regular expression on left of `~' or `!~' operator")); - (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), mk_rexp((yyvsp[0].nodeval))); + (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), (yyvsp[(2) - (3)].nodetypeval), mk_rexp((yyvsp[(3) - (3)].nodeval))); } break; case 103: -#line 838 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 828 "awkgram.y" { if (do_lint_old) warning(_("old awk does not support the keyword `in' except after `for'")); - (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[-2].nodeval)); + (yyval.nodeval) = node(variable((yyvsp[(3) - (3)].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[(1) - (3)].nodeval)); } break; case 104: -#line 844 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 834 "awkgram.y" { - if (do_lint && (yyvsp[0].nodeval)->type == Node_regex) + if (do_lint && (yyvsp[(3) - (3)].nodeval)->type == Node_regex) lintwarn(_("regular expression on right of comparison")); - (yyval.nodeval) = node((yyvsp[-2].nodeval), (yyvsp[-1].nodetypeval), (yyvsp[0].nodeval)); + (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), (yyvsp[(2) - (3)].nodetypeval), (yyvsp[(3) - (3)].nodeval)); } break; case 105: -#line 850 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-4].nodeval), Node_cond_exp, node((yyvsp[-2].nodeval), Node_if_branches, (yyvsp[0].nodeval)));} + +/* Line 1455 of yacc.c */ +#line 840 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (5)].nodeval), Node_cond_exp, node((yyvsp[(3) - (5)].nodeval), Node_if_branches, (yyvsp[(5) - (5)].nodeval)));} break; case 106: -#line 852 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 842 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 107: -#line 857 "awkgram.y" - { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); } + +/* Line 1455 of yacc.c */ +#line 847 "awkgram.y" + { (yyval.nodetypeval) = (yyvsp[(1) - (1)].nodetypeval); } break; case 108: -#line 859 "awkgram.y" - { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); } + +/* Line 1455 of yacc.c */ +#line 849 "awkgram.y" + { (yyval.nodetypeval) = (yyvsp[(1) - (1)].nodetypeval); } break; case 109: -#line 861 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 851 "awkgram.y" { (yyval.nodetypeval) = Node_assign_quotient; } break; case 110: -#line 866 "awkgram.y" - { (yyval.nodetypeval) = (yyvsp[0].nodetypeval); } + +/* Line 1455 of yacc.c */ +#line 856 "awkgram.y" + { (yyval.nodetypeval) = (yyvsp[(1) - (1)].nodetypeval); } break; case 111: -#line 868 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 858 "awkgram.y" { (yyval.nodetypeval) = Node_less; } break; case 113: -#line 873 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 863 "awkgram.y" { (yyval.nodetypeval) = Node_greater; } break; case 114: -#line 878 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 868 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 115: -#line 880 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 870 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 116: -#line 882 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_concat, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 872 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (2)].nodeval), Node_concat, (yyvsp[(2) - (2)].nodeval)); } break; case 118: -#line 889 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_exp, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 879 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_exp, (yyvsp[(3) - (3)].nodeval)); } break; case 119: -#line 891 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_times, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 881 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_times, (yyvsp[(3) - (3)].nodeval)); } break; case 120: -#line 893 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_quotient, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 883 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_quotient, (yyvsp[(3) - (3)].nodeval)); } break; case 121: -#line 895 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_mod, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 885 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_mod, (yyvsp[(3) - (3)].nodeval)); } break; case 122: -#line 897 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_plus, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 887 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_plus, (yyvsp[(3) - (3)].nodeval)); } break; case 123: -#line 899 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_minus, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 889 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(1) - (3)].nodeval), Node_minus, (yyvsp[(3) - (3)].nodeval)); } break; case 124: -#line 901 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 891 "awkgram.y" { - if (do_lint && parsing_end_rule && (yyvsp[0].nodeval) == NULL) + if (do_lint && parsing_end_rule && (yyvsp[(3) - (3)].nodeval) == NULL) lintwarn(_("non-redirected `getline' undefined inside END action")); - (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_K_getline, (yyvsp[0].nodeval)); + (yyval.nodeval) = node((yyvsp[(2) - (3)].nodeval), Node_K_getline, (yyvsp[(3) - (3)].nodeval)); } break; case 125: -#line 907 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_postincrement, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 897 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (2)].nodeval), Node_postincrement, (NODE *) NULL); } break; case 126: -#line 909 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_postdecrement, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 899 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (2)].nodeval), Node_postdecrement, (NODE *) NULL); } break; case 127: -#line 911 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 901 "awkgram.y" { if (do_lint_old) { warning(_("old awk does not support the keyword `in' except after `for'")); warning(_("old awk does not support multidimensional arrays")); } - (yyval.nodeval) = node(variable((yyvsp[0].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[-3].nodeval)); + (yyval.nodeval) = node(variable((yyvsp[(5) - (5)].sval), CAN_FREE, Node_var_array), Node_in_array, (yyvsp[(2) - (5)].nodeval)); } break; case 128: -#line 924 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 914 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_K_getline, - node((yyvsp[-3].nodeval), (yyvsp[-2].nodetypeval), (NODE *) NULL)); + (yyval.nodeval) = node((yyvsp[(4) - (4)].nodeval), Node_K_getline, + node((yyvsp[(1) - (4)].nodeval), (yyvsp[(2) - (4)].nodetypeval), (NODE *) NULL)); } break; case 129: -#line 929 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_exp, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 919 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_exp, (yyvsp[(3) - (3)].nodeval)); } break; case 130: -#line 931 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_times, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 921 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_times, (yyvsp[(3) - (3)].nodeval)); } break; case 131: -#line 933 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_quotient, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 923 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_quotient, (yyvsp[(3) - (3)].nodeval)); } break; case 132: -#line 935 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_mod, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 925 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_mod, (yyvsp[(3) - (3)].nodeval)); } break; case 133: -#line 937 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_plus, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 927 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_plus, (yyvsp[(3) - (3)].nodeval)); } break; case 134: -#line 939 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[-2].nodeval), Node_minus, (yyvsp[0].nodeval)); } + +/* Line 1455 of yacc.c */ +#line 929 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(1) - (3)].nodeval), Node_minus, (yyvsp[(3) - (3)].nodeval)); } break; case 135: -#line 944 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 934 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 136: -#line 946 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_not, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 936 "awkgram.y" + { (yyval.nodeval) = constant_fold((yyvsp[(2) - (2)].nodeval), Node_not, (NODE *) NULL); } break; case 137: -#line 948 "awkgram.y" - { (yyval.nodeval) = (yyvsp[-1].nodeval); } + +/* Line 1455 of yacc.c */ +#line 938 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(2) - (3)].nodeval); } break; case 138: -#line 951 "awkgram.y" - { (yyval.nodeval) = snode((yyvsp[-1].nodeval), Node_builtin, (int) (yyvsp[-3].lval)); } + +/* Line 1455 of yacc.c */ +#line 941 "awkgram.y" + { (yyval.nodeval) = snode((yyvsp[(3) - (4)].nodeval), Node_builtin, (int) (yyvsp[(1) - (4)].lval)); } break; case 139: -#line 953 "awkgram.y" - { (yyval.nodeval) = snode((yyvsp[-1].nodeval), Node_builtin, (int) (yyvsp[-3].lval)); } + +/* Line 1455 of yacc.c */ +#line 943 "awkgram.y" + { (yyval.nodeval) = snode((yyvsp[(3) - (4)].nodeval), Node_builtin, (int) (yyvsp[(1) - (4)].lval)); } break; case 140: -#line 955 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 945 "awkgram.y" { static short warned1 = FALSE, warned2 = FALSE; @@ -2625,7 +3181,7 @@ yyreduce: warned1 = TRUE; lintwarn(_("call of `length' without parentheses is not portable")); } - (yyval.nodeval) = snode((NODE *) NULL, Node_builtin, (int) (yyvsp[0].lval)); + (yyval.nodeval) = snode((NODE *) NULL, Node_builtin, (int) (yyvsp[(1) - (1)].lval)); if (do_posix && ! warned2) { warned2 = TRUE; warning(_("call of `length' without parentheses is deprecated by POSIX")); @@ -2634,102 +3190,128 @@ yyreduce: break; case 141: -#line 969 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 959 "awkgram.y" { - (yyval.nodeval) = node((yyvsp[-1].nodeval), Node_func_call, make_string((yyvsp[-3].sval), strlen((yyvsp[-3].sval)))); + (yyval.nodeval) = node((yyvsp[(3) - (4)].nodeval), Node_func_call, make_string((yyvsp[(1) - (4)].sval), strlen((yyvsp[(1) - (4)].sval)))); (yyval.nodeval)->funcbody = NULL; - func_use((yyvsp[-3].sval), FUNC_USE); - param_sanity((yyvsp[-1].nodeval)); - free((yyvsp[-3].sval)); + func_use((yyvsp[(1) - (4)].sval), FUNC_USE); + param_sanity((yyvsp[(3) - (4)].nodeval)); + free((yyvsp[(1) - (4)].sval)); } break; case 143: -#line 978 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_preincrement, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 968 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (2)].nodeval), Node_preincrement, (NODE *) NULL); } break; case 144: -#line 980 "awkgram.y" - { (yyval.nodeval) = node((yyvsp[0].nodeval), Node_predecrement, (NODE *) NULL); } + +/* Line 1455 of yacc.c */ +#line 970 "awkgram.y" + { (yyval.nodeval) = node((yyvsp[(2) - (2)].nodeval), Node_predecrement, (NODE *) NULL); } break; case 145: -#line 982 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 972 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 146: -#line 984 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 974 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 147: -#line 987 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 977 "awkgram.y" { - if ((yyvsp[0].nodeval)->type == Node_val && ((yyvsp[0].nodeval)->flags & (STRCUR|STRING)) == 0) { - (yyvsp[0].nodeval)->numbr = -(force_number((yyvsp[0].nodeval))); - (yyval.nodeval) = (yyvsp[0].nodeval); + if ((yyvsp[(2) - (2)].nodeval)->type == Node_val && ((yyvsp[(2) - (2)].nodeval)->flags & (STRCUR|STRING)) == 0) { + (yyvsp[(2) - (2)].nodeval)->numbr = -(force_number((yyvsp[(2) - (2)].nodeval))); + (yyval.nodeval) = (yyvsp[(2) - (2)].nodeval); } else - (yyval.nodeval) = node((yyvsp[0].nodeval), Node_unary_minus, (NODE *) NULL); + (yyval.nodeval) = node((yyvsp[(2) - (2)].nodeval), Node_unary_minus, (NODE *) NULL); } break; case 148: -#line 995 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 985 "awkgram.y" { /* * was: $$ = $2 * POSIX semantics: force a conversion to numeric type */ - (yyval.nodeval) = node (make_number(0.0), Node_plus, (yyvsp[0].nodeval)); + (yyval.nodeval) = node (make_number(0.0), Node_plus, (yyvsp[(2) - (2)].nodeval)); } break; case 149: -#line 1006 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 996 "awkgram.y" { (yyval.nodeval) = NULL; } break; case 150: -#line 1008 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 998 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 151: -#line 1013 "awkgram.y" - { (yyval.nodeval) = variable((yyvsp[0].sval), CAN_FREE, Node_var_new); } + +/* Line 1455 of yacc.c */ +#line 1003 "awkgram.y" + { (yyval.nodeval) = variable((yyvsp[(1) - (1)].sval), CAN_FREE, Node_var_new); } break; case 152: -#line 1015 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1005 "awkgram.y" { NODE *n; - if ((n = lookup((yyvsp[-3].sval))) != NULL && ! isarray(n)) { + if ((n = lookup((yyvsp[(1) - (4)].sval))) != NULL && ! isarray(n)) { yyerror(_("use of non-array as array")); - (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[-1].nodeval)); - } else if ((yyvsp[-1].nodeval) == NULL) { + (yyval.nodeval) = node(variable((yyvsp[(1) - (4)].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[(3) - (4)].nodeval)); + } else if ((yyvsp[(3) - (4)].nodeval) == NULL) { fatal(_("invalid subscript expression")); - } else if ((yyvsp[-1].nodeval)->rnode == NULL) { - (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[-1].nodeval)->lnode); - freenode((yyvsp[-1].nodeval)); + } else if ((yyvsp[(3) - (4)].nodeval)->rnode == NULL) { + (yyval.nodeval) = node(variable((yyvsp[(1) - (4)].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[(3) - (4)].nodeval)->lnode); + freenode((yyvsp[(3) - (4)].nodeval)); } else - (yyval.nodeval) = node(variable((yyvsp[-3].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[-1].nodeval)); + (yyval.nodeval) = node(variable((yyvsp[(1) - (4)].sval), CAN_FREE, Node_var_array), Node_subscript, (yyvsp[(3) - (4)].nodeval)); } break; case 153: -#line 1029 "awkgram.y" - { (yyval.nodeval) = (yyvsp[0].nodeval); } + +/* Line 1455 of yacc.c */ +#line 1019 "awkgram.y" + { (yyval.nodeval) = (yyvsp[(1) - (1)].nodeval); } break; case 154: -#line 1040 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1030 "awkgram.y" { - NODE *n = node((yyvsp[-1].nodeval), Node_field_spec, (NODE *) NULL); - if ((yyvsp[0].sval) != NULL) { - if ((yyvsp[0].sval)[0] == '+') + NODE *n = node((yyvsp[(2) - (3)].nodeval), Node_field_spec, (NODE *) NULL); + if ((yyvsp[(3) - (3)].sval) != NULL) { + if ((yyvsp[(3) - (3)].sval)[0] == '+') (yyval.nodeval) = node(n, Node_postincrement, (NODE *) NULL); else (yyval.nodeval) = node(n, Node_postdecrement, (NODE *) NULL); @@ -2740,60 +3322,75 @@ yyreduce: break; case 155: -#line 1054 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1044 "awkgram.y" { (yyval.sval) = "+"; } break; case 156: -#line 1055 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1045 "awkgram.y" { (yyval.sval) = "-"; } break; case 157: -#line 1056 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1046 "awkgram.y" { (yyval.sval) = NULL; } break; case 159: -#line 1064 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1054 "awkgram.y" { yyerrok; } break; case 160: -#line 1068 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1058 "awkgram.y" { yyerrok; } break; case 163: -#line 1077 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1067 "awkgram.y" { yyerrok; } break; case 164: -#line 1081 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1071 "awkgram.y" { yyerrok; } break; case 165: -#line 1084 "awkgram.y" + +/* Line 1455 of yacc.c */ +#line 1074 "awkgram.y" { yyerrok; } break; - } - -/* Line 1037 of yacc.c. */ -#line 2789 "y.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; +/* Line 1455 of yacc.c */ +#line 3384 "y.tab.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -2817,98 +3414,65 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); + } - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif } if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) - { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ + { + /* Return failure if at end of input. */ if (yychar == YYEOF) - for (;;) - { - - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - yydestruct ("Error: popping", - yystos[*yyssp], yyvsp); - } - } + YYABORT; + } else { - yydestruct ("Error: discarding", yytoken, &yylval); + yydestruct ("Error: discarding", + yytoken, &yylval); yychar = YYEMPTY; } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -2918,15 +3482,17 @@ yyerrlab: `---------------------------------------------------*/ yyerrorlab: -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) goto yyerrorlab; -#endif -yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -2956,19 +3522,17 @@ yyerrlab1: YYABORT; - yydestruct ("Error: popping", yystos[yystate], yyvsp); - YYPOPSTACK; + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; @@ -2986,32 +3550,49 @@ yyacceptlab: | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: - yydestruct ("Error: discarding lookahead", - yytoken, &yylval); - yychar = YYEMPTY; yyresult = 1; goto yyreturn; -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 1087 "awkgram.y" + +/* Line 1675 of yacc.c */ +#line 1077 "awkgram.y" struct token { @@ -3029,8 +3610,26 @@ struct token { NODE *(*ptr) P((NODE *)); /* function that implements this keyword */ }; -/* Tokentab is sorted ascii ascending order, so it can be binary searched. */ -/* Function pointers come from declarations in awk.h. */ +#if 'a' == 0x81 /* it's EBCDIC */ +/* tokcompare --- lexicographically compare token names for sorting */ + +static int +tokcompare(void *l, void *r) +{ + struct token *lhs, *rhs; + + lhs = (struct token *) l; + rhs = (struct token *) r; + + return strcmp(lhs->operator, rhs->operator); +} +#endif + +/* + * Tokentab is sorted ASCII ascending order, so it can be binary searched. + * See check_special(), which sorts the table on EBCDIC systems. + * Function pointers come from declarations in awk.h. + */ static const struct token tokentab[] = { {"BEGIN", Node_illegal, LEX_BEGIN, 0, 0}, @@ -3828,7 +4427,7 @@ retry: goto retry; } else { yyerror(_("backslash not last character on line")); - exit(1); + exit(EXIT_FAILURE); } break; @@ -4009,7 +4608,7 @@ retry: if (c == '\n') { pushback(); yyerror(_("unterminated string")); - exit(1); + exit(EXIT_FAILURE); } if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) && c == '\\') { @@ -4024,7 +4623,7 @@ retry: if (c == EOF) { pushback(); yyerror(_("unterminated string")); - exit(1); + exit(EXIT_FAILURE); } tokadd(c); } @@ -4209,7 +4808,7 @@ retry: if (c != '_' && ! ISALPHA(c)) { yyerror(_("invalid char '%c' in expression"), c); - exit(1); + exit(EXIT_FAILURE); } /* @@ -4920,6 +5519,9 @@ func_install(NODE *params, NODE *def) if (strcmp(n->param, params->param) == 0) fatal(_("function `%s': can't use function name as parameter name"), params->param); + else if (is_std_var(n->param)) + fatal(_("function `%s': can't use special variable `%s' as a function parameter"), + params->param, n->param); } thisfunc = NULL; /* turn off warnings */ @@ -5119,7 +5721,7 @@ param_sanity(NODE *arglist) } } -/* deferred varibles --- those that are only defined if needed. */ +/* deferred variables --- those that are only defined if needed. */ /* * Is there any reason to use a hash table for deferred variables? At the @@ -5410,6 +6012,16 @@ check_special(const char *name) { int low, high, mid; int i; +#if 'a' == 0x81 /* it's EBCDIC */ + static int did_sort = FALSE; + + if (! did_sort) { + qsort(tokentab, sizeof(tokentab) / sizeof(tokentab[0]), + sizeof(tokentab[0]), tokcompare); + did_sort = TRUE; + } +#endif + low = 0; high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1; @@ -5449,7 +6061,7 @@ read_one_line(int fd, void *buffer, size_t count) fp = fdopen(fd, "r"); if (fp == NULL) { fprintf(stderr, "ugh. fdopen: %s\n", strerror(errno)); - exit(1); + exit(EXIT_FAILURE); } } @@ -5475,4 +6087,160 @@ one_line_close(int fd) return ret; } +/* constant_fold --- try to fold constant operations */ + +static NODE * +constant_fold(NODE *left, NODETYPE op, NODE *right) +{ + AWKNUM result; + extern double fmod P((double x, double y)); + + if (! do_optimize) + return node(left, op, right); + + /* Unary not */ + if (right == NULL) { + if (op == Node_not && left->type == Node_val) { + if ((left->flags & (STRCUR|STRING)) != 0) { + NODE *ret; + if (left->stlen == 0) { + ret = make_number((AWKNUM) 1.0); + } else { + ret = make_number((AWKNUM) 0.0); + } + unref(left); + + return ret; + } else { + if (left->numbr == 0) { + left->numbr = 1.0; + } else { + left->numbr = 0.0; + } + + return left; + } + } + + return node(left, op, right); + } + + /* String concatentation of two string cnstants */ + if (op == Node_concat + && left->type == Node_val + && (left->flags & (STRCUR|STRING)) != 0 + && right->type == Node_val + && (right->flags & (STRCUR|STRING)) != 0) { + size_t newlen = left->stlen + right->stlen + 2; + + erealloc(left->stptr, char *, newlen, "constant_fold"); + memcpy(left->stptr + left->stlen, right->stptr, right->stlen); + left->stptr[left->stlen + right->stlen] = '\0'; + left->stlen += right->stlen; + + unref(right); + return left; + } + + /* + * From here down, numeric operations. + * Check for string and bail out if have them. + */ + if (left->type != Node_val + || (left->flags & (STRCUR|STRING)) != 0 + || right->type != Node_val + || (left->flags & (STRCUR|STRING)) != 0) { + return node(left, op, right); + } + + /* Numeric operations: */ + switch (op) { + case Node_not: + case Node_exp: + case Node_times: + case Node_quotient: + case Node_mod: + case Node_plus: + case Node_minus: + break; + default: + return node(left, op, right); + } + + left->numbr = force_number(left); + right->numbr = force_number(right); + + result = left->numbr; + switch (op) { + case Node_exp: + result = calc_exp(left->numbr, right->numbr); + break; + case Node_times: + result *= right->numbr; + break; + case Node_quotient: + result /= right->numbr; + break; + case Node_mod: + if (right->numbr == 0) + fatal(_("division by zero attempted in `%%'")); +#ifdef HAVE_FMOD + result = fmod(result, right->numbr); +#else /* ! HAVE_FMOD */ + (void) modf(left->numbr / right->numbr, &result); + result = left->numbr - result * right->numbr; +#endif /* ! HAVE_FMOD */ + break; + case Node_plus: + result += right->numbr; + break; + case Node_minus: + result -= right->numbr; + break; + default: + /* Shut up compiler warnings */ + fatal("can't happen"); + break; + } + + unref(right); + left->numbr = result; + + return left; +} + +/* optimize_concat --- optimize the general "x = x y z a" case */ + +static NODE * +optimize_concat(NODE *left, NODETYPE op, NODE *right) +{ + NODE *top, *leftmost; + + if (op != Node_assign) + return node(left, op, right); + + /* + * optimization of `x = x y'. can save lots of time + * if done a lot. + */ + if (( left->type == Node_var + || left->type == Node_var_new + || left->type == Node_param_list) + && right->type == Node_concat) { + /* find bottom of tree, save it */ + for (top = right; top->lnode != NULL && top->type == Node_concat; top = top->lnode) { + leftmost = top->lnode; + if (leftmost->type == Node_concat) + continue; + + /* at this point, we've run out of concatentation */ + if (leftmost != left) + return node(left, op, right); + + top->lnode = Nnull_string; + return node(left, Node_assign_concat, right); + } + } + return node(left, op, right); +} |