/* A Bison parser, made from awk.y */ #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 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 *token = NULL; static char *tokend; 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 73 "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 #ifndef __STDC__ #define const #endif #define YYFINAL 306 #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, 49, 2, 2, 52, 48, 2, 2, 53, 54, 46, 44, 60, 45, 2, 47, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 40, 59, 41, 2, 42, 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, 55, 2, 56, 51, 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, 57, 43, 58, 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, 50 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 4, 6, 9, 11, 14, 15, 19, 20, 24, 27, 30, 33, 35, 38, 41, 43, 45, 47, 49, 51, 52, 60, 65, 67, 71, 72, 77, 83, 88, 90, 93, 95, 98, 100, 103, 106, 109, 113, 115, 122, 131, 140, 151, 161, 164, 167, 174, 179, 183, 187, 188, 193, 200, 203, 205, 207, 214, 224, 226, 229, 230, 232, 233, 236, 237, 240, 243, 246, 247, 249, 251, 255, 257, 260, 264, 265, 267, 268, 270, 272, 276, 278, 281, 285, 289, 290, 292, 294, 298, 300, 303, 307, 311, 312, 317, 323, 328, 332, 336, 340, 344, 346, 349, 353, 357, 361, 365, 371, 373, 376, 377, 382, 386, 390, 394, 396, 399, 403, 407, 411, 417, 419, 422, 424, 428, 432, 436, 440, 444, 448, 451, 454, 457, 461, 466, 471, 473, 478, 480, 483, 486, 488, 490, 493, 496, 497, 499, 501, 506, 509, 512, 515, 517, 518, 520, 522 }; #endif static const short yyrhs[] = { 82, 62, 82, 0, 63, 0, 62, 63, 0, 1, 0, 62, 1, 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, 53, 85, 102, 82, 0, 100, 75, 101, 103, 0, 92, 0, 92, 105, 92, 0, 0, 47, 73, 5, 47, 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, 53, 92, 102, 82, 77, 0, 22, 82, 77, 21, 53, 92, 102, 82, 0, 23, 53, 4, 32, 4, 102, 82, 77, 0, 23, 53, 87, 104, 92, 104, 87, 102, 82, 77, 0, 23, 53, 87, 104, 104, 87, 102, 82, 77, 0, 24, 76, 0, 25, 76, 0, 79, 53, 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, 55, 91, 56, 76, 0, 92, 76, 0, 26, 0, 27, 0, 17, 53, 92, 102, 82, 77, 0, 17, 53, 92, 102, 82, 77, 18, 82, 77, 0, 13, 0, 81, 13, 0, 0, 81, 0, 0, 41, 96, 0, 0, 42, 92, 0, 10, 92, 0, 43, 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, 53, 91, 102, 32, 4, 0, 92, 43, 31, 98, 0, 31, 98, 83, 0, 92, 33, 92, 0, 92, 34, 92, 0, 92, 12, 92, 0, 72, 0, 49, 72, 0, 92, 32, 4, 0, 92, 9, 92, 0, 92, 41, 92, 0, 92, 42, 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, 49, 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, 51, 96, 0, 96, 46, 96, 0, 96, 47, 96, 0, 96, 48, 96, 0, 96, 44, 96, 0, 96, 45, 96, 0, 99, 35, 0, 99, 36, 0, 49, 96, 0, 53, 92, 102, 0, 37, 53, 90, 102, 0, 38, 53, 90, 102, 0, 38, 0, 3, 53, 90, 102, 0, 99, 0, 35, 99, 0, 36, 99, 0, 7, 0, 8, 0, 45, 96, 0, 44, 96, 0, 0, 99, 0, 4, 0, 4, 55, 91, 56, 0, 52, 97, 0, 57, 82, 0, 58, 82, 0, 54, 0, 0, 104, 0, 59, 0, 60, 82, 0 }; #if YYDEBUG != 0 static const short yyrline[] = { 0, 133, 138, 146, 162, 163, 167, 169, 183, 185, 199, 205, 211, 213, 215, 228, 237, 239, 241, 251, 252, 256, 260, 268, 277, 279, 288, 290, 308, 310, 315, 317, 325, 327, 332, 333, 337, 339, 341, 343, 345, 347, 349, 354, 358, 363, 366, 369, 371, 382, 400, 402, 404, 406, 408, 413, 415, 420, 425, 432, 434, 438, 439, 443, 445, 450, 452, 454, 456, 461, 463, 468, 470, 472, 474, 476, 482, 484, 489, 491, 496, 498, 504, 506, 508, 510, 515, 517, 522, 524, 530, 532, 534, 536, 541, 544, 549, 551, 556, 562, 564, 566, 572, 574, 582, 584, 590, 592, 594, 596, 598, 603, 606, 607, 609, 611, 617, 619, 621, 623, 625, 627, 629, 631, 636, 638, 640, 642, 644, 646, 648, 650, 652, 657, 659, 661, 664, 666, 674, 678, 679, 681, 683, 685, 688, 695, 700, 702, 707, 709, 717, 722, 726, 730, 734, 735, 739, 742 }; 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, 64, 63, 65, 63, 63, 63, 63, 63, 63, 63, 66, 66, 66, 67, 67, 69, 68, 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, 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, 3, 0, 3, 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, 1, 0, 7, 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, 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[] = { 61, 59, 62, 0, 60, 4, 0, 148, 142, 143, 6, 8, 21, 146, 0, 0, 0, 137, 0, 0, 26, 0, 0, 0, 61, 0, 2, 0, 0, 102, 13, 24, 109, 124, 139, 0, 0, 0, 156, 0, 10, 34, 61, 0, 11, 0, 63, 147, 140, 141, 0, 0, 0, 0, 145, 139, 144, 0, 103, 133, 150, 139, 90, 0, 88, 151, 5, 3, 1, 15, 0, 12, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 110, 0, 0, 0, 0, 0, 0, 0, 94, 131, 132, 32, 0, 51, 0, 0, 61, 0, 0, 0, 55, 56, 76, 76, 61, 0, 30, 0, 39, 0, 0, 154, 61, 0, 0, 88, 0, 7, 35, 9, 17, 16, 19, 20, 0, 18, 0, 98, 0, 0, 0, 0, 91, 153, 0, 0, 134, 0, 105, 101, 104, 99, 100, 0, 106, 107, 146, 157, 25, 129, 130, 126, 127, 128, 125, 0, 0, 76, 0, 0, 0, 76, 45, 46, 0, 77, 0, 152, 33, 31, 154, 82, 146, 0, 0, 116, 65, 0, 80, 122, 139, 54, 0, 37, 61, 155, 36, 138, 149, 0, 64, 135, 136, 27, 92, 0, 93, 89, 154, 0, 97, 95, 0, 0, 0, 0, 0, 148, 0, 49, 50, 61, 63, 117, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 123, 111, 38, 29, 73, 71, 0, 0, 96, 23, 108, 61, 52, 0, 61, 0, 0, 0, 28, 115, 65, 67, 66, 68, 48, 84, 85, 81, 120, 118, 119, 113, 114, 0, 0, 61, 74, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 112, 22, 75, 72, 57, 53, 40, 0, 61, 76, 0, 47, 121, 61, 61, 0, 0, 61, 0, 41, 42, 61, 0, 58, 0, 44, 43, 0, 0, 0 }; static const short yydefgoto[] = { 304, 25, 26, 39, 43, 127, 128, 27, 45, 69, 28, 29, 57, 30, 108, 40, 109, 160, 110, 111, 2, 3, 130, 221, 236, 237, 167, 179, 180, 116, 117, 112, 158, 181, 264, 32, 33, 46, 34, 113, 114, 139, 187, 115, 138 }; static const short yypact[] = { -6, -32768, 8, 1094,-32768,-32768, -26, -11,-32768,-32768, -1, -1,-32768, 1, 1, 1, 16, 31, 1738, 1738,-32768, 1691, 1738, 1186, -6, 890,-32768, -5, -2,-32768,-32768, 836, 69,-32768, 83, 612, 1166, 1186,-32768, -5,-32768, 8, -6, -5,-32768, 101, 20,-32768,-32768,-32768, 1166, 1166, 1738, 1606, 36, 2, 36, 62,-32768, 36,-32768, -32768,-32768, 5, 1299,-32768,-32768,-32768,-32768,-32768, 726, -32768,-32768, 1606, 1606, 93, 1606, 1606, 1606, 1606, 1606, 70, -6, 69, 1606, 1738, 1738, 1738, 1738, 1738, 1738, -32768,-32768,-32768,-32768, 54,-32768, 105, 58, -6, 68, -1, -1,-32768,-32768, 1606, 1606, -6, 679,-32768, 783, -32768, 994, 612, 78, -6, 86, 18, 1398, 23,-32768, -32768,-32768,-32768,-32768,-32768,-32768, 90,-32768, 1738,-32768, 86, 86, 1299, 97, 1606,-32768, 104, 1233,-32768, 679, 1373, 1753,-32768, 1506, 1445, 1351, 1373, 1373, 1,-32768, 1398, 130, 130, 36, 36, 36, 36, 1606, 1606, 1606, 92, 1606, 937, 1625,-32768,-32768, -1, 1398, -1,-32768, -32768,-32768, 78,-32768, 1, 1691, 1186,-32768, 0, 3, 1528, 69, 89,-32768, 679,-32768, -6,-32768,-32768,-32768, -32768, 14, 69,-32768,-32768,-32768, 1398, 144,-32768, 1398, 78, 1606,-32768, 1398, 1299, -1, 1186, 1299, 131, -15, 78,-32768,-32768, -6, 20,-32768, 5, 1606, 1606, 1606, -1, 1672, 1252, 1672, 1672, 147, 1672, 1672, 1672, 69, -32768,-32768,-32768,-32768,-32768, 86, 28,-32768,-32768, 1398, -6,-32768, 29, -6, 100, 150, 1119,-32768,-32768, 0, 1398, 1398, 1398,-32768, 1528,-32768, 1528, 802, 1013,-32768, 1586, 1567, 1467, 1672, -6,-32768, 35, 937, -1, 937, 1606, 86, 1047, 1606, -1, 1672, 1528,-32768,-32768,-32768, 140,-32768,-32768, 1299, -6, 1606, 86,-32768, 1528, -6, -6, 937, 86, -6, 937,-32768,-32768, -6, 937,-32768, 937,-32768,-32768, 160, 172,-32768 }; static const short yypgoto[] = {-32768, -32768, 148,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 91,-32768, 106, -47, 82, -99,-32768,-32768,-32768, 21, 155, -40, -65,-32768,-32768, -104,-32768,-32768, 76, -9, -3,-32768, 11,-32768, 325, 164, -124, 77, 103, -105, 247, -147, 406, -30 }; #define YYLAST 1806 static const short yytable[] = { 31, 84, 169, 173, 222, 7, 135, 1, 186, 172, 218, 1, 1, -79, 63, 234, -79, 246, 235, 135, 64, 4, 31, 140, 135, 203, 214, 36, 119, 266, 135, 41, 41, 118, 118, 201, 279, 92, 93, 280, 37, 172, 219, 220, 37, -79, -79, 118, 118, 41, 133, 215, 24, 22, 239, 24, 206, 38, 38, 136, 211, 129, -79, 82, 209, 82, 185, 134, -69, 50, 141, 142, -87, 144, 145, 146, 147, 148, 82, 191, 232, 151, -70, 82, 51, 269, 172, 90, 82, 82, 47, 48, 49, 44, 91, 55, 55, 143, 55, 61, 231, 149, 168, 168, 123, 124, 35, 159, 55, 161, 72, 162, 58, 85, 86, 87, 88, 89, 92, 93, 90, 164, 41, 41, 92, 93, 131, 132, 35, 55, 70, 35, 197, 41, 71, 200, 198, 38, 125, 126, 136, 55, 35, 192, 196, 120, 35, 207, 238, 122, 223, 260, 245, 271, 272, 204, 205, 168, 290, 208, 305, 168, 55, 55, 55, 55, 55, 55, 217, 281, 287, 283, 306, 67, 64, 249, 87, 88, 89, 65, 68, 90, 293, 165, 166, 275, 60, 183, 41, 55, 41, 0, 0, 297, 184, 55, 300, 121, 243, 240, 302, 178, 303, 0, 118, 0, 55, 267, 0, 0, 55, 0, 0, 0, 0, 251, 252, 253, 55, 55, 0, 55, 55, 55, 55, 55, 47, 41, 55, 0, 0, 0, 0, 255, 257, 258, 259, 150, 261, 262, 263, 0, 41, 0, 273, 55, 0, 0, 0, 212, 0, 213, 47, 55, 163, 0, 0, 0, 55, 0, 0, 0, 170, 0, 0, 0, 0, 216, 284, 0, 189, 168, 0, 0, 55, 277, 0, 55, 0, 0, 0, 55, 55, 168, 0, 55, 0, 289, 242, 0, 41, 0, 0, 0, 0, 0, 41, 0, 0, 183, 183, 183, 183, 254, 183, 183, 183, 0, 0, 0, 137, 0, 0, 178, 178, 178, 178, 55, 178, 178, 178, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 0, 55, 0, 55, 55, 55, 0, 55, 55, 55, 183, 233, 54, 56, 0, 59, 0, 0, 0, 55, 282, 0, 183, 55, 178, 83, 288, 0, 0, 0, 55, 0, 190, 0, 0, 55, 178, 0, 248, 0, 0, 0, 0, 0, 0, 0, 59, 194, 195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 268, 0, 0, 270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 153, 154, 155, 156, 157, 42, 42, 0, 0, 278, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 182, 0, 83, 0, 0, 292, 0, 0, 83, 0, 295, 296, 0, 0, 299, 0, 0, 241, 301, 193, 244, 0, 0, 83, 0, 0, 0, 0, 0, 250, 0, 83, 83, 0, 83, 83, 83, 83, 83, 0, 0, 83, 0, 0, 0, 0, 0, 0, 265, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 59, 0, 0, 0, 0, 230, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 285, 188, 0, 83, 0, 0, 83, 0, 0, 0, 83, 83, 291, 0, 83, 294, 0, 0, 0, 0, 0, 298, 0, 0, 0, 0, 0, 0, 182, 182, 182, 182, 0, 182, 182, 182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 42, 0, 42, 83, 83, 83, 188, 230, 0, 230, 230, 230, 0, 230, 230, 230, 182, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 182, 230, 0, 0, 0, 0, 188, 0, 83, 0, 0, 42, 94, 230, 6, 7, 247, 0, 8, 9, 0, 0, 0, 0, 0, 0, 42, 0, 95, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 0, 13, 0, 0, 0, 14, 15, 16, 17, 0, 0, 274, 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, 22, 23, 0, 0, 0, 24, 107, 38, 0, 0, 0, 42, 0, 0, 0, 286, 171, 42, 6, 7, 0, 0, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 0, 13, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 94, 21, 6, 7, 22, 23, 8, 9, 0, 24, 107, 38, 0, 0, 0, 0, 95, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 0, 13, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, 22, 23, 0, 0, 0, 24, 174, 38, 6, 7, 0, 0, 8, 9, 0, -78, 0, 0, -78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 8, 9, -32768, 0, 0, 175, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, -78, -78, 18, 19, 0, 20, 0, 176, 0, 0, 22, 177, 14, 15, 6, 7, 0, -78, 8, 9, 73, 18, 19, 74, 0, 0, 52, 0, 0, 22, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, 14, 15, 16, 17, 78, 0, 79, 80, 81, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, -61, 66, 0, 6, 7, 0, 82, 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, 18, 19, 0, 20, 0, 21, 6, 7, 22, 23, 8, 9, 0, 24, 0, 0, 0, 0, 0, 0, 95, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 0, 13, 0, 0, 0, 14, 15, 16, 17, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 8, 9, 224, 0, 0,-32768, 75, 76, 77, 14, 15, 16, 17, 78, 0, 79, 80, 81, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, 14, 15, 6, 7, 0, 38, 8, 9, 73, 18, 19, 74, 0, 0, 52, 0, 0, 22, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, 14, 15, 16, 17, 78, 0, 79, 80, 81, 18, 19, 0, 0, 5, 52, 6, 7, 22, 53, 8, 9, 0, 0, 0, 38, 0, 0, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 12, 13, 8, 9, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, 0, 22, 23, 0, 0, 13, 24, 0, 0, 14, 15, 16, 17, 0, 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, 62, 0, 6, 7, 0, 0, 8, 9, 0, 0, 13, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 0, 13, 22, 23, -86, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 199, 21, 6, 7, 22, 23, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0, 6, 7, 0, 0, 8, 9, 0, 0, 0, 13, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 175, 0, 22, 23, 14, 15, 16, 17, 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, 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, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, 136, 6, 7, 0, 0, 8, 9, 73, 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 8, 9,-32768, 75, 76, 77, 14, 15, 16, 17, 78, 202, 79, 80, 81, 18, 19, 0, 0, 0, 52, 6, 7, 22, 53, 8, 9, 73, 14, 15, 74, 0, 0, 0,-32768,-32768,-32768, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, 0, 0, 0, 75, 76, 77, 14, 15, 16, 17, 78, 0, 79, 80, 81, 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, 6, 7, 0, 0, 8, 9, 224, 75, 76, 225, 14, 15, 16, 17, 0, 0, 79, 80, 81, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, 226, 227, 228, 14, 15, 16, 17, 229, 276, 0, 6, 7, 18, 19, 8, 9, 73, 52, 0, 74, 22, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 0, 8, 9, 224, 75, 0, 225, 14, 15, 16, 17, 0, 0, 79, 80, 81, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53, 226, 227, 228, 14, 15, 16, 17, 229, 0, 0, 6, 7, 18, 19, 8, 9, 224, 52, 0, 225, 22, 53, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 0, 8, 9, 224, 0, 0, 225, 226, 227, 0, 14, 15, 16, 17, 0, 0, 0, 6, 7, 18, 19, 8, 9, 0, 52, 0, 226, 22, 53, 14, 15, 16, 17, 0, 0, 0, 6, 210, 18, 19, 8, 9, 0, 52, 0, 13, 22, 53, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 13, 0, 22, 23, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 21, 6, 7, 22, 23, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, 0, 0, 8, 9, 0, 0, 0, 175, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 176, 0, 0, 22, 53, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 20, 0, 52, 6, 7, 22, 53, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 8, 9, 73, 0, 0,-32768, 0, 0, 0, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 18, 19, 0, 0, 0, 52, 14, 15, 22, 53, 0, 0, 79, 80, 81, 18, 19, 0, 0, 0, 52, 0, 0, 22, 53 }; static const short yycheck[] = { 3, 31, 106, 108, 1, 4, 1, 13, 113, 108, 10, 13, 13, 10, 23, 1, 13, 32, 4, 1, 23, 13, 25, 70, 1, 149, 173, 53, 37, 1, 1, 10, 11, 36, 37, 140, 1, 35, 36, 4, 55, 140, 42, 43, 55, 42, 43, 50, 51, 28, 53, 175, 57, 52, 201, 57, 160, 59, 59, 54, 164, 41, 59, 60, 163, 60, 113, 5, 54, 53, 73, 74, 54, 76, 77, 78, 79, 80, 60, 56, 185, 84, 54, 60, 53, 56, 185, 51, 60, 60, 13, 14, 15, 11, 11, 18, 19, 4, 21, 22, 11, 31, 105, 106, 3, 4, 3, 53, 31, 4, 28, 53, 21, 44, 45, 46, 47, 48, 35, 36, 51, 53, 101, 102, 35, 36, 50, 51, 25, 52, 27, 28, 135, 112, 28, 138, 32, 59, 37, 38, 54, 64, 39, 53, 47, 39, 43, 55, 4, 43, 180, 4, 21, 53, 4, 158, 159, 160, 18, 162, 0, 164, 85, 86, 87, 88, 89, 90, 177, 268, 274, 270, 0, 25, 177, 215, 46, 47, 48, 24, 25, 51, 286, 101, 102, 250, 22, 110, 167, 112, 169, -1, -1, 292, 112, 118, 295, 42, 207, 202, 299, 110, 301, -1, 207, -1, 129, 237, -1, -1, 133, -1, -1, -1, -1, 218, 219, 220, 141, 142, -1, 144, 145, 146, 147, 148, 149, 206, 151, -1, -1, -1, -1, 222, 223, 224, 225, 82, 227, 228, 229, -1, 221, -1, 247, 168, -1, -1, -1, 167, -1, 169, 175, 176, 99, -1, -1, -1, 181, -1, -1, -1, 107, -1, -1, -1, -1, 176, 271, -1, 115, 274, -1, -1, 197, 264, -1, 200, -1, -1, -1, 204, 205, 286, -1, 208, -1, 276, 206, -1, 269, -1, -1, -1, -1, -1, 275, -1, -1, 222, 223, 224, 225, 221, 227, 228, 229, -1, -1, -1, 63, -1, -1, 222, 223, 224, 225, 240, 227, 228, 229, -1, -1, -1, -1, -1, -1, -1, 251, 252, 253, -1, 255, -1, 257, 258, 259, -1, 261, 262, 263, 264, 187, 18, 19, -1, 21, -1, -1, -1, 273, 269, -1, 276, 277, 264, 31, 275, -1, -1, -1, 284, -1, 116, -1, -1, 289, 276, -1, 214, -1, -1, -1, -1, -1, -1, -1, 52, 131, 132, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64, -1, -1, -1, -1, -1, -1, 241, -1, -1, 244, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, 86, 87, 88, 89, 90, 10, 11, -1, -1, 265, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 110, -1, 112, -1, -1, 285, -1, -1, 118, -1, 290, 291, -1, -1, 294, -1, -1, 205, 298, 129, 208, -1, -1, 133, -1, -1, -1, -1, -1, 217, -1, 141, 142, -1, 144, 145, 146, 147, 148, -1, -1, 151, -1, -1, -1, -1, -1, -1, 236, -1, -1, -1, -1, -1, -1, -1, -1, -1, 168, -1, -1, -1, -1, -1, -1, -1, 176, -1, -1, -1, -1, 181, 101, 102, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 272, 114, -1, 197, -1, -1, 200, -1, -1, -1, 204, 205, 284, -1, 208, 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, -1, -1, -1, 222, 223, 224, 225, -1, 227, 228, 229, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 240, -1, -1, -1, -1, -1, -1, -1, 167, -1, 169, 251, 252, 253, 173, 255, -1, 257, 258, 259, -1, 261, 262, 263, 264, -1, -1, -1, -1, -1, -1, -1, -1, 273, -1, -1, 276, 277, -1, -1, -1, -1, 201, -1, 284, -1, -1, 206, 1, 289, 3, 4, 211, -1, 7, 8, -1, -1, -1, -1, -1, -1, 221, -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, 247, -1, -1, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, -1, -1, -1, 57, 58, 59, -1, -1, -1, 269, -1, -1, -1, 273, 1, 275, 3, 4, -1, -1, 7, 8, -1, -1, -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, 44, 45, -1, 47, 1, 49, 3, 4, 52, 53, 7, 8, -1, 57, 58, 59, -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, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, -1, -1, -1, 57, 1, 59, 3, 4, -1, -1, 7, 8, -1, 10, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, 7, 8, 9, -1, -1, 31, -1, -1, -1, 35, 36, 37, 38, -1, -1, -1, 42, 43, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, 35, 36, 3, 4, -1, 59, 7, 8, 9, 44, 45, 12, -1, -1, 49, -1, -1, 52, 53, -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, -1, -1, -1, 49, -1, -1, 52, 53, 0, 1, -1, 3, 4, -1, 60, 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, 44, 45, -1, 47, -1, 49, 3, 4, 52, 53, 7, 8, -1, 57, -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, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, -1, -1, -1, 57, -1, 59, 3, 4, -1, -1, 7, 8, 9, -1, -1, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, 7, 8, 9, -1, -1, 12, 32, 33, 34, 35, 36, 37, 38, 39, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53, 35, 36, 3, 4, -1, 59, 7, 8, 9, 44, 45, 12, -1, -1, 49, -1, -1, 52, 53, -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, -1, -1, 1, 49, 3, 4, 52, 53, 7, 8, -1, -1, -1, 59, -1, -1, 15, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 30, 31, 7, 8, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, -1, -1, 31, 57, -1, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, 1, 49, 3, 4, 52, 53, 7, 8, -1, -1, -1, 59, -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, 44, 45, -1, 47, -1, 49, -1, 31, 52, 53, 54, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, 1, 49, 3, 4, 52, 53, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, 31, -1, -1, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, 31, -1, 52, 53, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, 3, 4, 52, 53, 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, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53, 54, 3, 4, -1, -1, 7, 8, 9, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, 7, 8, 9, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1, -1, -1, 49, 3, 4, 52, 53, 7, 8, 9, 35, 36, 12, -1, -1, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53, -1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, 3, 4, 52, 53, 7, 8, 9, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, -1, -1, 7, 8, 9, 32, 33, 12, 35, 36, 37, 38, -1, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53, 32, 33, 34, 35, 36, 37, 38, 39, 40, -1, 3, 4, 44, 45, 7, 8, 9, 49, -1, 12, 52, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, -1, -1, 7, 8, 9, 32, -1, 12, 35, 36, 37, 38, -1, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53, 32, 33, 34, 35, 36, 37, 38, 39, -1, -1, 3, 4, 44, 45, 7, 8, 9, 49, -1, 12, 52, 53, -1, -1, -1, -1, -1, -1, -1, 3, 4, -1, -1, 7, 8, 9, -1, -1, 12, 32, 33, -1, 35, 36, 37, 38, -1, -1, -1, 3, 4, 44, 45, 7, 8, -1, 49, -1, 32, 52, 53, 35, 36, 37, 38, -1, -1, -1, 3, 4, 44, 45, 7, 8, -1, 49, -1, 31, 52, 53, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, 31, -1, 52, 53, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, 3, 4, 52, 53, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, 31, -1, -1, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, -1, -1, 52, 53, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, 47, -1, 49, 3, 4, 52, 53, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, 7, 8, 9, -1, -1, 12, -1, -1, -1, -1, -1, -1, -1, 35, 36, 37, 38, -1, -1, -1, -1, -1, 44, 45, -1, -1, -1, 49, 35, 36, 52, 53, -1, -1, 41, 42, 43, 44, 45, -1, -1, -1, 49, -1, -1, 52, 53 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/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) #include #else /* not sparc */ #if defined (MSDOS) && !defined (__TURBOC__) #include #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) #include #pragma alloca #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 #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 169 "/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; /* 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. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), #ifdef YYLSP_NEEDED &yyls1, size * sizeof (*yylsp), #endif &yystacksize); 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]; 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 134 "awk.y" { expression_value = yyvsp[-1].nodeval; ; break;} case 2: #line 139 "awk.y" { if (yyvsp[0].nodeval != NULL) yyval.nodeval = yyvsp[0].nodeval; else yyval.nodeval = NULL; yyerrok; ; break;} case 3: #line 148 "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 162 "awk.y" { yyval.nodeval = NULL; ; break;} case 5: #line 163 "awk.y" { yyval.nodeval = NULL; ; break;} case 6: #line 167 "awk.y" { io_allowed = 0; ; break;} case 7: #line 169 "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 8: #line 183 "awk.y" { io_allowed = 0; ; break;} case 9: #line 185 "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 10: #line 200 "awk.y" { warning("BEGIN blocks must have an action part"); errcount++; yyerrok; ; break;} case 11: #line 206 "awk.y" { warning("END blocks must have an action part"); errcount++; yyerrok; ; break;} case 12: #line 212 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_rule_node, yyvsp[0].nodeval); yyerrok; ; break;} case 13: #line 214 "awk.y" { yyval.nodeval = node ((NODE *)NULL, Node_rule_node, yyvsp[0].nodeval); yyerrok; ; break;} case 14: #line 216 "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 15: #line 229 "awk.y" { func_install(yyvsp[-1].nodeval, yyvsp[0].nodeval); yyval.nodeval = NULL; yyerrok; ; break;} case 16: #line 238 "awk.y" { yyval.sval = yyvsp[0].sval; ; break;} case 17: #line 240 "awk.y" { yyval.sval = yyvsp[0].sval; ; break;} case 18: #line 242 "awk.y" { yyerror("%s() is a built-in function, it cannot be redefined", tokstart); errcount++; /* yyerrok; */ ; break;} case 21: #line 257 "awk.y" { param_counter = 0; ; break;} case 22: #line 261 "awk.y" { yyval.nodeval = append_right(make_param(yyvsp[-4].sval), yyvsp[-2].nodeval); can_return = 1; ; break;} case 23: #line 269 "awk.y" { yyval.nodeval = yyvsp[-2].nodeval; can_return = 0; ; break;} case 24: #line 278 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 25: #line 280 "awk.y" { yyval.nodeval = mkrangenode ( node(yyvsp[-2].nodeval, Node_cond_pair, yyvsp[0].nodeval) ); ; break;} case 26: #line 289 "awk.y" { ++want_regexp; ; break;} case 27: #line 291 "awk.y" { NODE *n; int 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 28: #line 309 "awk.y" { yyval.nodeval = yyvsp[-3].nodeval ; ; break;} case 29: #line 311 "awk.y" { yyval.nodeval = NULL; ; break;} case 30: #line 316 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 31: #line 318 "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 32: #line 326 "awk.y" { yyval.nodeval = NULL; ; break;} case 33: #line 328 "awk.y" { yyval.nodeval = NULL; ; break;} case 36: #line 338 "awk.y" { yyval.nodeval = NULL; ; break;} case 37: #line 340 "awk.y" { yyval.nodeval = NULL; ; break;} case 38: #line 342 "awk.y" { yyval.nodeval = yyvsp[-1].nodeval; ; break;} case 39: #line 344 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 40: #line 346 "awk.y" { yyval.nodeval = node (yyvsp[-3].nodeval, Node_K_while, yyvsp[0].nodeval); ; break;} case 41: #line 348 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_K_do, yyvsp[-5].nodeval); ; break;} case 42: #line 350 "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 43: #line 355 "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 44: #line 359 "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 45: #line 365 "awk.y" { yyval.nodeval = node ((NODE *)NULL, Node_K_break, (NODE *)NULL); ; break;} case 46: #line 368 "awk.y" { yyval.nodeval = node ((NODE *)NULL, Node_K_continue, (NODE *)NULL); ; break;} case 47: #line 370 "awk.y" { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-5].nodetypeval, yyvsp[-1].nodeval); ; break;} case 48: #line 372 "awk.y" { if (yyvsp[-3].nodetypeval == Node_K_print && yyvsp[-2].nodeval == NULL) yyvsp[-2].nodeval = node(node(make_number(0.0), Node_field_spec, (NODE *) NULL), Node_expression_list, (NODE *) NULL); yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-3].nodetypeval, yyvsp[-1].nodeval); ; break;} case 49: #line 383 "awk.y" { NODETYPE type; if (yyvsp[-1].nodeval && yyvsp[-1].nodeval == lookup("file")) { if (do_lint) warning("`next file' is a gawk extension"); else if (do_unix || do_posix) yyerror("`next file' is a gawk extension"); else if (! io_allowed) yyerror("`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 50: #line 401 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_exit, (NODE *)NULL); ; break;} case 51: #line 403 "awk.y" { if (! can_return) yyerror("return used outside function context"); ; break;} case 52: #line 405 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_K_return, (NODE *)NULL); ; break;} case 53: #line 407 "awk.y" { yyval.nodeval = node (variable(yyvsp[-4].sval,1), Node_K_delete, yyvsp[-2].nodeval); ; break;} case 54: #line 409 "awk.y" { yyval.nodeval = yyvsp[-1].nodeval; ; break;} case 55: #line 414 "awk.y" { yyval.nodetypeval = yyvsp[0].nodetypeval; ; break;} case 56: #line 416 "awk.y" { yyval.nodetypeval = yyvsp[0].nodetypeval; ; break;} case 57: #line 421 "awk.y" { yyval.nodeval = node(yyvsp[-3].nodeval, Node_K_if, node(yyvsp[0].nodeval, Node_if_branches, (NODE *)NULL)); ; break;} case 58: #line 427 "awk.y" { yyval.nodeval = node (yyvsp[-6].nodeval, Node_K_if, node (yyvsp[-3].nodeval, Node_if_branches, yyvsp[0].nodeval)); ; break;} case 59: #line 433 "awk.y" { want_assign = 0; ; break;} case 63: #line 444 "awk.y" { yyval.nodeval = NULL; ; break;} case 64: #line 446 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_input, (NODE *)NULL); ; break;} case 65: #line 451 "awk.y" { yyval.nodeval = NULL; ; break;} case 66: #line 453 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_output, (NODE *)NULL); ; break;} case 67: #line 455 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_append, (NODE *)NULL); ; break;} case 68: #line 457 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_redirect_pipe, (NODE *)NULL); ; break;} case 69: #line 462 "awk.y" { yyval.nodeval = NULL; ; break;} case 70: #line 464 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 71: #line 469 "awk.y" { yyval.nodeval = make_param(yyvsp[0].sval); ; break;} case 72: #line 471 "awk.y" { yyval.nodeval = append_right(yyvsp[-2].nodeval, make_param(yyvsp[0].sval)); yyerrok; ; break;} case 73: #line 473 "awk.y" { yyval.nodeval = NULL; ; break;} case 74: #line 475 "awk.y" { yyval.nodeval = NULL; ; break;} case 75: #line 477 "awk.y" { yyval.nodeval = NULL; ; break;} case 76: #line 483 "awk.y" { yyval.nodeval = NULL; ; break;} case 77: #line 485 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 78: #line 490 "awk.y" { yyval.nodeval = NULL; ; break;} case 79: #line 492 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 80: #line 497 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ; break;} case 81: #line 499 "awk.y" { yyval.nodeval = append_right(yyvsp[-2].nodeval, node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL)); yyerrok; ; break;} case 82: #line 505 "awk.y" { yyval.nodeval = NULL; ; break;} case 83: #line 507 "awk.y" { yyval.nodeval = NULL; ; break;} case 84: #line 509 "awk.y" { yyval.nodeval = NULL; ; break;} case 85: #line 511 "awk.y" { yyval.nodeval = NULL; ; break;} case 86: #line 516 "awk.y" { yyval.nodeval = NULL; ; break;} case 87: #line 518 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 88: #line 523 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL); ; break;} case 89: #line 525 "awk.y" { yyval.nodeval = append_right(yyvsp[-2].nodeval, node( yyvsp[0].nodeval, Node_expression_list, (NODE *)NULL)); yyerrok; ; break;} case 90: #line 531 "awk.y" { yyval.nodeval = NULL; ; break;} case 91: #line 533 "awk.y" { yyval.nodeval = NULL; ; break;} case 92: #line 535 "awk.y" { yyval.nodeval = NULL; ; break;} case 93: #line 537 "awk.y" { yyval.nodeval = NULL; ; break;} case 94: #line 542 "awk.y" { want_assign = 0; ; break;} case 95: #line 544 "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 96: #line 550 "awk.y" { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-3].nodeval); ; break;} case 97: #line 552 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_K_getline, node (yyvsp[-3].nodeval, Node_redirect_pipein, (NODE *)NULL)); ; break;} case 98: #line 557 "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 99: #line 563 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ; break;} case 100: #line 565 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ; break;} case 101: #line 567 "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 102: #line 573 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 103: #line 575 "awk.y" { yyval.nodeval = node(node(make_number(0.0), Node_field_spec, (NODE *) NULL), Node_nomatch, yyvsp[0].nodeval); ; break;} case 104: #line 583 "awk.y" { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ; break;} case 105: #line 585 "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 106: #line 591 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_less, yyvsp[0].nodeval); ; break;} case 107: #line 593 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_greater, yyvsp[0].nodeval); ; break;} case 108: #line 595 "awk.y" { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));; break;} case 109: #line 597 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 110: #line 599 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ; break;} case 111: #line 604 "awk.y" { want_assign = 0; ; break;} case 112: #line 606 "awk.y" { yyval.nodeval = node (yyvsp[-3].nodeval, yyvsp[-2].nodetypeval, yyvsp[0].nodeval); ; break;} case 113: #line 608 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_and, yyvsp[0].nodeval); ; break;} case 114: #line 610 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_or, yyvsp[0].nodeval); ; break;} case 115: #line 612 "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 116: #line 618 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 117: #line 620 "awk.y" { yyval.nodeval = node((NODE *) NULL, Node_nomatch, yyvsp[0].nodeval); ; break;} case 118: #line 622 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, mk_rexp(yyvsp[0].nodeval)); ; break;} case 119: #line 624 "awk.y" { yyval.nodeval = node (variable(yyvsp[0].sval,1), Node_in_array, yyvsp[-2].nodeval); ; break;} case 120: #line 626 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, yyvsp[-1].nodetypeval, yyvsp[0].nodeval); ; break;} case 121: #line 628 "awk.y" { yyval.nodeval = node(yyvsp[-4].nodeval, Node_cond_exp, node(yyvsp[-2].nodeval, Node_if_branches, yyvsp[0].nodeval));; break;} case 122: #line 630 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 123: #line 632 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_concat, yyvsp[0].nodeval); ; break;} case 125: #line 639 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_exp, yyvsp[0].nodeval); ; break;} case 126: #line 641 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_times, yyvsp[0].nodeval); ; break;} case 127: #line 643 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_quotient, yyvsp[0].nodeval); ; break;} case 128: #line 645 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_mod, yyvsp[0].nodeval); ; break;} case 129: #line 647 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_plus, yyvsp[0].nodeval); ; break;} case 130: #line 649 "awk.y" { yyval.nodeval = node (yyvsp[-2].nodeval, Node_minus, yyvsp[0].nodeval); ; break;} case 131: #line 651 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postincrement, (NODE *)NULL); ; break;} case 132: #line 653 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_postdecrement, (NODE *)NULL); ; break;} case 133: #line 658 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_not,(NODE *) NULL); ; break;} case 134: #line 660 "awk.y" { yyval.nodeval = yyvsp[-1].nodeval; ; break;} case 135: #line 663 "awk.y" { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ; break;} case 136: #line 665 "awk.y" { yyval.nodeval = snode (yyvsp[-1].nodeval, Node_builtin, (int) yyvsp[-3].lval); ; break;} case 137: #line 667 "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 138: #line 675 "awk.y" { yyval.nodeval = node (yyvsp[-1].nodeval, Node_func_call, make_string(yyvsp[-3].sval, strlen(yyvsp[-3].sval))); ; break;} case 140: #line 680 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_preincrement, (NODE *)NULL); ; break;} case 141: #line 682 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_predecrement, (NODE *)NULL); ; break;} case 142: #line 684 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 143: #line 686 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 144: #line 689 "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 145: #line 696 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 146: #line 701 "awk.y" { yyval.nodeval = NULL; ; break;} case 147: #line 703 "awk.y" { yyval.nodeval = yyvsp[0].nodeval; ; break;} case 148: #line 708 "awk.y" { yyval.nodeval = variable(yyvsp[0].sval,1); ; break;} case 149: #line 710 "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 150: #line 718 "awk.y" { yyval.nodeval = node (yyvsp[0].nodeval, Node_field_spec, (NODE *)NULL); ; break;} case 152: #line 726 "awk.y" { yyerrok; ; break;} case 153: #line 730 "awk.y" { yyerrok; ; break;} case 156: #line 739 "awk.y" { yyerrok; want_assign = 0; ; break;} case 157: #line 742 "awk.y" { yyerrok; ; break;} } /* the action file gets copied in in place of this dollarsign */ #line 442 "/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; for (x = 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 = 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 745 "awk.y" struct token { 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; char *mesg = NULL; register char *bp, *cp; char *scan; char buf[120]; errcount++; /* Find the current line in the input file */ if (lexptr) { if (!thisline) { cp = lexeme; if (*cp == '\n') { cp--; mesg = "unexpected newline"; } for ( ; cp != lexptr_begin && *cp != '\n'; --cp) ; if (*cp == '\n') cp++; thisline = cp; } /* NL isn't guaranteed */ bp = lexeme; while (bp < lexend && *bp && *bp != '\n') bp++; } else { thisline = "(END OF FILE)"; bp = thisline + 13; } 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 */ if (nextfile > numfiles) return NULL; if (srcfiles[nextfile].stype == CMDLINE) { if (len == 0) { len = strlen(srcfiles[nextfile].val); 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++; len = 0; return get_src_buf(); } lexptr = buf + SLOP; lexend = lexptr + n; return buf; } #define tokadd(x) (*token++ = (x), token == tokend ? tokexpand() : token) char * tokexpand() { static int toksize = 60; int tokoffset; tokoffset = token - tokstart; toksize *= 2; if (tokstart) erealloc(tokstart, char *, toksize, "tokexpand"); else emalloc(tokstart, char *, toksize, "tokexpand"); tokend = tokstart + toksize; token = tokstart + tokoffset; return token; } #if DEBUG char nextc() { if (lexptr && lexptr < lexend) return *lexptr++; else if (get_src_buf()) return *lexptr++; else return '\0'; } #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; if (!nextc()) return 0; pushback(); lexeme = lexptr; thisline = NULL; if (want_regexp) { int in_brack = 0; want_regexp = 0; token = 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 REGEXP; case '\n': pushback(); yyerror("unterminated regexp"); case '\0': yyerror("unterminated regexp at end of file"); } tokadd(c); } } retry: while ((c = nextc()) == ' ' || c == '\t') ; lexeme = lexptr ? lexptr - 1 : lexptr; thisline = NULL; token = tokstart; yylval.nodetypeval = Node_illegal; switch (c) { case 0: return 0; case '\n': sourceline++; return NEWLINE; case '#': /* it's a comment */ while ((c = nextc()) != '\n') { if (c == '\0') return 0; } sourceline++; return NEWLINE; case '\\': #ifdef RELAXED_CONTINUATION if (!do_unix) { /* strip trailing white-space and/or comment */ while ((c = nextc()) == ' ' || c == '\t') continue; if (c == '#') while ((c = nextc()) != '\n') if (!c) break; pushback(); } #endif /*RELAXED_CONTINUATION*/ if (nextc() == '\n') { sourceline++; goto retry; } else yyerror("inappropriate use of backslash"); break; case '$': want_assign = 1; return '$'; case ')': case ']': case '(': case '[': case ';': case ':': case '?': case '{': case ',': return c; case '*': if ((c = nextc()) == '=') { yylval.nodetypeval = Node_assign_times; return ASSIGNOP; } else if (do_posix) { pushback(); return '*'; } 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 ASSIGNOP; } else { pushback(); if (do_lint && ! did_warn_op) { did_warn_op = 1; warning("** is not allowed by POSIX"); } return '^'; } } pushback(); return '*'; case '/': if (want_assign) { if (nextc() == '=') { yylval.nodetypeval = Node_assign_quotient; return ASSIGNOP; } pushback(); } return '/'; case '%': if (nextc() == '=') { yylval.nodetypeval = Node_assign_mod; return ASSIGNOP; } pushback(); return '%'; 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 ASSIGNOP; } pushback(); if (do_lint && ! did_warn_op) { did_warn_op = 1; warning("operator `^' is not supported in old awk"); } return '^'; } case '+': if ((c = nextc()) == '=') { yylval.nodetypeval = Node_assign_plus; return ASSIGNOP; } if (c == '+') return INCREMENT; pushback(); return '+'; case '!': if ((c = nextc()) == '=') { yylval.nodetypeval = Node_notequal; return RELOP; } if (c == '~') { yylval.nodetypeval = Node_nomatch; want_assign = 0; return MATCHOP; } pushback(); return '!'; case '<': if (nextc() == '=') { yylval.nodetypeval = Node_leq; return RELOP; } yylval.nodetypeval = Node_less; pushback(); return '<'; case '=': if (nextc() == '=') { yylval.nodetypeval = Node_equal; return RELOP; } yylval.nodetypeval = Node_assign; pushback(); return ASSIGNOP; case '>': if ((c = nextc()) == '=') { yylval.nodetypeval = Node_geq; return RELOP; } else if (c == '>') { yylval.nodetypeval = Node_redirect_append; return APPEND_OP; } yylval.nodetypeval = Node_greater; pushback(); return '>'; case '~': yylval.nodetypeval = Node_match; want_assign = 0; return MATCHOP; case '}': /* * Added did newline stuff. Easier than * hacking the grammar */ if (did_newline) { did_newline = 0; return c; } did_newline++; --lexptr; /* pick up } next time */ return 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, token - tokstart, esc_seen ? SCAN : 0); yylval.nodeval->flags |= PERM; return YSTRING; case '-': if ((c = nextc()) == '=') { yylval.nodetypeval = Node_assign_minus; return ASSIGNOP; } if (c == '-') return DECREMENT; pushback(); return '-'; case '.': c = nextc(); pushback(); if (!isdigit(c)) return '.'; 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(); } pushback(); yylval.nodeval = make_number(atof(tokstart)); yylval.nodeval->flags |= PERM; return YNUMBER; case '&': if ((c = nextc()) == '&') { yylval.nodetypeval = Node_and; for (;;) { c = nextc(); if (c == '\0') break; if (c == '#') { while ((c = nextc()) != '\n' && c != '\0') ; if (c == '\0') break; } if (c == '\n') sourceline++; if (! isspace(c)) { pushback(); break; } } want_assign = 0; return LEX_AND; } pushback(); return '&'; case '|': if ((c = nextc()) == '|') { yylval.nodetypeval = Node_or; for (;;) { c = nextc(); if (c == '\0') break; if (c == '#') { while ((c = nextc()) != '\n' && c != '\0') ; if (c == '\0') break; } if (c == '\n') sourceline++; if (! isspace(c)) { pushback(); break; } } want_assign = 0; return LEX_OR; } pushback(); return '|'; } if (c != '_' && ! isalpha(c)) yyerror("Invalid char '%c' in expression\n", c); /* it's some type of name-type-thing. Find its length */ token = tokstart; while (is_identchar(c)) { tokadd(c); c = nextc(); } tokadd('\0'); emalloc(tokkey, char *, token - tokstart, "yylex"); memcpy(tokkey, tokstart, token - tokstart); pushback(); /* 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; return tokentab[mid].class; } } yylval.sval = tokkey; if (*lexptr == '(') return FUNC_CALL; else { want_assign = 1; return 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 int len, bucket; len = strlen(name); bucket = hash(name, len); 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) char *name; { register NODE *bucket; register int len; len = strlen(name); bucket = variables[hash(name, len)]; 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; } /* * 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 int len; char *name; name = np->param; len = strlen(name); save = &(variables[hash(name, len)]); 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); } } static void pop_params(params) NODE *params; { register NODE *np; for (np = params; np != NULL; np = np->rnode) pop_var(np, 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 its 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; } }