home *** CD-ROM | disk | FTP | other *** search
-
- /* A Bison parser, made from awk.y with Bison version GNU Bison version 1.22
- */
-
- #define YYBISON 1 /* Identify Bison output. */
-
- #define FUNC_CALL 258
- #define NAME 259
- #define REGEXP 260
- #define ERROR 261
- #define YNUMBER 262
- #define YSTRING 263
- #define RELOP 264
- #define APPEND_OP 265
- #define ASSIGNOP 266
- #define MATCHOP 267
- #define NEWLINE 268
- #define CONCAT_OP 269
- #define LEX_BEGIN 270
- #define LEX_END 271
- #define LEX_IF 272
- #define LEX_ELSE 273
- #define LEX_RETURN 274
- #define LEX_DELETE 275
- #define LEX_WHILE 276
- #define LEX_DO 277
- #define LEX_FOR 278
- #define LEX_BREAK 279
- #define LEX_CONTINUE 280
- #define LEX_PRINT 281
- #define LEX_PRINTF 282
- #define LEX_NEXT 283
- #define LEX_EXIT 284
- #define LEX_FUNCTION 285
- #define LEX_GETLINE 286
- #define LEX_IN 287
- #define LEX_AND 288
- #define LEX_OR 289
- #define INCREMENT 290
- #define DECREMENT 291
- #define LEX_BUILTIN 292
- #define LEX_LENGTH 293
- #define UNARY 294
-
- #line 26 "awk.y"
-
- #ifdef DEBUG
- #define YYDEBUG 12
- #endif
-
- #include "awk.h"
-
- static void yyerror (); /* va_alist */
- static char *get_src_buf P((void));
- static int yylex P((void));
- static NODE *node_common P((NODETYPE op));
- static NODE *snode P((NODE *subn, NODETYPE op, int sindex));
- static NODE *mkrangenode P((NODE *cpair));
- static NODE *make_for_loop P((NODE *init, NODE *cond, NODE *incr));
- static NODE *append_right P((NODE *list, NODE *new));
- static void func_install P((NODE *params, NODE *def));
- static void pop_var P((NODE *np, int freeit));
- static void pop_params P((NODE *params));
- static NODE *make_param P((char *name));
- static NODE *mk_rexp P((NODE *exp));
- static int dup_parms P((NODE *func));
-
- static int want_assign; /* lexical scanning kludge */
- static int want_regexp; /* lexical scanning kludge */
- static int can_return; /* lexical scanning kludge */
- static int io_allowed = 1; /* lexical scanning kludge */
- static char *lexptr; /* pointer to next char during parsing */
- static char *lexend;
- static char *lexptr_begin; /* keep track of where we were for error msgs */
- static char *lexeme; /* beginning of lexeme for debugging */
- static char *thisline = NULL;
- #define YYDEBUG_LEXER_TEXT (lexeme)
- static int param_counter;
- static char *tokstart = NULL;
- static char *tok = NULL;
- static char *tokend;
-
- #define HASHSIZE 1021 /* this constant only used here */
- NODE *variables[HASHSIZE];
-
- extern char *source;
- extern int sourceline;
- extern struct src *srcfiles;
- extern int numfiles;
- extern int errcount;
- extern NODE *begin_block;
- extern NODE *end_block;
-
- #line 75 "awk.y"
- typedef union {
- long lval;
- AWKNUM fval;
- NODE *nodeval;
- NODETYPE nodetypeval;
- char *sval;
- NODE *(*ptrval)();
- } YYSTYPE;
-
- #ifndef YYLTYPE
- typedef
- struct yyltype
- {
- int timestamp;
- int first_line;
- int first_column;
- int last_line;
- int last_column;
- char *text;
- }
- yyltype;
-
- #define YYLTYPE yyltype
- #endif
-
- #include <stdio.h>
-
- #ifndef __cplusplus
- #ifndef __STDC__
- #define const
- #endif
- #endif
-
-
-
- #define YYFINAL 310
- #define YYFLAG -32768
- #define YYNTBASE 61
-
- #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 106)
-
- static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 50, 2, 2, 53, 49, 2, 2, 54,
- 55, 47, 45, 41, 46, 2, 48, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 40, 60, 42,
- 2, 43, 39, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 56, 2, 57, 52, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 58, 44, 59, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 51
- };
-
- #if YYDEBUG != 0
- static const short yyprhs[] = { 0,
- 0, 4, 6, 9, 11, 14, 15, 16, 20, 21,
- 25, 28, 31, 34, 36, 39, 42, 44, 46, 48,
- 50, 52, 53, 61, 66, 71, 73, 77, 78, 83,
- 89, 94, 96, 99, 101, 104, 106, 109, 112, 115,
- 119, 121, 128, 137, 146, 157, 167, 170, 173, 180,
- 185, 189, 193, 194, 199, 206, 210, 213, 215, 217,
- 224, 234, 236, 239, 240, 242, 243, 246, 247, 250,
- 253, 256, 257, 259, 261, 265, 267, 270, 274, 275,
- 277, 278, 280, 282, 286, 288, 291, 295, 299, 300,
- 302, 304, 308, 310, 313, 317, 321, 322, 327, 333,
- 338, 342, 346, 350, 354, 356, 359, 363, 367, 371,
- 375, 381, 383, 386, 387, 392, 396, 400, 404, 406,
- 409, 413, 417, 421, 427, 429, 432, 434, 438, 442,
- 446, 450, 454, 458, 461, 464, 467, 471, 476, 481,
- 483, 488, 490, 493, 496, 498, 500, 503, 506, 507,
- 509, 511, 516, 519, 522, 525, 527, 528, 530, 532
- };
-
- static const short yyrhs[] = { 82,
- 62, 82, 0, 63, 0, 62, 63, 0, 1, 0,
- 62, 1, 0, 0, 0, 15, 64, 74, 0, 0,
- 16, 65, 74, 0, 15, 76, 0, 16, 76, 0,
- 71, 74, 0, 74, 0, 71, 76, 0, 68, 70,
- 0, 4, 0, 3, 0, 67, 0, 37, 0, 38,
- 0, 0, 30, 69, 66, 54, 85, 102, 82, 0,
- 100, 75, 101, 103, 0, 100, 101, 103, 82, 0,
- 92, 0, 92, 41, 92, 0, 0, 48, 73, 5,
- 48, 0, 100, 75, 101, 103, 82, 0, 100, 101,
- 103, 82, 0, 77, 0, 75, 77, 0, 1, 0,
- 75, 1, 0, 81, 0, 104, 82, 0, 104, 82,
- 0, 100, 101, 0, 100, 75, 101, 0, 80, 0,
- 21, 54, 92, 102, 82, 77, 0, 22, 82, 77,
- 21, 54, 92, 102, 82, 0, 23, 54, 4, 32,
- 4, 102, 82, 77, 0, 23, 54, 87, 104, 92,
- 104, 87, 102, 82, 77, 0, 23, 54, 87, 104,
- 104, 87, 102, 82, 77, 0, 24, 76, 0, 25,
- 76, 0, 79, 54, 91, 102, 84, 76, 0, 79,
- 88, 84, 76, 0, 28, 87, 76, 0, 29, 87,
- 76, 0, 0, 19, 78, 87, 76, 0, 20, 4,
- 56, 91, 57, 76, 0, 20, 4, 76, 0, 92,
- 76, 0, 26, 0, 27, 0, 17, 54, 92, 102,
- 82, 77, 0, 17, 54, 92, 102, 82, 77, 18,
- 82, 77, 0, 13, 0, 81, 13, 0, 0, 81,
- 0, 0, 42, 96, 0, 0, 43, 92, 0, 10,
- 92, 0, 44, 92, 0, 0, 86, 0, 4, 0,
- 86, 105, 4, 0, 1, 0, 86, 1, 0, 86,
- 105, 1, 0, 0, 92, 0, 0, 89, 0, 94,
- 0, 89, 105, 94, 0, 1, 0, 89, 1, 0,
- 89, 1, 94, 0, 89, 105, 1, 0, 0, 91,
- 0, 92, 0, 91, 105, 92, 0, 1, 0, 91,
- 1, 0, 91, 1, 92, 0, 91, 105, 1, 0,
- 0, 99, 11, 93, 92, 0, 54, 91, 102, 32,
- 4, 0, 92, 44, 31, 98, 0, 31, 98, 83,
- 0, 92, 33, 92, 0, 92, 34, 92, 0, 92,
- 12, 92, 0, 72, 0, 50, 72, 0, 92, 32,
- 4, 0, 92, 9, 92, 0, 92, 42, 92, 0,
- 92, 43, 92, 0, 92, 39, 92, 40, 92, 0,
- 96, 0, 92, 96, 0, 0, 99, 11, 95, 94,
- 0, 94, 33, 94, 0, 94, 34, 94, 0, 31,
- 98, 83, 0, 72, 0, 50, 72, 0, 94, 12,
- 94, 0, 94, 32, 4, 0, 94, 9, 94, 0,
- 94, 39, 94, 40, 94, 0, 96, 0, 94, 96,
- 0, 97, 0, 96, 52, 96, 0, 96, 47, 96,
- 0, 96, 48, 96, 0, 96, 49, 96, 0, 96,
- 45, 96, 0, 96, 46, 96, 0, 99, 35, 0,
- 99, 36, 0, 50, 96, 0, 54, 92, 102, 0,
- 37, 54, 90, 102, 0, 38, 54, 90, 102, 0,
- 38, 0, 3, 54, 90, 102, 0, 99, 0, 35,
- 99, 0, 36, 99, 0, 7, 0, 8, 0, 46,
- 96, 0, 45, 96, 0, 0, 99, 0, 4, 0,
- 4, 56, 91, 57, 0, 53, 97, 0, 58, 82,
- 0, 59, 82, 0, 55, 0, 0, 104, 0, 60,
- 0, 41, 82, 0
- };
-
- #endif
-
- #if YYDEBUG != 0
- static const short yyrline[] = { 0,
- 136, 141, 149, 165, 166, 167, 171, 173, 187, 189,
- 203, 209, 215, 217, 219, 232, 241, 243, 245, 255,
- 256, 260, 264, 275, 280, 289, 291, 300, 302, 320,
- 322, 327, 329, 337, 339, 344, 345, 349, 351, 353,
- 355, 357, 359, 361, 366, 370, 375, 378, 381, 383,
- 403, 430, 432, 434, 436, 438, 452, 457, 459, 464,
- 469, 476, 478, 482, 483, 487, 489, 494, 496, 498,
- 500, 505, 507, 512, 514, 516, 518, 520, 526, 528,
- 533, 535, 540, 542, 548, 550, 552, 554, 559, 561,
- 566, 568, 574, 576, 578, 580, 585, 588, 593, 595,
- 600, 606, 608, 610, 616, 626, 634, 636, 642, 644,
- 646, 648, 650, 655, 658, 659, 661, 663, 669, 671,
- 673, 675, 677, 679, 681, 683, 688, 690, 692, 694,
- 696, 698, 700, 702, 704, 709, 711, 713, 716, 718,
- 726, 731, 732, 734, 736, 738, 741, 748, 757, 759,
- 764, 766, 774, 779, 783, 787, 791, 792, 796, 799
- };
-
- static const char * const yytname[] = { "$","error","$illegal.","FUNC_CALL",
- "NAME","REGEXP","ERROR","YNUMBER","YSTRING","RELOP","APPEND_OP","ASSIGNOP","MATCHOP",
- "NEWLINE","CONCAT_OP","LEX_BEGIN","LEX_END","LEX_IF","LEX_ELSE","LEX_RETURN",
- "LEX_DELETE","LEX_WHILE","LEX_DO","LEX_FOR","LEX_BREAK","LEX_CONTINUE","LEX_PRINT",
- "LEX_PRINTF","LEX_NEXT","LEX_EXIT","LEX_FUNCTION","LEX_GETLINE","LEX_IN","LEX_AND",
- "LEX_OR","INCREMENT","DECREMENT","LEX_BUILTIN","LEX_LENGTH","'?'","':'","','",
- "'<'","'>'","'|'","'+'","'-'","'*'","'/'","'%'","'!'","UNARY","'^'","'$'","'('",
- "')'","'['","']'","'{'","'}'","';'","start","program","rule","@1","@2","func_name",
- "lex_builtin","function_prologue","@3","function_body","pattern","regexp","@4",
- "action","statements","statement_term","statement","@5","print","if_statement",
- "nls","opt_nls","input_redir","output_redir","opt_param_list","param_list","opt_exp",
- "opt_rexpression_list","rexpression_list","opt_expression_list","expression_list",
- "exp","@6","rexp","@7","simp_exp","non_post_simp_exp","opt_variable","variable",
- "l_brace","r_brace","r_paren","opt_semi","semi","comma",""
- };
- #endif
-
- static const short yyr1[] = { 0,
- 61, 62, 62, 62, 62, 62, 64, 63, 65, 63,
- 63, 63, 63, 63, 63, 63, 66, 66, 66, 67,
- 67, 69, 68, 70, 70, 71, 71, 73, 72, 74,
- 74, 75, 75, 75, 75, 76, 76, 77, 77, 77,
- 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
- 77, 77, 78, 77, 77, 77, 77, 79, 79, 80,
- 80, 81, 81, 82, 82, 83, 83, 84, 84, 84,
- 84, 85, 85, 86, 86, 86, 86, 86, 87, 87,
- 88, 88, 89, 89, 89, 89, 89, 89, 90, 90,
- 91, 91, 91, 91, 91, 91, 93, 92, 92, 92,
- 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
- 92, 92, 92, 95, 94, 94, 94, 94, 94, 94,
- 94, 94, 94, 94, 94, 94, 96, 96, 96, 96,
- 96, 96, 96, 96, 96, 97, 97, 97, 97, 97,
- 97, 97, 97, 97, 97, 97, 97, 97, 98, 98,
- 99, 99, 99, 100, 101, 102, 103, 103, 104, 105
- };
-
- static const short yyr2[] = { 0,
- 3, 1, 2, 1, 2, 0, 0, 3, 0, 3,
- 2, 2, 2, 1, 2, 2, 1, 1, 1, 1,
- 1, 0, 7, 4, 4, 1, 3, 0, 4, 5,
- 4, 1, 2, 1, 2, 1, 2, 2, 2, 3,
- 1, 6, 8, 8, 10, 9, 2, 2, 6, 4,
- 3, 3, 0, 4, 6, 3, 2, 1, 1, 6,
- 9, 1, 2, 0, 1, 0, 2, 0, 2, 2,
- 2, 0, 1, 1, 3, 1, 2, 3, 0, 1,
- 0, 1, 1, 3, 1, 2, 3, 3, 0, 1,
- 1, 3, 1, 2, 3, 3, 0, 4, 5, 4,
- 3, 3, 3, 3, 1, 2, 3, 3, 3, 3,
- 5, 1, 2, 0, 4, 3, 3, 3, 1, 2,
- 3, 3, 3, 5, 1, 2, 1, 3, 3, 3,
- 3, 3, 3, 2, 2, 2, 3, 4, 4, 1,
- 4, 1, 2, 2, 1, 1, 2, 2, 0, 1,
- 1, 4, 2, 2, 2, 1, 0, 1, 1, 2
- };
-
- static const short yydefact[] = { 64,
- 62, 65, 0, 63, 4, 0, 151, 145, 146, 7,
- 9, 22, 149, 0, 0, 0, 140, 0, 0, 28,
- 0, 0, 0, 64, 0, 2, 0, 0, 105, 14,
- 26, 112, 127, 142, 0, 0, 0, 159, 0, 11,
- 36, 64, 0, 12, 0, 66, 150, 143, 144, 0,
- 0, 0, 0, 148, 142, 147, 0, 106, 136, 153,
- 142, 93, 0, 91, 154, 5, 3, 1, 16, 0,
- 13, 15, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 113, 0, 0, 0, 0, 0, 0, 97,
- 134, 135, 34, 0, 53, 0, 0, 64, 0, 0,
- 0, 58, 59, 79, 79, 64, 0, 32, 0, 41,
- 0, 0, 157, 64, 0, 0, 91, 0, 8, 37,
- 10, 18, 17, 20, 21, 0, 19, 0, 101, 0,
- 0, 0, 0, 94, 64, 156, 0, 0, 137, 0,
- 157, 108, 104, 107, 102, 103, 0, 27, 109, 110,
- 149, 132, 133, 129, 130, 131, 128, 0, 0, 79,
- 0, 0, 0, 79, 47, 48, 0, 80, 0, 155,
- 35, 33, 157, 85, 149, 0, 0, 119, 68, 0,
- 83, 125, 142, 57, 0, 39, 64, 158, 38, 141,
- 152, 0, 67, 138, 139, 29, 95, 160, 0, 96,
- 92, 157, 64, 0, 100, 98, 0, 0, 0, 56,
- 0, 0, 151, 0, 51, 52, 64, 66, 120, 0,
- 0, 0, 0, 0, 86, 0, 0, 0, 0, 0,
- 0, 0, 126, 114, 40, 31, 76, 74, 0, 0,
- 99, 24, 25, 111, 64, 54, 0, 64, 0, 0,
- 0, 30, 118, 68, 70, 69, 71, 50, 87, 88,
- 84, 123, 121, 122, 116, 117, 0, 0, 64, 77,
- 0, 0, 0, 0, 0, 0, 0, 79, 0, 0,
- 115, 23, 78, 75, 60, 55, 42, 0, 64, 79,
- 0, 49, 124, 64, 64, 0, 0, 64, 0, 43,
- 44, 64, 0, 61, 0, 46, 45, 0, 0, 0
- };
-
- static const short yydefgoto[] = { 308,
- 25, 26, 39, 43, 126, 127, 27, 45, 69, 28,
- 29, 57, 30, 107, 40, 108, 160, 109, 110, 2,
- 3, 129, 224, 239, 240, 167, 179, 180, 115, 116,
- 111, 158, 181, 268, 32, 33, 46, 34, 112, 113,
- 139, 187, 42, 138
- };
-
- static const short yypact[] = { 2,
- -32768, 15, 842,-32768,-32768, -44, -27,-32768,-32768, 6,
- 6,-32768, 3, 3, 3, -15, -9, 1684, 1684,-32768,
- 1678, 1684, 1093, 2, 898,-32768, 32, 46,-32768,-32768,
- 1262, 197,-32768, 49, 665, 1072, 1093,-32768, 32,-32768,
- 15, 2, 32,-32768, 96, 7,-32768,-32768,-32768, 1072,
- 1072, 1684, 1474, -21, -11, -21, 86,-32768, -21,-32768,
- -32768,-32768, 0, 1209,-32768,-32768,-32768,-32768,-32768, 665,
- -32768,-32768, 1474, 1474, 89, 1474, 1474, 1474, 1474, 1474,
- 1474, 63, 197, 1684, 1684, 1684, 1684, 1684, 1684,-32768,
- -32768,-32768,-32768, 55,-32768, 99, 56, 2, 66, 6,
- 6,-32768,-32768, 1474, 1474, 2, 756,-32768, 816,-32768,
- 518, 665, 61, 2, 68, 41, 1358, 11,-32768,-32768,
- -32768,-32768,-32768,-32768,-32768, 71,-32768, 1684,-32768, 68,
- 68, 1209, 79, 1474, 2,-32768, 98, 1141,-32768, 756,
- 61, 1745, 1732,-32768, 1494, 1406, 1310, 1358, 1745, 1745,
- 3, 90, 90, -21, -21, -21, -21, 1474, 1474, 1474,
- 59, 1474, 946, 1602,-32768,-32768, 6, 1358, 6,-32768,
- -32768,-32768, 61,-32768, 3, 1678, 1093,-32768, 44, 85,
- 1542, 197, 111,-32768, 756,-32768, 2,-32768,-32768,-32768,
- -32768, 26, 197,-32768,-32768,-32768, 1358,-32768, 128,-32768,
- 1358, 61, 2, 1474,-32768, 1358, 1209, 6, 1093,-32768,
- 1209, 119, -24, 61,-32768,-32768, 2, 7,-32768, 0,
- 1474, 1474, 1474, 6, 1658, 1161, 1658, 1658, 137, 1658,
- 1658, 1658, 197,-32768,-32768,-32768,-32768,-32768, 68, 42,
- -32768,-32768,-32768, 1358, 2,-32768, 12, 2, 94, 139,
- 1024,-32768,-32768, 44, 1358, 1358, 1358,-32768, 1542,-32768,
- 1542, 415, 1222,-32768, 1622, 1582, 1454, 1658, 2,-32768,
- 22, 946, 6, 946, 1474, 68, 1004, 1474, 6, 1658,
- 1542,-32768,-32768,-32768, 131,-32768,-32768, 1209, 2, 1474,
- 68,-32768, 1542, 2, 2, 946, 68, 2, 946,-32768,
- -32768, 2, 946,-32768, 946,-32768,-32768, 151, 153,-32768
- };
-
- static const short yypgoto[] = {-32768,
- -32768, 125,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
- 84,-32768, -22, -54, 334, -96,-32768,-32768,-32768, 202,
- 38, -58, -92,-32768,-32768, -103,-32768,-32768, -14, -19,
- -3,-32768, -114,-32768, 368, 145, -137, 150, 183, -61,
- -23, -138, 469, -175
- };
-
-
- #define YYLAST 1799
-
-
- static const short yytable[] = { 31,
- 134, 169, 203, 63, 226, 71, 7, 250, 141, 36,
- 172, 134, 134, 205, 1, 140, 119, 118, 1, 64,
- 121, 31, 283, 91, 92, 284, 237, 4, 37, 238,
- 89, 37, 117, 117, 217, 130, 131, 218, 50, 137,
- 135, 134, 270, 172, 51, 173, 117, 117, 128, 132,
- 186, 135, 135, 221, 136, 22, 208, 185, 1, 90,
- 214, 65, 68, 242, 271, 38, 212, 191, 273, 142,
- 143, 1, 145, 146, 147, 148, 149, 150, 202, 120,
- -72, 135, 135, 91, 92, 225, 222, 223, 172, 24,
- 133, 190, 144, 151, -82, -90, -73, -82, 122, 123,
- 168, 168, 161, 24, 58, 38, 194, 195, 159, 162,
- 259, 261, 262, 263, 209, 265, 266, 267, 38, 164,
- 38, 234, 136, 235, 192, 135, 196, -82, -82, 199,
- 197, 241, 124, 125, 201, 163, 86, 87, 88, 249,
- 264, 89, 276, 170, -82, 91, 92, 275, 294, 67,
- 309, 189, 310, 281, 206, 207, 168, 220, 211, 253,
- 168, 279, 47, 48, 49, 293, 60, 55, 55, 0,
- 55, 61, 198, 64, 291, 285, 0, 287, 0, 0,
- 55, 0, 0, 245, 0, 35, 297, 248, 0, 247,
- 0, 0, 178, 0, 0, 0, 254, 0, 0, 301,
- 244, 55, 304, 0, 0, 117, 306, 35, 307, 70,
- 35, 41, 41, 55, 0, 269, 0, 255, 256, 257,
- 0, 35, 0, 0, 236, 35, 0, 0, 0, 41,
- 0, 0, 0, 55, 55, 55, 55, 55, 55, 0,
- 243, 84, 85, 86, 87, 88, 0, 277, 89, 0,
- 0, 0, 289, 0, 252, 0, 0, 0, 183, 219,
- 55, 0, 0, 0, 295, 0, 55, 298, 0, 0,
- 0, 288, 0, 302, 168, 0, 0, 55, 0, 0,
- 0, 55, 272, 0, 0, 274, 168, 0, 0, 0,
- 0, 55, 55, 0, 55, 55, 55, 55, 55, 55,
- 47, 41, 41, 0, 0, 0, 282, 0, 178, 178,
- 178, 178, 41, 178, 178, 178, 0, 55, 0, 0,
- 0, 0, 0, 0, 47, 55, 296, 0, 0, 0,
- 55, 299, 300, 0, 0, 303, 0, 0, 0, 305,
- 0, 0, 0, 0, 44, 0, 55, 0, 0, 0,
- 55, 178, 0, 0, 0, 55, 55, 0, 0, 0,
- 55, 72, 41, 178, 0, 0, 0, 0, 41, 0,
- 41, 0, 0, 0, 183, 183, 183, 183, 0, 183,
- 183, 183, 0, 0, 0, 54, 56, 0, 59, 0,
- 0, 0, 0, 55, 0, 0, 0, 0, 83, 0,
- 0, 0, 0, 0, 55, 55, 55, 0, 55, 41,
- 55, 55, 55, 0, 55, 55, 55, 183, 7, 59,
- 0, 8, 9,-32768, 0, 41, 55, 0, 0, 183,
- 55, 83, 0, 165, 166, 0, 0, 55, 0, 0,
- 0, 0, 55, 0, 184, 0, 0, 0, 0, 14,
- 15, 152, 153, 154, 155, 156, 157, 0, 0, 18,
- 19, 0, 0, 0, 52, 0, 0, 22, 53, 0,
- 0, 0, 0, 0, 41, 0, 182, 0, 83, 0,
- 41, 0, 0, 0, 83, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 210, 193, 0, 0, 0, 83,
- 215, 0, 216, 114, 0, 0, 0, 0, 0, 83,
- 83, 0, 83, 83, 83, 83, 83, 83, 0, 0,
- 6, 7, 0, 0, 8, 9, 73, 0, 0, 74,
- 1, 0, 0, 0, 0, 83, 0, 0, 114, 0,
- 0, 246, 0, 59, 0, 0, 0, 0, 233, 75,
- 76, 77, 14, 15, 16, 17, 78, 258, 0, 80,
- 81, 82, 18, 19, 83, 0, 0, 52, 83, 0,
- 22, 53, 0, 83, 83, 114, 0, 38, 83, 0,
- 114, 188, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 182, 182, 182, 182, 0, 182, 182, 182,
- 0, 0, 0, 0, 0, 0, 286, 0, 114, 188,
- 0, 83, 292, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 83, 83, 83, 0, 233, 0, 233, 233,
- 233, 114, 233, 233, 233, 182, 0, 0, 0, 0,
- 0, 188, 0, 0, 83, 0, 0, 182, 233, 0,
- 0, 0, 0, 114, 0, 83, 0, 0, 0, 0,
- 233, 0, 0, 0, 0, 93, 0, 6, 7, 0,
- 188, 8, 9, 0, 0, 0, 0, 0, 0, 0,
- 0, 94, 251, 95, 96, 97, 98, 99, 100, 101,
- 102, 103, 104, 105, 0, 13, 0, 0, 0, 14,
- 15, 16, 17, 0, 0, 0, 0, 0, 0, 18,
- 19, 0, 20, 0, 21, 0, 0, 22, 23, 278,
- 0, 0, 24, 106, 38, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 114, 0, 114, 0, 0, 290, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 171, 0, 6, 7,
- 0, 0, 8, 9, 114, 0, 0, 114, 0, 0,
- 0, 114, 94, 114, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 0, 13, 0, 0, 0,
- 14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
- 18, 19, 0, 20, 0, 21, 0, 0, 22, 23,
- 0, 0, 0, 24, 106, 38, 174, 0, 6, 7,
- 0, 0, 8, 9, 0, -81, 0, 0, -81, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, -6, 5, 0, 6, 7, 175, 0, 8, 9,
- 14, 15, 16, 17, -6, 0, 10, 11, -81, -81,
- 18, 19, 0, 20, 0, 176, 0, 0, 22, 177,
- 0, 12, 13, 0, 0, -81, 14, 15, 16, 17,
- 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
- 0, 21, 0, 0, 22, 23, 0, -64, 66, 24,
- 6, 7, 0, 0, 8, 9, 0, 0, 0, 0,
- 1, 0, 10, 11, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 12, 13, 0,
- 0, 0, 14, 15, 16, 17, 0, 0, 0, 0,
- 0, 0, 18, 19, 0, 20, 0, 21, 6, 7,
- 22, 23, 8, 9, 0, 24, 0, 0, 0, 0,
- 0, 0, 94, 0, 95, 96, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 0, 13, 0, 0, 0,
- 14, 15, 16, 17, 0, 0, 0, 0, 0, 0,
- 18, 19, 0, 20, 0, 21, 0, 0, 22, 23,
- 0, 0, 0, 24, 0, 38, 6, 7, 0, 0,
- 8, 9, 73, 0, 0, 74, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 6, 7, 0, 0,
- 8, 9, 0, 0, 0, 75, 76, 77, 14, 15,
- 16, 17, 78, 0, 0, 80, 81, 82, 18, 19,
- 0, 0, 0, 52, 13, 0, 22, 53, 14, 15,
- 16, 17, 0, 38, 0, 0, 0, 0, 18, 19,
- 0, 20, 62, 21, 6, 7, 22, 23, 8, 9,
- 0, 0, 0, 38, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 62, 0, 6, 7, 0, 0, 8,
- 9, 0, 13, 0, 0, 0, 14, 15, 16, 17,
- 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
- 0, 21, 0, 13, 22, 23, -89, 14, 15, 16,
- 17, 0, 0, 0, 0, 0, 0, 18, 19, 0,
- 20, 200, 21, 6, 7, 22, 23, 8, 9, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 260, 0, 6, 7, 0, 0, 8, 9, 0,
- 0, 13, 0, 0, 0, 14, 15, 16, 17, 0,
- 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
- 21, 175, 0, 22, 23, 14, 15, 16, 17, 0,
- 0, 0, 0, 0, 0, 18, 19, 0, 20, 0,
- 176, 6, 7, 22, 53, 8, 9, 73, 0, 0,
- 74, 0, 0, 0, 0, 7, 0, 0, 8, 9,
- 227, 0, 0,-32768, 0, 0, 0, 0, 0, 0,
- 75, 76, 77, 14, 15, 16, 17, 78, 0, 0,
- 80, 81, 82, 18, 19, 0, 14, 15, 52, 0,
- 0, 22, 53, 136, 6, 7, 18, 19, 8, 9,
- 73, 52, 0, 74, 22, 53, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 75, 76, 77, 14, 15, 16, 17,
- 78, 0, 79, 80, 81, 82, 18, 19, 0, 0,
- 0, 52, 6, 7, 22, 53, 8, 9, 73, 0,
- 0, 74, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 75, 76, 77, 14, 15, 16, 17, 78, 204,
- 0, 80, 81, 82, 18, 19, 0, 0, 0, 52,
- 6, 7, 22, 53, 8, 9, 73, 0, 0, 74,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 75,
- 76, 77, 14, 15, 16, 17, 78, 0, 0, 80,
- 81, 82, 18, 19, 0, 0, 0, 52, 6, 7,
- 22, 53, 8, 9, 73, 0, 0, 74, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 75, 76, 0,
- 14, 15, 16, 17, 0, 0, 0, 80, 81, 82,
- 18, 19, 0, 0, 0, 52, 6, 7, 22, 53,
- 8, 9, 227, 0, 0, 228, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 6, 7, 0, 0,
- 8, 9, 0, 0, 0, 229, 230, 231, 14, 15,
- 16, 17, 232, 280, 0, 0, 6, 7, 18, 19,
- 8, 9, 73, 52, 13, 74, 22, 53, 14, 15,
- 16, 17, 0, 0, 0, 0, 0, 0, 18, 19,
- 0, 20, 0, 21, 0, 75, 22, 23, 14, 15,
- 16, 17, 0, 0, 0, 80, 81, 82, 18, 19,
- 0, 0, 0, 52, 6, 7, 22, 53, 8, 9,
- 227, 0, 0, 228, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 229, 230, 231, 14, 15, 16, 17,
- 232, 0, 0, 0, 6, 7, 18, 19, 8, 9,
- 227, 52, 0, 228, 22, 53, 0, 0, 0, 0,
- 0, 0, 0, 0, 6, 213, 0, 0, 8, 9,
- 0, 0, 0, 229, 230, 0, 14, 15, 16, 17,
- 0, 0, 0, 0, 6, 7, 18, 19, 8, 9,
- 227, 52, 13, 228, 22, 53, 14, 15, 16, 17,
- 0, 0, 0, 0, 0, 0, 18, 19, 0, 20,
- 0, 21, 0, 229, 22, 23, 14, 15, 16, 17,
- 6, 7, 0, 0, 8, 9, 18, 19, 0, 0,
- 0, 52, 0, 0, 22, 53, 0, 0, 0, 0,
- 6, 7, 0, 0, 8, 9, 6, 7, 175, 0,
- 8, 9, 14, 15, 16, 17, 0, 0, 0, 0,
- 0, 0, 18, 19, 0, 20, 0, 176, 0, 0,
- 22, 53, 14, 15, 16, 17, 0, 0, 14, 15,
- 16, 17, 18, 19, 0, 20, 0, 52, 18, 19,
- 22, 53, 0, 52, 0, 7, 22, 53, 8, 9,
- 73, 0, 0,-32768, 0, 0, 0, 0, 7, 0,
- 0, 8, 9,-32768, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 14, 15, 0, 0,
- 0, 0, 0, 80, 81, 82, 18, 19, 0, 14,
- 15, 52, 0, 0, 22, 53,-32768,-32768,-32768, 18,
- 19, 0, 0, 0, 52, 0, 0, 22, 53
- };
-
- static const short yycheck[] = { 3,
- 1, 105, 141, 23, 180, 28, 4, 32, 70, 54,
- 107, 1, 1, 151, 13, 70, 39, 37, 13, 23,
- 43, 25, 1, 35, 36, 4, 1, 13, 56, 4,
- 52, 56, 36, 37, 173, 50, 51, 175, 54, 63,
- 41, 1, 1, 140, 54, 107, 50, 51, 42, 53,
- 112, 41, 41, 10, 55, 53, 160, 112, 13, 11,
- 164, 24, 25, 202, 240, 60, 163, 57, 57, 73,
- 74, 13, 76, 77, 78, 79, 80, 81, 140, 42,
- 55, 41, 41, 35, 36, 1, 43, 44, 185, 58,
- 5, 115, 4, 31, 10, 55, 55, 13, 3, 4,
- 104, 105, 4, 58, 21, 60, 130, 131, 54, 54,
- 225, 226, 227, 228, 56, 230, 231, 232, 60, 54,
- 60, 11, 55, 185, 54, 41, 48, 43, 44, 32,
- 134, 4, 37, 38, 138, 98, 47, 48, 49, 21,
- 4, 52, 4, 106, 60, 35, 36, 54, 18, 25,
- 0, 114, 0, 268, 158, 159, 160, 177, 162, 218,
- 164, 254, 13, 14, 15, 280, 22, 18, 19, -1,
- 21, 22, 135, 177, 278, 272, -1, 274, -1, -1,
- 31, -1, -1, 207, -1, 3, 290, 211, -1, 209,
- -1, -1, 109, -1, -1, -1, 220, -1, -1, 296,
- 204, 52, 299, -1, -1, 209, 303, 25, 305, 27,
- 28, 10, 11, 64, -1, 239, -1, 221, 222, 223,
- -1, 39, -1, -1, 187, 43, -1, -1, -1, 28,
- -1, -1, -1, 84, 85, 86, 87, 88, 89, -1,
- 203, 45, 46, 47, 48, 49, -1, 251, 52, -1,
- -1, -1, 276, -1, 217, -1, -1, -1, 109, 176,
- 111, -1, -1, -1, 288, -1, 117, 291, -1, -1,
- -1, 275, -1, 297, 278, -1, -1, 128, -1, -1,
- -1, 132, 245, -1, -1, 248, 290, -1, -1, -1,
- -1, 142, 143, -1, 145, 146, 147, 148, 149, 150,
- 151, 100, 101, -1, -1, -1, 269, -1, 225, 226,
- 227, 228, 111, 230, 231, 232, -1, 168, -1, -1,
- -1, -1, -1, -1, 175, 176, 289, -1, -1, -1,
- 181, 294, 295, -1, -1, 298, -1, -1, -1, 302,
- -1, -1, -1, -1, 11, -1, 197, -1, -1, -1,
- 201, 268, -1, -1, -1, 206, 207, -1, -1, -1,
- 211, 28, 161, 280, -1, -1, -1, -1, 167, -1,
- 169, -1, -1, -1, 225, 226, 227, 228, -1, 230,
- 231, 232, -1, -1, -1, 18, 19, -1, 21, -1,
- -1, -1, -1, 244, -1, -1, -1, -1, 31, -1,
- -1, -1, -1, -1, 255, 256, 257, -1, 259, 208,
- 261, 262, 263, -1, 265, 266, 267, 268, 4, 52,
- -1, 7, 8, 9, -1, 224, 277, -1, -1, 280,
- 281, 64, -1, 100, 101, -1, -1, 288, -1, -1,
- -1, -1, 293, -1, 111, -1, -1, -1, -1, 35,
- 36, 84, 85, 86, 87, 88, 89, -1, -1, 45,
- 46, -1, -1, -1, 50, -1, -1, 53, 54, -1,
- -1, -1, -1, -1, 273, -1, 109, -1, 111, -1,
- 279, -1, -1, -1, 117, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 161, 128, -1, -1, -1, 132,
- 167, -1, 169, 35, -1, -1, -1, -1, -1, 142,
- 143, -1, 145, 146, 147, 148, 149, 150, -1, -1,
- 3, 4, -1, -1, 7, 8, 9, -1, -1, 12,
- 13, -1, -1, -1, -1, 168, -1, -1, 70, -1,
- -1, 208, -1, 176, -1, -1, -1, -1, 181, 32,
- 33, 34, 35, 36, 37, 38, 39, 224, -1, 42,
- 43, 44, 45, 46, 197, -1, -1, 50, 201, -1,
- 53, 54, -1, 206, 207, 107, -1, 60, 211, -1,
- 112, 113, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 225, 226, 227, 228, -1, 230, 231, 232,
- -1, -1, -1, -1, -1, -1, 273, -1, 140, 141,
- -1, 244, 279, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 255, 256, 257, -1, 259, -1, 261, 262,
- 263, 163, 265, 266, 267, 268, -1, -1, -1, -1,
- -1, 173, -1, -1, 277, -1, -1, 280, 281, -1,
- -1, -1, -1, 185, -1, 288, -1, -1, -1, -1,
- 293, -1, -1, -1, -1, 1, -1, 3, 4, -1,
- 202, 7, 8, -1, -1, -1, -1, -1, -1, -1,
- -1, 17, 214, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, -1, 31, -1, -1, -1, 35,
- 36, 37, 38, -1, -1, -1, -1, -1, -1, 45,
- 46, -1, 48, -1, 50, -1, -1, 53, 54, 251,
- -1, -1, 58, 59, 60, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 272, -1, 274, -1, -1, 277, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 1, -1, 3, 4,
- -1, -1, 7, 8, 296, -1, -1, 299, -1, -1,
- -1, 303, 17, 305, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, -1, 31, -1, -1, -1,
- 35, 36, 37, 38, -1, -1, -1, -1, -1, -1,
- 45, 46, -1, 48, -1, 50, -1, -1, 53, 54,
- -1, -1, -1, 58, 59, 60, 1, -1, 3, 4,
- -1, -1, 7, 8, -1, 10, -1, -1, 13, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 0, 1, -1, 3, 4, 31, -1, 7, 8,
- 35, 36, 37, 38, 13, -1, 15, 16, 43, 44,
- 45, 46, -1, 48, -1, 50, -1, -1, 53, 54,
- -1, 30, 31, -1, -1, 60, 35, 36, 37, 38,
- -1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
- -1, 50, -1, -1, 53, 54, -1, 0, 1, 58,
- 3, 4, -1, -1, 7, 8, -1, -1, -1, -1,
- 13, -1, 15, 16, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 30, 31, -1,
- -1, -1, 35, 36, 37, 38, -1, -1, -1, -1,
- -1, -1, 45, 46, -1, 48, -1, 50, 3, 4,
- 53, 54, 7, 8, -1, 58, -1, -1, -1, -1,
- -1, -1, 17, -1, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, -1, 31, -1, -1, -1,
- 35, 36, 37, 38, -1, -1, -1, -1, -1, -1,
- 45, 46, -1, 48, -1, 50, -1, -1, 53, 54,
- -1, -1, -1, 58, -1, 60, 3, 4, -1, -1,
- 7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
- 7, 8, -1, -1, -1, 32, 33, 34, 35, 36,
- 37, 38, 39, -1, -1, 42, 43, 44, 45, 46,
- -1, -1, -1, 50, 31, -1, 53, 54, 35, 36,
- 37, 38, -1, 60, -1, -1, -1, -1, 45, 46,
- -1, 48, 1, 50, 3, 4, 53, 54, 7, 8,
- -1, -1, -1, 60, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 1, -1, 3, 4, -1, -1, 7,
- 8, -1, 31, -1, -1, -1, 35, 36, 37, 38,
- -1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
- -1, 50, -1, 31, 53, 54, 55, 35, 36, 37,
- 38, -1, -1, -1, -1, -1, -1, 45, 46, -1,
- 48, 1, 50, 3, 4, 53, 54, 7, 8, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 1, -1, 3, 4, -1, -1, 7, 8, -1,
- -1, 31, -1, -1, -1, 35, 36, 37, 38, -1,
- -1, -1, -1, -1, -1, 45, 46, -1, 48, -1,
- 50, 31, -1, 53, 54, 35, 36, 37, 38, -1,
- -1, -1, -1, -1, -1, 45, 46, -1, 48, -1,
- 50, 3, 4, 53, 54, 7, 8, 9, -1, -1,
- 12, -1, -1, -1, -1, 4, -1, -1, 7, 8,
- 9, -1, -1, 12, -1, -1, -1, -1, -1, -1,
- 32, 33, 34, 35, 36, 37, 38, 39, -1, -1,
- 42, 43, 44, 45, 46, -1, 35, 36, 50, -1,
- -1, 53, 54, 55, 3, 4, 45, 46, 7, 8,
- 9, 50, -1, 12, 53, 54, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 32, 33, 34, 35, 36, 37, 38,
- 39, -1, 41, 42, 43, 44, 45, 46, -1, -1,
- -1, 50, 3, 4, 53, 54, 7, 8, 9, -1,
- -1, 12, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- -1, 42, 43, 44, 45, 46, -1, -1, -1, 50,
- 3, 4, 53, 54, 7, 8, 9, -1, -1, 12,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 32,
- 33, 34, 35, 36, 37, 38, 39, -1, -1, 42,
- 43, 44, 45, 46, -1, -1, -1, 50, 3, 4,
- 53, 54, 7, 8, 9, -1, -1, 12, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 32, 33, -1,
- 35, 36, 37, 38, -1, -1, -1, 42, 43, 44,
- 45, 46, -1, -1, -1, 50, 3, 4, 53, 54,
- 7, 8, 9, -1, -1, 12, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 3, 4, -1, -1,
- 7, 8, -1, -1, -1, 32, 33, 34, 35, 36,
- 37, 38, 39, 40, -1, -1, 3, 4, 45, 46,
- 7, 8, 9, 50, 31, 12, 53, 54, 35, 36,
- 37, 38, -1, -1, -1, -1, -1, -1, 45, 46,
- -1, 48, -1, 50, -1, 32, 53, 54, 35, 36,
- 37, 38, -1, -1, -1, 42, 43, 44, 45, 46,
- -1, -1, -1, 50, 3, 4, 53, 54, 7, 8,
- 9, -1, -1, 12, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 32, 33, 34, 35, 36, 37, 38,
- 39, -1, -1, -1, 3, 4, 45, 46, 7, 8,
- 9, 50, -1, 12, 53, 54, -1, -1, -1, -1,
- -1, -1, -1, -1, 3, 4, -1, -1, 7, 8,
- -1, -1, -1, 32, 33, -1, 35, 36, 37, 38,
- -1, -1, -1, -1, 3, 4, 45, 46, 7, 8,
- 9, 50, 31, 12, 53, 54, 35, 36, 37, 38,
- -1, -1, -1, -1, -1, -1, 45, 46, -1, 48,
- -1, 50, -1, 32, 53, 54, 35, 36, 37, 38,
- 3, 4, -1, -1, 7, 8, 45, 46, -1, -1,
- -1, 50, -1, -1, 53, 54, -1, -1, -1, -1,
- 3, 4, -1, -1, 7, 8, 3, 4, 31, -1,
- 7, 8, 35, 36, 37, 38, -1, -1, -1, -1,
- -1, -1, 45, 46, -1, 48, -1, 50, -1, -1,
- 53, 54, 35, 36, 37, 38, -1, -1, 35, 36,
- 37, 38, 45, 46, -1, 48, -1, 50, 45, 46,
- 53, 54, -1, 50, -1, 4, 53, 54, 7, 8,
- 9, -1, -1, 12, -1, -1, -1, -1, 4, -1,
- -1, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 35, 36, -1, -1,
- -1, -1, -1, 42, 43, 44, 45, 46, -1, 35,
- 36, 50, -1, -1, 53, 54, 42, 43, 44, 45,
- 46, -1, -1, -1, 50, -1, -1, 53, 54
- };
- /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
- #line 3 "/usr/local/lib/bison.simple"
-
- /* Skeleton output parser for bison,
- Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
-
- 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
- #ifndef alloca
- #ifdef __GNUC__
- #define alloca __builtin_alloca
- #else /* not GNU C. */
- #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
- #include <alloca.h>
- #else /* not sparc */
- #if defined (MSDOS) && !defined (__TURBOC__)
- #include <malloc.h>
- #else /* not MSDOS, or __TURBOC__ */
- #if defined(_AIX)
- #include <malloc.h>
- #pragma alloca
- #else /* not MSDOS, __TURBOC__, or _AIX */
- #ifdef __hpux
- #ifdef __cplusplus
- extern "C" {
- void *alloca (unsigned int);
- };
- #else /* not __cplusplus */
- void *alloca ();
- #endif /* not __cplusplus */
- #endif /* __hpux */
- #endif /* not _AIX */
- #endif /* not MSDOS, or __TURBOC__ */
- #endif /* not sparc. */
- #endif /* not GNU C. */
- #endif /* alloca not defined. */
-
- /* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
- /* Note: there must be only one dollar sign in this file.
- It is replaced by the list of actions, each action
- as one case of the switch. */
-
- #define yyerrok (yyerrstatus = 0)
- #define yyclearin (yychar = YYEMPTY)
- #define YYEMPTY -2
- #define YYEOF 0
- #define YYACCEPT return(0)
- #define YYABORT return(1)
- #define YYERROR goto yyerrlab1
- /* Like YYERROR except do call yyerror.
- This remains here temporarily to ease the
- transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
- #define YYFAIL goto yyerrlab
- #define YYRECOVERING() (!!yyerrstatus)
- #define YYBACKUP(token, value) \
- do \
- if (yychar == YYEMPTY && yylen == 1) \
- { yychar = (token), yylval = (value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { yyerror ("syntax error: cannot back up"); YYERROR; } \
- while (0)
-
- #define YYTERROR 1
- #define YYERRCODE 256
-
- #ifndef YYPURE
- #define YYLEX yylex()
- #endif
-
- #ifdef YYPURE
- #ifdef YYLSP_NEEDED
- #define YYLEX yylex(&yylval, &yylloc)
- #else
- #define YYLEX yylex(&yylval)
- #endif
- #endif
-
- /* If nonreentrant, generate the variables here */
-
- #ifndef YYPURE
-
- int yychar; /* the lookahead symbol */
- YYSTYPE yylval; /* the semantic value of the */
- /* lookahead symbol */
-
- #ifdef YYLSP_NEEDED
- YYLTYPE yylloc; /* location data for the lookahead */
- /* symbol */
- #endif
-
- int yynerrs; /* number of parse errors so far */
- #endif /* not YYPURE */
-
- #if YYDEBUG != 0
- int yydebug; /* nonzero means print parse trace */
- /* Since this is uninitialized, it does not stop multiple parsers
- from coexisting. */
- #endif
-
- /* YYINITDEPTH indicates the initial size of the parser's stacks */
-
- #ifndef YYINITDEPTH
- #define YYINITDEPTH 200
- #endif
-
- /* YYMAXDEPTH is the maximum size the stacks can grow to
- (effective only if the built-in stack extension method is used). */
-
- #if YYMAXDEPTH == 0
- #undef YYMAXDEPTH
- #endif
-
- #ifndef YYMAXDEPTH
- #define YYMAXDEPTH 10000
- #endif
-
- /* Prevent warning if -Wstrict-prototypes. */
- #ifdef __GNUC__
- int yyparse (void);
- #endif
-
- #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
- #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
- #else /* not GNU C or C++ */
- #ifndef __cplusplus
-
- /* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
- static void
- __yy_bcopy (from, to, count)
- char *from;
- char *to;
- int count;
- {
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
- }
-
- #else /* __cplusplus */
-
- /* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
- static void
- __yy_bcopy (char *from, char *to, int count)
- {
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
- }
-
- #endif
- #endif
-
- #line 184 "/usr/local/lib/bison.simple"
- int
- yyparse()
- {
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
- int yyerrstatus; /* number of tokens to shift before error messages enabled */
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */
-
- short yyssa[YYINITDEPTH]; /* the state stack */
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
-
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
-
- #ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
- #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
- #else
- #define YYPOPSTACK (yyvsp--, yyssp--)
- #endif
-
- int yystacksize = YYINITDEPTH;
-
- #ifdef YYPURE
- int yychar;
- YYSTYPE yylval;
- int yynerrs;
- #ifdef YYLSP_NEEDED
- YYLTYPE yylloc;
- #endif
- #endif
-
- YYSTYPE yyval; /* the variable used to return */
- /* semantic values from the action */
- /* routines */
-
- int yylen;
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Starting parse\n");
- #endif
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- 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 - 1;
- yyvsp = yyvs;
- #ifdef YYLSP_NEEDED
- yylsp = yyls;
- #endif
-
- /* Push a new state, which is found in yystate . */
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks. */
- yynewstate:
-
- *++yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
- {
- /* 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 *yyss1 = yyss;
- #ifdef YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
- #endif
-
- /* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
-
- #ifdef yyoverflow
- /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes. */
- #ifdef YYLSP_NEEDED
- /* 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",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
- #else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
- #endif
-
- yyss = yyss1; yyvs = yyvs1;
- #ifdef YYLSP_NEEDED
- yyls = yyls1;
- #endif
- #else /* no yyoverflow */
- /* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- {
- yyerror("parser stack overflow");
- return 2;
- }
- yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
- yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
- __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
- #ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
- #endif
- #endif /* no yyoverflow */
-
- yyssp = yyss + size - 1;
- yyvsp = yyvs + size - 1;
- #ifdef YYLSP_NEEDED
- yylsp = yyls + size - 1;
- #endif
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
- #endif
-
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
- }
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
- #endif
-
- goto yybackup;
- yybackup:
-
- /* Do appropriate processing given the current state. */
- /* Read a lookahead token if we need one and don't already have one. */
- /* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
- if (yychar == YYEMPTY)
- {
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Reading a token: ");
- #endif
- yychar = YYLEX;
- }
-
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
- {
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
- #endif
- }
- else
- {
- yychar1 = YYTRANSLATE(yychar);
-
- #if YYDEBUG != 0
- if (yydebug)
- {
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
- #ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
- #endif
- fprintf (stderr, ")\n");
- }
- #endif
- }
-
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
- goto yydefault;
-
- yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
- #endif
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
- #ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
- #endif
-
- /* count tokens shifted since error; after three, turn off error status. */
- if (yyerrstatus) yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
- /* Do the default action for the current state. */
- yydefault:
-
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
-
- /* Do a reduction. yyn is the number of a rule to reduce with. */
- yyreduce:
- yylen = yyr2[yyn];
- if (yylen > 0)
- yyval = yyvsp[1-yylen]; /* implement default value of the action */
-
- #if YYDEBUG != 0
- if (yydebug)
- {
- int i;
-
- fprintf (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
- #endif
-
-
- switch (yyn) {
-
- case 1:
- #line 137 "awk.y"
- { expression_value = yyvsp[-1].nodeval; ;
- break;}
- case 2:
- #line 142 "awk.y"
- {
- if (yyvsp[0].nodeval != NULL)
- yyval.nodeval = yyvsp[0].nodeval;
- else
- yyval.nodeval = NULL;
- yyerrok;
- ;
- break;}
- case 3:
- #line 151 "awk.y"
- {
- if (yyvsp[0].nodeval == NULL)
- yyval.nodeval = yyvsp[-1].nodeval;
- else if (yyvsp[-1].nodeval == NULL)
- yyval.nodeval = yyvsp[0].nodeval;
- else {
- if (yyvsp[-1].nodeval->type != Node_rule_list)
- yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_rule_list,
- (NODE*)NULL);
- yyval.nodeval = append_right (yyvsp[-1].nodeval,
- node(yyvsp[0].nodeval, Node_rule_list,(NODE *) NULL));
- }
- yyerrok;
- ;
- break;}
- case 4:
- #line 165 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 5:
- #line 166 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 6:
- #line 167 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 7:
- #line 171 "awk.y"
- { io_allowed = 0; ;
- break;}
- case 8:
- #line 173 "awk.y"
- {
- if (begin_block) {
- if (begin_block->type != Node_rule_list)
- begin_block = node(begin_block, Node_rule_list,
- (NODE *)NULL);
- (void) append_right (begin_block, node(
- node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
- Node_rule_list, (NODE *)NULL) );
- } else
- begin_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
- yyval.nodeval = NULL;
- io_allowed = 1;
- yyerrok;
- ;
- break;}
- case 9:
- #line 187 "awk.y"
- { io_allowed = 0; ;
- break;}
- case 10:
- #line 189 "awk.y"
- {
- if (end_block) {
- if (end_block->type != Node_rule_list)
- end_block = node(end_block, Node_rule_list,
- (NODE *)NULL);
- (void) append_right (end_block, node(
- node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval),
- Node_rule_list, (NODE *)NULL));
- } else
- end_block = node((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval);
- yyval.nodeval = NULL;
- io_allowed = 1;
- yyerrok;
- ;
- break;}
- case 11:
- #line 204 "awk.y"
- {
- warning("BEGIN blocks must have an action part");
- errcount++;
- yyerrok;
- ;
- break;}
- case 12:
- #line 210 "awk.y"
- {
- warning("END blocks must have an action part");
- errcount++;
- yyerrok;
- ;
- break;}
- case 13:
- #line 216 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
- break;}
- case 14:
- #line 218 "awk.y"
- { yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ;
- break;}
- case 15:
- #line 220 "awk.y"
- {
- yyval.nodeval = node (yyvsp[-1].nodeval,
- Node_rule_node,
- node(node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL),
- Node_K_print,
- (NODE *) NULL));
- yyerrok;
- ;
- break;}
- case 16:
- #line 233 "awk.y"
- {
- func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval);
- yyval.nodeval = NULL;
- yyerrok;
- ;
- break;}
- case 17:
- #line 242 "awk.y"
- { yyval.sval = yyvsp[0].sval; ;
- break;}
- case 18:
- #line 244 "awk.y"
- { yyval.sval = yyvsp[0].sval; ;
- break;}
- case 19:
- #line 246 "awk.y"
- {
- yyerror("%s() is a built-in function, it cannot be redefined",
- tokstart);
- errcount++;
- /* yyerrok; */
- ;
- break;}
- case 22:
- #line 261 "awk.y"
- {
- param_counter = 0;
- ;
- break;}
- case 23:
- #line 265 "awk.y"
- {
- yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval);
- can_return = 1;
- /* check for duplicate parameter names */
- if (dup_parms(yyval.nodeval))
- errcount++;
- ;
- break;}
- case 24:
- #line 276 "awk.y"
- {
- yyval.nodeval = yyvsp[-2].nodeval;
- can_return = 0;
- ;
- break;}
- case 25:
- #line 281 "awk.y"
- {
- yyval.nodeval = node((NODE *) NULL, Node_K_return, (NODE *) NULL);
- can_return = 0;
- ;
- break;}
- case 26:
- #line 290 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 27:
- #line 292 "awk.y"
- { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ;
- break;}
- case 28:
- #line 301 "awk.y"
- { ++want_regexp; ;
- break;}
- case 29:
- #line 303 "awk.y"
- {
- NODE *n;
- size_t len;
-
- getnode(n);
- n->type = Node_regex;
- len = strlen(yyvsp[-1].sval);
- n->re_exp = make_string(yyvsp[-1].sval, len);
- n->re_reg = make_regexp(yyvsp[-1].sval, len, 0, 1);
- n->re_text = NULL;
- n->re_flags = CONST;
- n->re_cnt = 1;
- yyval.nodeval = n;
- ;
- break;}
- case 30:
- #line 321 "awk.y"
- { yyval.nodeval = yyvsp[-3].nodeval ; ;
- break;}
- case 31:
- #line 323 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 32:
- #line 328 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 33:
- #line 330 "awk.y"
- {
- if (yyvsp[-1].nodeval == NULL || yyvsp[-1].nodeval->type != Node_statement_list)
- yyvsp[-1].nodeval = node(yyvsp[-1].nodeval, Node_statement_list,(NODE *)NULL);
- yyval.nodeval = append_right(yyvsp[-1].nodeval,
- node( yyvsp[0].nodeval, Node_statement_list, (NODE *)NULL));
- yyerrok;
- ;
- break;}
- case 34:
- #line 338 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 35:
- #line 340 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 38:
- #line 350 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 39:
- #line 352 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 40:
- #line 354 "awk.y"
- { yyval.nodeval = yyvsp[-1].nodeval; ;
- break;}
- case 41:
- #line 356 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 42:
- #line 358 "awk.y"
- { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ;
- break;}
- case 43:
- #line 360 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ;
- break;}
- case 44:
- #line 362 "awk.y"
- {
- yyval.nodeval = node (yyvsp[0].nodeval, Node_K_arrayfor, make_for_loop(variable(yyvsp[-5].sval,1),
- (NODE *)NULL, variable(yyvsp[-3].sval,1)));
- ;
- break;}
- case 45:
- #line 367 "awk.y"
- {
- yyval.nodeval = node(yyvsp[0].nodeval, Node_K_for, (NODE *)make_for_loop(yyvsp[-7].nodeval, yyvsp[-5].nodeval, yyvsp[-3].nodeval));
- ;
- break;}
- case 46:
- #line 371 "awk.y"
- {
- yyval.nodeval = node (yyvsp[0].nodeval, Node_K_for,
- (NODE *)make_for_loop(yyvsp[-6].nodeval, (NODE *)NULL, yyvsp[-3].nodeval));
- ;
- break;}
- case 47:
- #line 377 "awk.y"
- { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ;
- break;}
- case 48:
- #line 380 "awk.y"
- { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ;
- break;}
- case 49:
- #line 382 "awk.y"
- { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ;
- break;}
- case 50:
- #line 384 "awk.y"
- {
- if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL) {
- static int warned = 0;
-
- yyvsp[-2].nodeval = node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL);
-
- if (do_lint && ! io_allowed && ! warned) {
- warned = 1;
- warning(
- "plain `print' in BEGIN or END rule should probably be `print \"\"'");
- }
- }
-
- yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval);
- ;
- break;}
- case 51:
- #line 404 "awk.y"
- { NODETYPE type;
-
- if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) {
- if (do_lint)
- warning("`next file' is a gawk extension");
- if (do_unix || do_posix) {
- /*
- * can't use yyerror, since may have overshot
- * the source line
- */
- errcount++;
- error("`next file' is a gawk extension");
- }
- if (! io_allowed) {
- /* same thing */
- errcount++;
- error("`next file' used in BEGIN or END action");
- }
- type = Node_K_nextfile;
- } else {
- if (! io_allowed)
- yyerror("next used in BEGIN or END action");
- type = Node_K_next;
- }
- yyval.nodeval = node ((NODE *)NULL, type, (NODE *)NULL);
- ;
- break;}
- case 52:
- #line 431 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ;
- break;}
- case 53:
- #line 433 "awk.y"
- { if (! can_return) yyerror("return used outside function context"); ;
- break;}
- case 54:
- #line 435 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ;
- break;}
- case 55:
- #line 437 "awk.y"
- { yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ;
- break;}
- case 56:
- #line 439 "awk.y"
- {
- if (do_lint)
- warning("`delete array' is a gawk extension");
- if (do_unix || do_posix) {
- /*
- * can't use yyerror, since may have overshot
- * the source line
- */
- errcount++;
- error("`delete array' is a gawk extension");
- }
- yyval.nodeval = node (variable(yyvsp[-1].sval,1), Node_K_delete, (NODE *) NULL);
- ;
- break;}
- case 57:
- #line 453 "awk.y"
- { yyval.nodeval = yyvsp[-1].nodeval; ;
- break;}
- case 58:
- #line 458 "awk.y"
- { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
- break;}
- case 59:
- #line 460 "awk.y"
- { yyval.nodetypeval = yyvsp[0].nodetypeval; ;
- break;}
- case 60:
- #line 465 "awk.y"
- {
- yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if,
- node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL));
- ;
- break;}
- case 61:
- #line 471 "awk.y"
- { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if,
- node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ;
- break;}
- case 62:
- #line 477 "awk.y"
- { want_assign = 0; ;
- break;}
- case 66:
- #line 488 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 67:
- #line 490 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ;
- break;}
- case 68:
- #line 495 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 69:
- #line 497 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ;
- break;}
- case 70:
- #line 499 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ;
- break;}
- case 71:
- #line 501 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ;
- break;}
- case 72:
- #line 506 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 73:
- #line 508 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 74:
- #line 513 "awk.y"
- { yyval.nodeval = make_param(yyvsp[0].sval); ;
- break;}
- case 75:
- #line 515 "awk.y"
- { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ;
- break;}
- case 76:
- #line 517 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 77:
- #line 519 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 78:
- #line 521 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 79:
- #line 527 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 80:
- #line 529 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 81:
- #line 534 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 82:
- #line 536 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 83:
- #line 541 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
- break;}
- case 84:
- #line 543 "awk.y"
- {
- yyval.nodeval = append_right(yyvsp[-2].nodeval,
- node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
- yyerrok;
- ;
- break;}
- case 85:
- #line 549 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 86:
- #line 551 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 87:
- #line 553 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 88:
- #line 555 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 89:
- #line 560 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 90:
- #line 562 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 91:
- #line 567 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ;
- break;}
- case 92:
- #line 569 "awk.y"
- {
- yyval.nodeval = append_right(yyvsp[-2].nodeval,
- node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL));
- yyerrok;
- ;
- break;}
- case 93:
- #line 575 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 94:
- #line 577 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 95:
- #line 579 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 96:
- #line 581 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 97:
- #line 586 "awk.y"
- { want_assign = 0; ;
- break;}
- case 98:
- #line 588 "awk.y"
- {
- if (do_lint && yyvsp[0].nodeval->type == Node_regex)
- warning("Regular expression on left of assignment.");
- yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval);
- ;
- break;}
- case 99:
- #line 594 "awk.y"
- { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ;
- break;}
- case 100:
- #line 596 "awk.y"
- {
- yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline,
- node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL));
- ;
- break;}
- case 101:
- #line 601 "awk.y"
- {
- if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
- warning("non-redirected getline undefined inside BEGIN or END action");
- yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
- ;
- break;}
- case 102:
- #line 607 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
- break;}
- case 103:
- #line 609 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
- break;}
- case 104:
- #line 611 "awk.y"
- {
- if (yyvsp[-2].nodeval->type == Node_regex)
- warning("Regular expression on left of MATCH operator.");
- yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval));
- ;
- break;}
- case 105:
- #line 617 "awk.y"
- {
- yyval.nodeval = yyvsp[0].nodeval;
- if (do_lint && tokstart[0] == '*') {
- /* possible C comment */
- int n = strlen(tokstart) - 1;
- if (tokstart[n] == '*')
- warning("regexp looks like a C comment, but is not");
- }
- ;
- break;}
- case 106:
- #line 627 "awk.y"
- {
- yyval.nodeval = node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_nomatch,
- yyvsp[0].nodeval);
- ;
- break;}
- case 107:
- #line 635 "awk.y"
- { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
- break;}
- case 108:
- #line 637 "awk.y"
- {
- if (do_lint && yyvsp[0].nodeval->type == Node_regex)
- warning("Regular expression on left of comparison.");
- yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval);
- ;
- break;}
- case 109:
- #line 643 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ;
- break;}
- case 110:
- #line 645 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ;
- break;}
- case 111:
- #line 647 "awk.y"
- { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
- break;}
- case 112:
- #line 649 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 113:
- #line 651 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
- break;}
- case 114:
- #line 656 "awk.y"
- { want_assign = 0; ;
- break;}
- case 115:
- #line 658 "awk.y"
- { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ;
- break;}
- case 116:
- #line 660 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ;
- break;}
- case 117:
- #line 662 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ;
- break;}
- case 118:
- #line 664 "awk.y"
- {
- if (do_lint && ! io_allowed && yyvsp[0].nodeval == NULL)
- warning("non-redirected getline undefined inside BEGIN or END action");
- yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_getline, yyvsp[0].nodeval);
- ;
- break;}
- case 119:
- #line 670 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 120:
- #line 672 "awk.y"
- { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ;
- break;}
- case 121:
- #line 674 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ;
- break;}
- case 122:
- #line 676 "awk.y"
- { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ;
- break;}
- case 123:
- #line 678 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ;
- break;}
- case 124:
- #line 680 "awk.y"
- { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));;
- break;}
- case 125:
- #line 682 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 126:
- #line 684 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ;
- break;}
- case 128:
- #line 691 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ;
- break;}
- case 129:
- #line 693 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ;
- break;}
- case 130:
- #line 695 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ;
- break;}
- case 131:
- #line 697 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ;
- break;}
- case 132:
- #line 699 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ;
- break;}
- case 133:
- #line 701 "awk.y"
- { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ;
- break;}
- case 134:
- #line 703 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ;
- break;}
- case 135:
- #line 705 "awk.y"
- { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ;
- break;}
- case 136:
- #line 710 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ;
- break;}
- case 137:
- #line 712 "awk.y"
- { yyval.nodeval = yyvsp[-1].nodeval; ;
- break;}
- case 138:
- #line 715 "awk.y"
- { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
- break;}
- case 139:
- #line 717 "awk.y"
- { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ;
- break;}
- case 140:
- #line 719 "awk.y"
- {
- if (do_lint)
- warning("call of `length' without parentheses is not portable");
- yyval.nodeval = snode ((NODE *)NULL, Node_builtin, (int) yyvsp[0].lval);
- if (do_posix)
- warning( "call of `length' without parentheses is deprecated by POSIX");
- ;
- break;}
- case 141:
- #line 727 "awk.y"
- {
- yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval)));
- free(yyvsp[-3].sval);
- ;
- break;}
- case 143:
- #line 733 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ;
- break;}
- case 144:
- #line 735 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ;
- break;}
- case 145:
- #line 737 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 146:
- #line 739 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 147:
- #line 742 "awk.y"
- { if (yyvsp[0].nodeval->type == Node_val) {
- yyvsp[0].nodeval->numbr = -(force_number(yyvsp[0].nodeval));
- yyval.nodeval = yyvsp[0].nodeval;
- } else
- yyval.nodeval = node (yyvsp[0].nodeval, Node_unary_minus, (NODE *)NULL);
- ;
- break;}
- case 148:
- #line 749 "awk.y"
- {
- /* was: $$ = $2 */
- /* POSIX semantics: force a conversion to numeric type */
- yyval.nodeval = node (make_number(0.0), Node_plus, yyvsp[0].nodeval);
- ;
- break;}
- case 149:
- #line 758 "awk.y"
- { yyval.nodeval = NULL; ;
- break;}
- case 150:
- #line 760 "awk.y"
- { yyval.nodeval = yyvsp[0].nodeval; ;
- break;}
- case 151:
- #line 765 "awk.y"
- { yyval.nodeval = variable(yyvsp[0].sval,1); ;
- break;}
- case 152:
- #line 767 "awk.y"
- {
- if (yyvsp[-1].nodeval->rnode == NULL) {
- yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval->lnode);
- freenode(yyvsp[-1].nodeval);
- } else
- yyval.nodeval = node (variable(yyvsp[-3].sval,1), Node_subscript, yyvsp[-1].nodeval);
- ;
- break;}
- case 153:
- #line 775 "awk.y"
- { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ;
- break;}
- case 155:
- #line 783 "awk.y"
- { yyerrok; ;
- break;}
- case 156:
- #line 787 "awk.y"
- { yyerrok; ;
- break;}
- case 159:
- #line 796 "awk.y"
- { yyerrok; want_assign = 0; ;
- break;}
- case 160:
- #line 799 "awk.y"
- { yyerrok; ;
- break;}
- }
- /* the action file gets copied in in place of this dollarsign */
- #line 465 "/usr/local/lib/bison.simple"
-
- yyvsp -= yylen;
- yyssp -= yylen;
- #ifdef YYLSP_NEEDED
- yylsp -= yylen;
- #endif
-
- #if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
- #endif
-
- *++yyvsp = yyval;
-
- #ifdef YYLSP_NEEDED
- yylsp++;
- if (yylen == 0)
- {
- yylsp->first_line = yylloc.first_line;
- yylsp->first_column = yylloc.first_column;
- yylsp->last_line = (yylsp-1)->last_line;
- yylsp->last_column = (yylsp-1)->last_column;
- yylsp->text = 0;
- }
- else
- {
- yylsp->last_line = (yylsp+yylen-1)->last_line;
- yylsp->last_column = (yylsp+yylen-1)->last_column;
- }
- #endif
-
- /* 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. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
- yyerrlab: /* here on detecting error */
-
- if (! yyerrstatus)
- /* If not already recovering from an error, report this error. */
- {
- ++yynerrs;
-
- #ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- int size = 0;
- char *msg;
- int x, count;
-
- count = 0;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- {
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
- count++;
- }
- }
- yyerror(msg);
- free(msg);
- }
- else
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
- #endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
- yyerrlab1: /* here on error raised explicitly by an action */
-
- if (yyerrstatus == 3)
- {
- /* if just tried and failed to reuse lookahead token after an error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
- #endif
-
- yychar = YYEMPTY;
- }
-
- /* Else will try to reuse lookahead token
- after shifting the error token. */
-
- yyerrstatus = 3; /* Each real token shifted decrements this */
-
- goto yyerrhandle;
-
- yyerrdefault: /* current state does not do anything special for the error token. */
-
- #if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
- if (yyn) goto yydefault;
- #endif
-
- yyerrpop: /* pop the current state because it cannot handle the error token */
-
- if (yyssp == yyss) YYABORT;
- yyvsp--;
- yystate = *--yyssp;
- #ifdef YYLSP_NEEDED
- yylsp--;
- #endif
-
- #if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
- #endif
-
- yyerrhandle:
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
-
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- #if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting error token, ");
- #endif
-
- *++yyvsp = yylval;
- #ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
- #endif
-
- yystate = yyn;
- goto yynewstate;
- }
- #line 802 "awk.y"
-
-
- struct token {
- const char *operator; /* text to match */
- NODETYPE value; /* node type */
- int class; /* lexical class */
- unsigned flags; /* # of args. allowed and compatability */
- # define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */
- # define A(n) (1<<(n))
- # define VERSION 0xFF00 /* old awk is zero */
- # define NOT_OLD 0x0100 /* feature not in old awk */
- # define NOT_POSIX 0x0200 /* feature not in POSIX */
- # define GAWKX 0x0400 /* gawk extension */
- NODE *(*ptr) (); /* function that implements this keyword */
- };
-
- extern NODE
- *do_exp(), *do_getline(), *do_index(), *do_length(),
- *do_sqrt(), *do_log(), *do_sprintf(), *do_substr(),
- *do_split(), *do_system(), *do_int(), *do_close(),
- *do_atan2(), *do_sin(), *do_cos(), *do_rand(),
- *do_srand(), *do_match(), *do_tolower(), *do_toupper(),
- *do_sub(), *do_gsub(), *do_strftime(), *do_systime();
-
- /* Tokentab is sorted ascii ascending order, so it can be binary searched. */
-
- static struct token tokentab[] = {
- {"BEGIN", Node_illegal, LEX_BEGIN, 0, 0},
- {"END", Node_illegal, LEX_END, 0, 0},
- {"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2},
- {"break", Node_K_break, LEX_BREAK, 0, 0},
- {"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close},
- {"continue", Node_K_continue, LEX_CONTINUE, 0, 0},
- {"cos", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos},
- {"delete", Node_K_delete, LEX_DELETE, NOT_OLD, 0},
- {"do", Node_K_do, LEX_DO, NOT_OLD, 0},
- {"else", Node_illegal, LEX_ELSE, 0, 0},
- {"exit", Node_K_exit, LEX_EXIT, 0, 0},
- {"exp", Node_builtin, LEX_BUILTIN, A(1), do_exp},
- {"for", Node_K_for, LEX_FOR, 0, 0},
- {"func", Node_K_function, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0},
- {"function", Node_K_function, LEX_FUNCTION, NOT_OLD, 0},
- {"getline", Node_K_getline, LEX_GETLINE, NOT_OLD, 0},
- {"gsub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_gsub},
- {"if", Node_K_if, LEX_IF, 0, 0},
- {"in", Node_illegal, LEX_IN, 0, 0},
- {"index", Node_builtin, LEX_BUILTIN, A(2), do_index},
- {"int", Node_builtin, LEX_BUILTIN, A(1), do_int},
- {"length", Node_builtin, LEX_LENGTH, A(0)|A(1), do_length},
- {"log", Node_builtin, LEX_BUILTIN, A(1), do_log},
- {"match", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_match},
- {"next", Node_K_next, LEX_NEXT, 0, 0},
- {"print", Node_K_print, LEX_PRINT, 0, 0},
- {"printf", Node_K_printf, LEX_PRINTF, 0, 0},
- {"rand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand},
- {"return", Node_K_return, LEX_RETURN, NOT_OLD, 0},
- {"sin", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin},
- {"split", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_split},
- {"sprintf", Node_builtin, LEX_BUILTIN, 0, do_sprintf},
- {"sqrt", Node_builtin, LEX_BUILTIN, A(1), do_sqrt},
- {"srand", Node_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand},
- {"strftime", Node_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_strftime},
- {"sub", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_sub},
- {"substr", Node_builtin, LEX_BUILTIN, A(2)|A(3), do_substr},
- {"system", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system},
- {"systime", Node_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime},
- {"tolower", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower},
- {"toupper", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper},
- {"while", Node_K_while, LEX_WHILE, 0, 0},
- };
-
- /* VARARGS0 */
- static void
- yyerror(va_alist)
- va_dcl
- {
- va_list args;
- const char *mesg = NULL;
- register char *bp, *cp;
- char *scan;
- char buf[120];
- static char end_of_file_line[] = "(END OF FILE)";
-
- errcount++;
- /* Find the current line in the input file */
- if (lexptr && lexeme) {
- if (!thisline) {
- cp = lexeme;
- if (*cp == '\n') {
- cp--;
- mesg = "unexpected newline";
- }
- for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
- continue;
- if (*cp == '\n')
- cp++;
- thisline = cp;
- }
- /* NL isn't guaranteed */
- bp = lexeme;
- while (bp < lexend && *bp && *bp != '\n')
- bp++;
- } else {
- thisline = end_of_file_line;
- bp = thisline + strlen(thisline);
- }
- msg("%.*s", (int) (bp - thisline), thisline);
- bp = buf;
- cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
- if (lexptr) {
- scan = thisline;
- while (bp < cp && scan < lexeme)
- if (*scan++ == '\t')
- *bp++ = '\t';
- else
- *bp++ = ' ';
- *bp++ = '^';
- *bp++ = ' ';
- }
- va_start(args);
- if (mesg == NULL)
- mesg = va_arg(args, char *);
- strcpy(bp, mesg);
- err("", buf, args);
- va_end(args);
- exit(2);
- }
-
- static char *
- get_src_buf()
- {
- static int samefile = 0;
- static int nextfile = 0;
- static char *buf = NULL;
- static int fd;
- int n;
- register char *scan;
- static int len = 0;
- static int did_newline = 0;
- # define SLOP 128 /* enough space to hold most source lines */
-
- again:
- if (nextfile > numfiles)
- return NULL;
-
- if (srcfiles[nextfile].stype == CMDLINE) {
- if (len == 0) {
- len = strlen(srcfiles[nextfile].val);
- if (len == 0) {
- /*
- * Yet Another Special case:
- * gawk '' /path/name
- * Sigh.
- */
- ++nextfile;
- goto again;
- }
- sourceline = 1;
- lexptr = lexptr_begin = srcfiles[nextfile].val;
- lexend = lexptr + len;
- } else if (!did_newline && *(lexptr-1) != '\n') {
- /*
- * The following goop is to ensure that the source
- * ends with a newline and that the entire current
- * line is available for error messages.
- */
- int offset;
-
- did_newline = 1;
- offset = lexptr - lexeme;
- for (scan = lexeme; scan > lexptr_begin; scan--)
- if (*scan == '\n') {
- scan++;
- break;
- }
- len = lexptr - scan;
- emalloc(buf, char *, len+1, "get_src_buf");
- memcpy(buf, scan, len);
- thisline = buf;
- lexptr = buf + len;
- *lexptr = '\n';
- lexeme = lexptr - offset;
- lexptr_begin = buf;
- lexend = lexptr + 1;
- } else {
- len = 0;
- lexeme = lexptr = lexptr_begin = NULL;
- }
- if (lexptr == NULL && ++nextfile <= numfiles)
- return get_src_buf();
- return lexptr;
- }
- if (!samefile) {
- source = srcfiles[nextfile].val;
- if (source == NULL) {
- if (buf) {
- free(buf);
- buf = NULL;
- }
- len = 0;
- return lexeme = lexptr = lexptr_begin = NULL;
- }
- fd = pathopen(source);
- if (fd == -1)
- fatal("can't open source file \"%s\" for reading (%s)",
- source, strerror(errno));
- len = optimal_bufsize(fd);
- if (buf)
- free(buf);
- emalloc(buf, char *, len + SLOP, "get_src_buf");
- lexptr_begin = buf + SLOP;
- samefile = 1;
- sourceline = 1;
- } else {
- /*
- * Here, we retain the current source line (up to length SLOP)
- * in the beginning of the buffer that was overallocated above
- */
- int offset;
- int linelen;
-
- offset = lexptr - lexeme;
- for (scan = lexeme; scan > lexptr_begin; scan--)
- if (*scan == '\n') {
- scan++;
- break;
- }
- linelen = lexptr - scan;
- if (linelen > SLOP)
- linelen = SLOP;
- thisline = buf + SLOP - linelen;
- memcpy(thisline, scan, linelen);
- lexeme = buf + SLOP - offset;
- lexptr_begin = thisline;
- }
- n = read(fd, buf + SLOP, len);
- if (n == -1)
- fatal("can't read sourcefile \"%s\" (%s)",
- source, strerror(errno));
- if (n == 0) {
- samefile = 0;
- nextfile++;
- if (lexeme)
- *lexeme = '\0';
- len = 0;
- goto again;
- }
- lexptr = buf + SLOP;
- lexend = lexptr + n;
- return buf;
- }
-
- #define tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok)
-
- char *
- tokexpand()
- {
- static int toksize = 60;
- int tokoffset;
-
- tokoffset = tok - tokstart;
- toksize *= 2;
- if (tokstart)
- erealloc(tokstart, char *, toksize, "tokexpand");
- else
- emalloc(tokstart, char *, toksize, "tokexpand");
- tokend = tokstart + toksize;
- tok = tokstart + tokoffset;
- return tok;
- }
-
- #if DEBUG
- char
- nextc() {
- int c;
-
- if (lexptr && lexptr < lexend)
- c = *lexptr++;
- else if (get_src_buf())
- c = *lexptr++;
- else
- c = '\0';
-
- return c;
- }
- #else
- #define nextc() ((lexptr && lexptr < lexend) ? \
- *lexptr++ : \
- (get_src_buf() ? *lexptr++ : '\0') \
- )
- #endif
- #define pushback() (lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr)
-
- /*
- * Read the input and turn it into tokens.
- */
-
- static int
- yylex()
- {
- register int c;
- int seen_e = 0; /* These are for numbers */
- int seen_point = 0;
- int esc_seen; /* for literal strings */
- int low, mid, high;
- static int did_newline = 0;
- char *tokkey;
- static int lasttok = 0, eof_warned = 0;
-
- if (!nextc()) {
- if (lasttok != NEWLINE) {
- lasttok = NEWLINE;
- if (do_lint && ! eof_warned) {
- warning("source file does not end in newline");
- eof_warned = 1;
- }
- return NEWLINE; /* fake it */
- }
- return 0;
- }
- pushback();
- #ifdef OS2
- /*
- * added for OS/2's extproc feature of cmd.exe
- * (like #! in BSD sh)
- */
- if (strncasecmp(lexptr, "extproc ", 8) == 0) {
- while (*lexptr && *lexptr != '\n')
- lexptr++;
- }
- #endif
- lexeme = lexptr;
- thisline = NULL;
- if (want_regexp) {
- int in_brack = 0;
-
- want_regexp = 0;
- tok = tokstart;
- while ((c = nextc()) != 0) {
- switch (c) {
- case '[':
- in_brack = 1;
- break;
- case ']':
- in_brack = 0;
- break;
- case '\\':
- if ((c = nextc()) == '\0') {
- yyerror("unterminated regexp ends with \\ at end of file");
- } else if (c == '\n') {
- sourceline++;
- continue;
- } else
- tokadd('\\');
- break;
- case '/': /* end of the regexp */
- if (in_brack)
- break;
-
- pushback();
- tokadd('\0');
- yylval.sval = tokstart;
- return lasttok = REGEXP;
- case '\n':
- pushback();
- yyerror("unterminated regexp");
- case '\0':
- yyerror("unterminated regexp at end of file");
- }
- tokadd(c);
- }
- }
- retry:
- while ((c = nextc()) == ' ' || c == '\t')
- continue;
-
- lexeme = lexptr ? lexptr - 1 : lexptr;
- thisline = NULL;
- tok = tokstart;
- yylval.nodetypeval = Node_illegal;
-
- switch (c) {
- case 0:
- if (lasttok != NEWLINE) {
- lasttok = NEWLINE;
- if (do_lint && ! eof_warned) {
- warning("source file does not end in newline");
- eof_warned = 1;
- }
- return NEWLINE; /* fake it */
- }
- return 0;
-
- case '\n':
- sourceline++;
- return lasttok = NEWLINE;
-
- case '#': /* it's a comment */
- while ((c = nextc()) != '\n') {
- if (c == '\0') {
- if (lasttok != NEWLINE) {
- lasttok = NEWLINE;
- if (do_lint && ! eof_warned) {
- warning(
- "source file does not end in newline");
- eof_warned = 1;
- }
- return NEWLINE; /* fake it */
- }
- return 0;
- }
- }
- sourceline++;
- return lasttok = NEWLINE;
-
- case '\\':
- #ifdef RELAXED_CONTINUATION
- /*
- * This code puports to allow comments and/or whitespace
- * after the `\' at the end of a line used for continuation.
- * Use it at your own risk. We think it's a bad idea, which
- * is why it's not on by default.
- */
- if (!do_unix) {
- /* strip trailing white-space and/or comment */
- while ((c = nextc()) == ' ' || c == '\t')
- continue;
- if (c == '#')
- while ((c = nextc()) != '\n')
- if (c == '\0')
- break;
- pushback();
- }
- #endif /* RELAXED_CONTINUATION */
- if (nextc() == '\n') {
- sourceline++;
- goto retry;
- } else
- yyerror("backslash not last character on line");
- break;
-
- case '$':
- want_assign = 1;
- return lasttok = '$';
-
- case ')':
- case ']':
- case '(':
- case '[':
- case ';':
- case ':':
- case '?':
- case '{':
- case ',':
- return lasttok = c;
-
- case '*':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_times;
- return lasttok = ASSIGNOP;
- } else if (do_posix) {
- pushback();
- return lasttok = '*';
- } else if (c == '*') {
- /* make ** and **= aliases for ^ and ^= */
- static int did_warn_op = 0, did_warn_assgn = 0;
-
- if (nextc() == '=') {
- if (do_lint && ! did_warn_assgn) {
- did_warn_assgn = 1;
- warning("**= is not allowed by POSIX");
- }
- yylval.nodetypeval = Node_assign_exp;
- return lasttok = ASSIGNOP;
- } else {
- pushback();
- if (do_lint && ! did_warn_op) {
- did_warn_op = 1;
- warning("** is not allowed by POSIX");
- }
- return lasttok = '^';
- }
- }
- pushback();
- return lasttok = '*';
-
- case '/':
- if (want_assign) {
- if (nextc() == '=') {
- yylval.nodetypeval = Node_assign_quotient;
- return lasttok = ASSIGNOP;
- }
- pushback();
- }
- return lasttok = '/';
-
- case '%':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_assign_mod;
- return lasttok = ASSIGNOP;
- }
- pushback();
- return lasttok = '%';
-
- case '^':
- {
- static int did_warn_op = 0, did_warn_assgn = 0;
-
- if (nextc() == '=') {
-
- if (do_lint && ! did_warn_assgn) {
- did_warn_assgn = 1;
- warning("operator `^=' is not supported in old awk");
- }
- yylval.nodetypeval = Node_assign_exp;
- return lasttok = ASSIGNOP;
- }
- pushback();
- if (do_lint && ! did_warn_op) {
- did_warn_op = 1;
- warning("operator `^' is not supported in old awk");
- }
- return lasttok = '^';
- }
-
- case '+':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_plus;
- return lasttok = ASSIGNOP;
- }
- if (c == '+')
- return lasttok = INCREMENT;
- pushback();
- return lasttok = '+';
-
- case '!':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_notequal;
- return lasttok = RELOP;
- }
- if (c == '~') {
- yylval.nodetypeval = Node_nomatch;
- want_assign = 0;
- return lasttok = MATCHOP;
- }
- pushback();
- return lasttok = '!';
-
- case '<':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_leq;
- return lasttok = RELOP;
- }
- yylval.nodetypeval = Node_less;
- pushback();
- return lasttok = '<';
-
- case '=':
- if (nextc() == '=') {
- yylval.nodetypeval = Node_equal;
- return lasttok = RELOP;
- }
- yylval.nodetypeval = Node_assign;
- pushback();
- return lasttok = ASSIGNOP;
-
- case '>':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_geq;
- return lasttok = RELOP;
- } else if (c == '>') {
- yylval.nodetypeval = Node_redirect_append;
- return lasttok = APPEND_OP;
- }
- yylval.nodetypeval = Node_greater;
- pushback();
- return lasttok = '>';
-
- case '~':
- yylval.nodetypeval = Node_match;
- want_assign = 0;
- return lasttok = MATCHOP;
-
- case '}':
- /*
- * Added did newline stuff. Easier than
- * hacking the grammar
- */
- if (did_newline) {
- did_newline = 0;
- return lasttok = c;
- }
- did_newline++;
- --lexptr; /* pick up } next time */
- return lasttok = NEWLINE;
-
- case '"':
- esc_seen = 0;
- while ((c = nextc()) != '"') {
- if (c == '\n') {
- pushback();
- yyerror("unterminated string");
- }
- if (c == '\\') {
- c = nextc();
- if (c == '\n') {
- sourceline++;
- continue;
- }
- esc_seen = 1;
- tokadd('\\');
- }
- if (c == '\0') {
- pushback();
- yyerror("unterminated string");
- }
- tokadd(c);
- }
- yylval.nodeval = make_str_node(tokstart,
- tok - tokstart, esc_seen ? SCAN : 0);
- yylval.nodeval->flags |= PERM;
- return lasttok = YSTRING;
-
- case '-':
- if ((c = nextc()) == '=') {
- yylval.nodetypeval = Node_assign_minus;
- return lasttok = ASSIGNOP;
- }
- if (c == '-')
- return lasttok = DECREMENT;
- pushback();
- return lasttok = '-';
-
- case '.':
- c = nextc();
- pushback();
- if (!isdigit(c))
- return lasttok = '.';
- else
- c = '.'; /* FALL THROUGH */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- /* It's a number */
- for (;;) {
- int gotnumber = 0;
-
- tokadd(c);
- switch (c) {
- case '.':
- if (seen_point) {
- gotnumber++;
- break;
- }
- ++seen_point;
- break;
- case 'e':
- case 'E':
- if (seen_e) {
- gotnumber++;
- break;
- }
- ++seen_e;
- if ((c = nextc()) == '-' || c == '+')
- tokadd(c);
- else
- pushback();
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- break;
- default:
- gotnumber++;
- }
- if (gotnumber)
- break;
- c = nextc();
- }
- if (c != 0)
- pushback();
- else if (do_lint && ! eof_warned) {
- warning("source file does not end in newline");
- eof_warned = 1;
- }
- tokadd('\0');
- yylval.nodeval = make_number(atof(tokstart));
- yylval.nodeval->flags |= PERM;
- return lasttok = YNUMBER;
-
- case '&':
- if ((c = nextc()) == '&') {
- yylval.nodetypeval = Node_and;
- for (;;) {
- c = nextc();
- if (c == '\0')
- break;
- if (c == '#') {
- while ((c = nextc()) != '\n' && c != '\0')
- continue;
- if (c == '\0')
- break;
- }
- if (c == '\n')
- sourceline++;
- if (! isspace(c)) {
- pushback();
- break;
- }
- }
- want_assign = 0;
- return lasttok = LEX_AND;
- }
- pushback();
- return lasttok = '&';
-
- case '|':
- if ((c = nextc()) == '|') {
- yylval.nodetypeval = Node_or;
- for (;;) {
- c = nextc();
- if (c == '\0')
- break;
- if (c == '#') {
- while ((c = nextc()) != '\n' && c != '\0')
- continue;
- if (c == '\0')
- break;
- }
- if (c == '\n')
- sourceline++;
- if (! isspace(c)) {
- pushback();
- break;
- }
- }
- want_assign = 0;
- return lasttok = LEX_OR;
- }
- pushback();
- return lasttok = '|';
- }
-
- if (c != '_' && ! isalpha(c))
- yyerror("Invalid char '%c' in expression\n", c);
-
- /* it's some type of name-type-thing. Find its length */
- tok = tokstart;
- while (is_identchar(c)) {
- tokadd(c);
- c = nextc();
- }
- tokadd('\0');
- emalloc(tokkey, char *, tok - tokstart, "yylex");
- memcpy(tokkey, tokstart, tok - tokstart);
- if (c != 0)
- pushback();
- else if (do_lint && ! eof_warned) {
- warning("source file does not end in newline");
- eof_warned = 1;
- }
-
- /* See if it is a special token. */
- low = 0;
- high = (sizeof (tokentab) / sizeof (tokentab[0])) - 1;
- while (low <= high) {
- int i/* , c */;
-
- mid = (low + high) / 2;
- c = *tokstart - tokentab[mid].operator[0];
- i = c ? c : strcmp (tokstart, tokentab[mid].operator);
-
- if (i < 0) { /* token < mid */
- high = mid - 1;
- } else if (i > 0) { /* token > mid */
- low = mid + 1;
- } else {
- if (do_lint) {
- if (tokentab[mid].flags & GAWKX)
- warning("%s() is a gawk extension",
- tokentab[mid].operator);
- if (tokentab[mid].flags & NOT_POSIX)
- warning("POSIX does not allow %s",
- tokentab[mid].operator);
- if (tokentab[mid].flags & NOT_OLD)
- warning("%s is not supported in old awk",
- tokentab[mid].operator);
- }
- if ((do_unix && (tokentab[mid].flags & GAWKX))
- || (do_posix && (tokentab[mid].flags & NOT_POSIX)))
- break;
- if (tokentab[mid].class == LEX_BUILTIN
- || tokentab[mid].class == LEX_LENGTH
- )
- yylval.lval = mid;
- else
- yylval.nodetypeval = tokentab[mid].value;
-
- free(tokkey);
- return lasttok = tokentab[mid].class;
- }
- }
-
- yylval.sval = tokkey;
- if (*lexptr == '(')
- return lasttok = FUNC_CALL;
- else {
- want_assign = 1;
- return lasttok = NAME;
- }
- }
-
- static NODE *
- node_common(op)
- NODETYPE op;
- {
- register NODE *r;
-
- getnode(r);
- r->type = op;
- r->flags = MALLOC;
- /* if lookahead is NL, lineno is 1 too high */
- if (lexeme && *lexeme == '\n')
- r->source_line = sourceline - 1;
- else
- r->source_line = sourceline;
- r->source_file = source;
- return r;
- }
-
- /*
- * This allocates a node with defined lnode and rnode.
- */
- NODE *
- node(left, op, right)
- NODE *left, *right;
- NODETYPE op;
- {
- register NODE *r;
-
- r = node_common(op);
- r->lnode = left;
- r->rnode = right;
- return r;
- }
-
- /*
- * This allocates a node with defined subnode and proc for builtin functions
- * Checks for arg. count and supplies defaults where possible.
- */
- static NODE *
- snode(subn, op, idx)
- NODETYPE op;
- int idx;
- NODE *subn;
- {
- register NODE *r;
- register NODE *n;
- int nexp = 0;
- int args_allowed;
-
- r = node_common(op);
-
- /* traverse expression list to see how many args. given */
- for (n= subn; n; n= n->rnode) {
- nexp++;
- if (nexp > 3)
- break;
- }
-
- /* check against how many args. are allowed for this builtin */
- args_allowed = tokentab[idx].flags & ARGS;
- if (args_allowed && !(args_allowed & A(nexp)))
- fatal("%s() cannot have %d argument%c",
- tokentab[idx].operator, nexp, nexp == 1 ? ' ' : 's');
-
- r->proc = tokentab[idx].ptr;
-
- /* special case processing for a few builtins */
- if (nexp == 0 && r->proc == do_length) {
- subn = node(node(make_number(0.0),Node_field_spec,(NODE *)NULL),
- Node_expression_list,
- (NODE *) NULL);
- } else if (r->proc == do_match) {
- if (subn->rnode->lnode->type != Node_regex)
- subn->rnode->lnode = mk_rexp(subn->rnode->lnode);
- } else if (r->proc == do_sub || r->proc == do_gsub) {
- if (subn->lnode->type != Node_regex)
- subn->lnode = mk_rexp(subn->lnode);
- if (nexp == 2)
- append_right(subn, node(node(make_number(0.0),
- Node_field_spec,
- (NODE *) NULL),
- Node_expression_list,
- (NODE *) NULL));
- else if (do_lint && subn->rnode->rnode->lnode->type == Node_val)
- warning("string literal as last arg of substitute");
- } else if (r->proc == do_split) {
- if (nexp == 2)
- append_right(subn,
- node(FS_node, Node_expression_list, (NODE *) NULL));
- n = subn->rnode->rnode->lnode;
- if (n->type != Node_regex)
- subn->rnode->rnode->lnode = mk_rexp(n);
- if (nexp == 2)
- subn->rnode->rnode->lnode->re_flags |= FS_DFLT;
- }
-
- r->subnode = subn;
- return r;
- }
-
- /*
- * This allocates a Node_line_range node with defined condpair and
- * zeroes the trigger word to avoid the temptation of assuming that calling
- * 'node( foo, Node_line_range, 0)' will properly initialize 'triggered'.
- */
- /* Otherwise like node() */
- static NODE *
- mkrangenode(cpair)
- NODE *cpair;
- {
- register NODE *r;
-
- getnode(r);
- r->type = Node_line_range;
- r->condpair = cpair;
- r->triggered = 0;
- return r;
- }
-
- /* Build a for loop */
- static NODE *
- make_for_loop(init, cond, incr)
- NODE *init, *cond, *incr;
- {
- register FOR_LOOP_HEADER *r;
- NODE *n;
-
- emalloc(r, FOR_LOOP_HEADER *, sizeof(FOR_LOOP_HEADER), "make_for_loop");
- getnode(n);
- n->type = Node_illegal;
- r->init = init;
- r->cond = cond;
- r->incr = incr;
- n->sub.nodep.r.hd = r;
- return n;
- }
-
- /*
- * Install a name in the symbol table, even if it is already there.
- * Caller must check against redefinition if that is desired.
- */
- NODE *
- install(name, value)
- char *name;
- NODE *value;
- {
- register NODE *hp;
- register size_t len;
- register int bucket;
-
- len = strlen(name);
- bucket = hash(name, len, (unsigned long) HASHSIZE);
- getnode(hp);
- hp->type = Node_hashnode;
- hp->hnext = variables[bucket];
- variables[bucket] = hp;
- hp->hlength = len;
- hp->hvalue = value;
- hp->hname = name;
- hp->hvalue->vname = name;
- return hp->hvalue;
- }
-
- /* find the most recent hash node for name installed by install */
- NODE *
- lookup(name)
- const char *name;
- {
- register NODE *bucket;
- register size_t len;
-
- len = strlen(name);
- bucket = variables[hash(name, len, (unsigned long) HASHSIZE)];
- while (bucket) {
- if (bucket->hlength == len && STREQN(bucket->hname, name, len))
- return bucket->hvalue;
- bucket = bucket->hnext;
- }
- return NULL;
- }
-
- /*
- * Add new to the rightmost branch of LIST. This uses n^2 time, so we make
- * a simple attempt at optimizing it.
- */
- static NODE *
- append_right(list, new)
- NODE *list, *new;
- {
- register NODE *oldlist;
- static NODE *savefront = NULL, *savetail = NULL;
-
- oldlist = list;
- if (savefront == oldlist) {
- savetail = savetail->rnode = new;
- return oldlist;
- } else
- savefront = oldlist;
- while (list->rnode != NULL)
- list = list->rnode;
- savetail = list->rnode = new;
- return oldlist;
- }
-
- /* return 1 if there are duplicate parameters, 0 means all ok */
- static int
- dup_parms(func)
- NODE *func;
- {
- register NODE *np;
- char *fname, **names;
- int count, i, j, dups;
- NODE *params;
-
- fname = func->param;
- count = func->param_cnt;
- params = func->rnode;
-
- if (count == 0) /* no args, no problem */
- return 0;
-
- emalloc(names, char **, count * sizeof(char *), "dup_parms");
-
- i = 0;
- for (np = params; np != NULL; np = np->rnode)
- names[i++] = np->param;
-
- dups = 0;
- for (i = 1; i < count; i++) {
- for (j = 0; j < i; j++) {
- if (strcmp(names[i], names[j]) == 0) {
- dups++;
- error(
- "function `%s': parameter #%d, `%s', duplicates parameter #%d",
- fname, i+1, names[j], j+1);
- }
- }
- }
-
- free(names);
- return (dups > 0);
- }
-
- /*
- * check if name is already installed; if so, it had better have Null value,
- * in which case def is added as the value. Otherwise, install name with def
- * as value.
- */
- static void
- func_install(params, def)
- NODE *params;
- NODE *def;
- {
- NODE *r;
-
- pop_params(params->rnode);
- pop_var(params, 0);
- r = lookup(params->param);
- if (r != NULL) {
- fatal("function name `%s' previously defined", params->param);
- } else
- (void) install(params->param, node(params, Node_func, def));
- }
-
- static void
- pop_var(np, freeit)
- NODE *np;
- int freeit;
- {
- register NODE *bucket, **save;
- register size_t len;
- char *name;
-
- name = np->param;
- len = strlen(name);
- save = &(variables[hash(name, len, (unsigned long) HASHSIZE)]);
- for (bucket = *save; bucket; bucket = bucket->hnext) {
- if (len == bucket->hlength && STREQN(bucket->hname, name, len)) {
- *save = bucket->hnext;
- freenode(bucket);
- if (freeit)
- free(np->param);
- return;
- }
- save = &(bucket->hnext);
- }
- }
-
- /*
- * pop parameters out of the symbol table. do this in reverse order to
- * avoid reading freed memory if there were duplicated parameters.
- */
- static void
- pop_params(params)
- NODE *params;
- {
- if (params == NULL)
- return;
- pop_params(params->rnode);
- pop_var(params, 1);
- }
-
- static NODE *
- make_param(name)
- char *name;
- {
- NODE *r;
-
- getnode(r);
- r->type = Node_param_list;
- r->rnode = NULL;
- r->param = name;
- r->param_cnt = param_counter++;
- return (install(name, r));
- }
-
- /* Name points to a variable name. Make sure it's in the symbol table */
- NODE *
- variable(name, can_free)
- char *name;
- int can_free;
- {
- register NODE *r;
- static int env_loaded = 0;
-
- if (!env_loaded && STREQ(name, "ENVIRON")) {
- load_environ();
- env_loaded = 1;
- }
- if ((r = lookup(name)) == NULL)
- r = install(name, node(Nnull_string, Node_var, (NODE *) NULL));
- else if (can_free)
- free(name);
- return r;
- }
-
- static NODE *
- mk_rexp(exp)
- NODE *exp;
- {
- if (exp->type == Node_regex)
- return exp;
- else {
- NODE *n;
-
- getnode(n);
- n->type = Node_regex;
- n->re_exp = exp;
- n->re_text = NULL;
- n->re_reg = NULL;
- n->re_flags = 0;
- n->re_cnt = 1;
- return n;
- }
- }
-