diff options
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 2774 |
1 files changed, 1056 insertions, 1718 deletions
@@ -86,19 +86,15 @@ static char *get_src_buf(void); static int yylex(void); int yyparse(void); static INSTRUCTION *snode(INSTRUCTION *subn, INSTRUCTION *op); -static int func_install(INSTRUCTION *fp, INSTRUCTION *def); -static void pop_params(NODE *params); -static NODE *make_param(char *pname); +static char **check_params(char *fname, int pcount, INSTRUCTION *list); +static int install_function(char *fname, INSTRUCTION *fi, INSTRUCTION *plist); static NODE *mk_rexp(INSTRUCTION *exp); -static void append_param(char *pname); -static int dup_parms(INSTRUCTION *fp, NODE *func); static void param_sanity(INSTRUCTION *arglist); static int parms_shadow(INSTRUCTION *pc, int *shadow); static int isnoeffect(OPCODE type); static INSTRUCTION *make_assignable(INSTRUCTION *ip); static void dumpintlstr(const char *str, size_t len); static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2); -static int isarray(NODE *n); static int include_source(INSTRUCTION *file); static void next_sourcefile(void); static char *tokexpand(void); @@ -107,6 +103,7 @@ static char *tokexpand(void); static INSTRUCTION *mk_program(void); static INSTRUCTION *append_rule(INSTRUCTION *pattern, INSTRUCTION *action); +static INSTRUCTION *mk_function(INSTRUCTION *fi, INSTRUCTION *def); static INSTRUCTION *mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, INSTRUCTION *elsep, INSTRUCTION *false_branch); static INSTRUCTION *mk_expression_list(INSTRUCTION *list, INSTRUCTION *s1); @@ -125,16 +122,13 @@ static void add_lint(INSTRUCTION *list, LINTTYPE linttype); enum defref { FUNC_DEFINE, FUNC_USE }; static void func_use(const char *name, enum defref how); static void check_funcs(void); -static void free_bcpool(INSTRUCTION *pl); static ssize_t read_one_line(int fd, void *buffer, size_t count); static int one_line_close(int fd); -static void (*install_func)(char *) = NULL; - static int want_source = FALSE; static int want_regexp; /* lexical scanning kludge */ -static int can_return; /* parsing kludge */ +static char *in_function; /* parsing kludge */ static int rule = 0; const char *const ruletab[] = { @@ -169,27 +163,17 @@ static int continue_allowed; /* kludge for continue */ #define END_SRC -2000 #define YYDEBUG_LEXER_TEXT (lexeme) -static int param_counter; -static NODE *func_params; /* list of parameters for the current function */ static char *tokstart = NULL; static char *tok = NULL; static char *tokend; static int errcount = 0; -static NODE *symbol_list; -extern void destroy_symbol(char *name); - -static long func_count; /* total number of functions */ - -#define HASHSIZE 1021 /* this constant only used here */ -NODE *variables[HASHSIZE]; -static int var_count; /* total number of global variables */ - extern char *source; extern int sourceline; extern SRCFILE *srcfiles; extern INSTRUCTION *rule_list; extern int max_args; +extern NODE **args_array; static INSTRUCTION *rule_block[sizeof(ruletab)]; @@ -206,22 +190,12 @@ static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x); static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); extern double fmod(double x, double y); -/* - * This string cannot occur as a real awk identifier. - * Use it as a special token to make function parsing - * uniform, but if it's seen, don't install the function. - * e.g. - * function split(x) { return x } - * function x(a) { return a } - * should only produce one error message, and not core dump. - */ -static char builtin_func[] = "@builtin"; #define YYSTYPE INSTRUCTION * /* Line 268 of yacc.c */ -#line 225 "awkgram.c" +#line 199 "awkgram.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -367,7 +341,7 @@ typedef int YYSTYPE; /* Line 343 of yacc.c */ -#line 371 "awkgram.c" +#line 345 "awkgram.c" #ifdef short # undef short @@ -583,16 +557,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1157 +#define YYLAST 1150 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 74 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 65 +#define YYNNTS 64 /* YYNRULES -- Number of rules. */ -#define YYNRULES 185 +#define YYNRULES 184 /* YYNRULES -- Number of states. */ -#define YYNSTATES 330 +#define YYNSTATES 329 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -644,110 +618,110 @@ static const yytype_uint16 yyprhs[] = { 0, 0, 3, 4, 7, 10, 13, 16, 19, 22, 25, 30, 32, 35, 37, 38, 40, 45, 47, 49, - 51, 53, 59, 61, 63, 65, 68, 70, 72, 73, - 81, 82, 86, 88, 90, 91, 94, 97, 99, 102, - 105, 109, 111, 121, 128, 137, 146, 159, 171, 173, - 176, 179, 182, 185, 189, 190, 195, 198, 199, 204, - 205, 210, 215, 217, 218, 220, 221, 224, 227, 233, - 238, 240, 243, 246, 248, 250, 252, 254, 256, 260, - 261, 262, 266, 273, 283, 285, 288, 289, 291, 292, - 295, 296, 298, 300, 304, 306, 309, 313, 314, 316, - 317, 319, 321, 325, 327, 330, 334, 338, 342, 346, - 350, 354, 358, 362, 368, 370, 372, 374, 377, 379, - 381, 383, 385, 387, 389, 392, 394, 398, 402, 406, - 410, 414, 418, 422, 425, 428, 434, 439, 443, 447, - 451, 455, 459, 463, 465, 468, 472, 477, 482, 484, - 486, 488, 491, 494, 496, 498, 501, 504, 506, 509, - 514, 515, 517, 518, 521, 523, 526, 528, 532, 534, - 537, 540, 542, 545, 547, 551, 553, 555, 556, 559, - 562, 564, 565, 567, 569, 571 + 51, 53, 59, 61, 63, 65, 68, 70, 72, 79, + 80, 84, 86, 88, 89, 92, 95, 97, 100, 103, + 107, 109, 119, 126, 135, 144, 157, 169, 171, 174, + 177, 180, 183, 187, 188, 193, 196, 197, 202, 203, + 208, 213, 215, 216, 218, 219, 222, 225, 231, 236, + 238, 241, 244, 246, 248, 250, 252, 254, 258, 259, + 260, 264, 271, 281, 283, 286, 287, 289, 290, 293, + 294, 296, 298, 302, 304, 307, 311, 312, 314, 315, + 317, 319, 323, 325, 328, 332, 336, 340, 344, 348, + 352, 356, 360, 366, 368, 370, 372, 375, 377, 379, + 381, 383, 385, 387, 390, 392, 396, 400, 404, 408, + 412, 416, 420, 423, 426, 432, 437, 441, 445, 449, + 453, 457, 461, 463, 466, 470, 475, 480, 482, 484, + 486, 489, 492, 494, 496, 499, 502, 504, 507, 512, + 513, 515, 516, 519, 521, 524, 526, 530, 532, 535, + 538, 540, 543, 545, 549, 551, 553, 554, 557, 560, + 562, 563, 565, 567, 569 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 75, 0, -1, -1, 75, 76, -1, 75, 104, -1, + 75, 0, -1, -1, 75, 76, -1, 75, 103, -1, 75, 47, -1, 75, 1, -1, 78, 79, -1, 78, - 88, -1, 82, 79, -1, 68, 48, 77, 88, -1, - 6, -1, 6, 1, -1, 1, -1, -1, 112, -1, - 112, 54, 105, 112, -1, 17, -1, 18, -1, 36, - -1, 37, -1, 132, 87, 133, 135, 105, -1, 4, + 87, -1, 82, 79, -1, 68, 48, 77, 87, -1, + 6, -1, 6, 1, -1, 1, -1, -1, 111, -1, + 111, 54, 104, 111, -1, 17, -1, 18, -1, 36, + -1, 37, -1, 131, 86, 132, 134, 104, -1, 4, -1, 3, -1, 81, -1, 68, 49, -1, 45, -1, - 46, -1, -1, 35, 83, 80, 66, 107, 134, 105, - -1, -1, 86, 85, 5, -1, 60, -1, 51, -1, - -1, 87, 89, -1, 87, 1, -1, 104, -1, 136, - 105, -1, 136, 105, -1, 132, 87, 133, -1, 103, - -1, 23, 66, 112, 134, 105, 132, 96, 105, 133, - -1, 26, 66, 112, 134, 105, 89, -1, 27, 105, - 89, 26, 66, 112, 134, 105, -1, 28, 66, 4, - 40, 129, 134, 105, 89, -1, 28, 66, 95, 136, - 105, 112, 136, 105, 95, 134, 105, 89, -1, 28, - 66, 95, 136, 105, 136, 105, 95, 134, 105, 89, - -1, 90, -1, 29, 88, -1, 30, 88, -1, 33, - 88, -1, 39, 88, -1, 34, 109, 88, -1, -1, - 21, 91, 109, 88, -1, 92, 88, -1, -1, 99, - 93, 100, 101, -1, -1, 22, 4, 94, 123, -1, - 22, 66, 4, 67, -1, 112, -1, -1, 92, -1, - -1, 96, 97, -1, 96, 1, -1, 24, 98, 137, - 105, 87, -1, 25, 137, 105, 87, -1, 7, -1, - 58, 7, -1, 57, 7, -1, 8, -1, 84, -1, - 31, -1, 32, -1, 110, -1, 66, 111, 134, -1, - -1, -1, 10, 102, 116, -1, 19, 66, 112, 134, - 105, 89, -1, 19, 66, 112, 134, 105, 89, 20, - 105, 89, -1, 50, -1, 104, 50, -1, -1, 104, - -1, -1, 55, 117, -1, -1, 108, -1, 4, -1, - 108, 138, 4, -1, 1, -1, 108, 1, -1, 108, - 138, 1, -1, -1, 112, -1, -1, 111, -1, 112, - -1, 111, 138, 112, -1, 1, -1, 111, 1, -1, - 111, 1, 112, -1, 111, 138, 1, -1, 130, 113, - 112, -1, 112, 41, 112, -1, 112, 42, 112, -1, - 112, 14, 112, -1, 112, 40, 129, -1, 112, 115, - 112, -1, 112, 52, 112, 53, 112, -1, 116, -1, - 13, -1, 12, -1, 51, 13, -1, 9, -1, 55, - -1, 114, -1, 56, -1, 117, -1, 118, -1, 116, - 117, -1, 119, -1, 117, 64, 117, -1, 117, 59, - 117, -1, 117, 60, 117, -1, 117, 61, 117, -1, - 117, 57, 117, -1, 117, 58, 117, -1, 38, 122, - 106, -1, 130, 43, -1, 130, 44, -1, 66, 111, - 134, 40, 129, -1, 116, 11, 38, 122, -1, 118, - 64, 117, -1, 118, 59, 117, -1, 118, 60, 117, - -1, 118, 61, 117, -1, 118, 57, 117, -1, 118, - 58, 117, -1, 84, -1, 62, 117, -1, 66, 112, - 134, -1, 45, 66, 110, 134, -1, 46, 66, 110, - 134, -1, 46, -1, 120, -1, 130, -1, 43, 130, - -1, 44, 130, -1, 7, -1, 8, -1, 58, 117, - -1, 57, 117, -1, 121, -1, 68, 121, -1, 3, - 66, 110, 134, -1, -1, 130, -1, -1, 124, 16, - -1, 125, -1, 124, 125, -1, 126, -1, 69, 111, - 70, -1, 126, -1, 127, 126, -1, 127, 16, -1, - 4, -1, 4, 128, -1, 129, -1, 65, 119, 131, - -1, 43, -1, 44, -1, -1, 71, 105, -1, 72, - 105, -1, 67, -1, -1, 136, -1, 73, -1, 53, - -1, 54, 105, -1 + 46, -1, 35, 80, 66, 106, 133, 104, -1, -1, + 85, 84, 5, -1, 60, -1, 51, -1, -1, 86, + 88, -1, 86, 1, -1, 103, -1, 135, 104, -1, + 135, 104, -1, 131, 86, 132, -1, 102, -1, 23, + 66, 111, 133, 104, 131, 95, 104, 132, -1, 26, + 66, 111, 133, 104, 88, -1, 27, 104, 88, 26, + 66, 111, 133, 104, -1, 28, 66, 4, 40, 128, + 133, 104, 88, -1, 28, 66, 94, 135, 104, 111, + 135, 104, 94, 133, 104, 88, -1, 28, 66, 94, + 135, 104, 135, 104, 94, 133, 104, 88, -1, 89, + -1, 29, 87, -1, 30, 87, -1, 33, 87, -1, + 39, 87, -1, 34, 108, 87, -1, -1, 21, 90, + 108, 87, -1, 91, 87, -1, -1, 98, 92, 99, + 100, -1, -1, 22, 4, 93, 122, -1, 22, 66, + 4, 67, -1, 111, -1, -1, 91, -1, -1, 95, + 96, -1, 95, 1, -1, 24, 97, 136, 104, 86, + -1, 25, 136, 104, 86, -1, 7, -1, 58, 7, + -1, 57, 7, -1, 8, -1, 83, -1, 31, -1, + 32, -1, 109, -1, 66, 110, 133, -1, -1, -1, + 10, 101, 115, -1, 19, 66, 111, 133, 104, 88, + -1, 19, 66, 111, 133, 104, 88, 20, 104, 88, + -1, 50, -1, 103, 50, -1, -1, 103, -1, -1, + 55, 116, -1, -1, 107, -1, 4, -1, 107, 137, + 4, -1, 1, -1, 107, 1, -1, 107, 137, 1, + -1, -1, 111, -1, -1, 110, -1, 111, -1, 110, + 137, 111, -1, 1, -1, 110, 1, -1, 110, 1, + 111, -1, 110, 137, 1, -1, 129, 112, 111, -1, + 111, 41, 111, -1, 111, 42, 111, -1, 111, 14, + 111, -1, 111, 40, 128, -1, 111, 114, 111, -1, + 111, 52, 111, 53, 111, -1, 115, -1, 13, -1, + 12, -1, 51, 13, -1, 9, -1, 55, -1, 113, + -1, 56, -1, 116, -1, 117, -1, 115, 116, -1, + 118, -1, 116, 64, 116, -1, 116, 59, 116, -1, + 116, 60, 116, -1, 116, 61, 116, -1, 116, 57, + 116, -1, 116, 58, 116, -1, 38, 121, 105, -1, + 129, 43, -1, 129, 44, -1, 66, 110, 133, 40, + 128, -1, 115, 11, 38, 121, -1, 117, 64, 116, + -1, 117, 59, 116, -1, 117, 60, 116, -1, 117, + 61, 116, -1, 117, 57, 116, -1, 117, 58, 116, + -1, 83, -1, 62, 116, -1, 66, 111, 133, -1, + 45, 66, 109, 133, -1, 46, 66, 109, 133, -1, + 46, -1, 119, -1, 129, -1, 43, 129, -1, 44, + 129, -1, 7, -1, 8, -1, 58, 116, -1, 57, + 116, -1, 120, -1, 68, 120, -1, 3, 66, 109, + 133, -1, -1, 129, -1, -1, 123, 16, -1, 124, + -1, 123, 124, -1, 125, -1, 69, 110, 70, -1, + 125, -1, 126, 125, -1, 126, 16, -1, 4, -1, + 4, 127, -1, 128, -1, 65, 118, 130, -1, 43, + -1, 44, -1, -1, 71, 104, -1, 72, 104, -1, + 67, -1, -1, 135, -1, 73, -1, 53, -1, 54, + 104, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 218, 218, 220, 225, 226, 230, 242, 246, 257, - 265, 273, 281, 283, 289, 290, 292, 318, 329, 340, - 346, 355, 365, 367, 369, 380, 385, 386, 391, 390, - 420, 419, 452, 454, 459, 460, 473, 478, 479, 483, - 485, 487, 494, 584, 626, 668, 781, 788, 795, 805, - 814, 823, 832, 847, 863, 862, 874, 886, 886, 982, - 982, 1007, 1030, 1036, 1037, 1043, 1044, 1051, 1056, 1068, - 1082, 1084, 1090, 1095, 1097, 1105, 1107, 1116, 1117, 1125, - 1130, 1130, 1141, 1145, 1153, 1154, 1157, 1159, 1164, 1165, - 1172, 1174, 1178, 1184, 1191, 1193, 1195, 1202, 1203, 1209, - 1210, 1215, 1217, 1222, 1224, 1226, 1228, 1234, 1241, 1243, - 1245, 1261, 1271, 1278, 1280, 1285, 1287, 1289, 1297, 1299, - 1304, 1306, 1311, 1313, 1315, 1368, 1370, 1372, 1374, 1376, - 1378, 1380, 1382, 1405, 1410, 1415, 1440, 1446, 1448, 1450, - 1452, 1454, 1456, 1461, 1465, 1496, 1498, 1504, 1510, 1523, - 1524, 1525, 1530, 1535, 1539, 1543, 1555, 1568, 1573, 1609, - 1627, 1628, 1634, 1635, 1640, 1642, 1649, 1666, 1683, 1685, - 1692, 1697, 1705, 1719, 1731, 1740, 1744, 1748, 1752, 1756, - 1760, 1763, 1765, 1769, 1773, 1777 + 0, 192, 192, 194, 199, 200, 204, 216, 220, 231, + 237, 245, 253, 255, 261, 262, 264, 290, 301, 312, + 318, 327, 337, 339, 341, 347, 352, 353, 357, 376, + 375, 409, 411, 416, 417, 430, 435, 436, 440, 442, + 444, 451, 541, 583, 625, 738, 745, 752, 762, 771, + 780, 789, 804, 820, 819, 843, 855, 855, 949, 949, + 974, 997, 1003, 1004, 1010, 1011, 1018, 1023, 1035, 1049, + 1051, 1057, 1062, 1064, 1072, 1074, 1083, 1084, 1092, 1097, + 1097, 1108, 1112, 1120, 1121, 1124, 1126, 1131, 1132, 1141, + 1142, 1147, 1152, 1158, 1160, 1162, 1169, 1170, 1176, 1177, + 1182, 1184, 1189, 1191, 1193, 1195, 1201, 1208, 1210, 1212, + 1228, 1238, 1245, 1247, 1252, 1254, 1256, 1264, 1266, 1271, + 1273, 1278, 1280, 1282, 1332, 1334, 1336, 1338, 1340, 1342, + 1344, 1346, 1369, 1374, 1379, 1404, 1410, 1412, 1414, 1416, + 1418, 1420, 1425, 1429, 1460, 1462, 1468, 1474, 1487, 1488, + 1489, 1494, 1499, 1503, 1507, 1520, 1533, 1538, 1574, 1592, + 1593, 1599, 1600, 1605, 1607, 1614, 1631, 1648, 1650, 1657, + 1662, 1670, 1680, 1692, 1701, 1705, 1709, 1713, 1717, 1721, + 1724, 1726, 1730, 1734, 1738 }; #endif @@ -769,10 +743,10 @@ static const char *const yytname[] = "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", "'('", "')'", "'@'", "'['", "']'", "'{'", "'}'", "';'", "$accept", "program", "rule", "source", "pattern", "action", "func_name", "lex_builtin", - "function_prologue", "$@1", "regexp", "$@2", "a_slash", "statements", - "statement_term", "statement", "non_compound_stmt", "$@3", "simple_stmt", - "$@4", "$@5", "opt_simple_stmt", "case_statements", "case_statement", - "case_value", "print", "print_expression_list", "output_redir", "$@6", + "function_prologue", "regexp", "$@1", "a_slash", "statements", + "statement_term", "statement", "non_compound_stmt", "$@2", "simple_stmt", + "$@3", "$@4", "opt_simple_stmt", "case_statements", "case_statement", + "case_value", "print", "print_expression_list", "output_redir", "$@5", "if_statement", "nls", "opt_nls", "input_redir", "opt_param_list", "param_list", "opt_exp", "opt_expression_list", "expression_list", "exp", "assign_operator", "relop_or_less", "a_relop", "common_exp", "simp_exp", @@ -805,23 +779,23 @@ static const yytype_uint8 yyr1[] = { 0, 74, 75, 75, 75, 75, 75, 76, 76, 76, 76, 77, 77, 77, 78, 78, 78, 78, 78, 78, - 78, 79, 80, 80, 80, 80, 81, 81, 83, 82, - 85, 84, 86, 86, 87, 87, 87, 88, 88, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 90, - 90, 90, 90, 90, 91, 90, 90, 93, 92, 94, - 92, 92, 92, 95, 95, 96, 96, 96, 97, 97, - 98, 98, 98, 98, 98, 99, 99, 100, 100, 101, - 102, 101, 103, 103, 104, 104, 105, 105, 106, 106, - 107, 107, 108, 108, 108, 108, 108, 109, 109, 110, - 110, 111, 111, 111, 111, 111, 111, 112, 112, 112, - 112, 112, 112, 112, 112, 113, 113, 113, 114, 114, - 115, 115, 116, 116, 116, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, - 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 120, 120, 121, - 122, 122, 123, 123, 124, 124, 125, 126, 127, 127, - 128, 129, 129, 130, 130, 131, 131, 131, 132, 133, - 134, 135, 135, 136, 137, 138 + 78, 79, 80, 80, 80, 80, 81, 81, 82, 84, + 83, 85, 85, 86, 86, 86, 87, 87, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 89, 89, + 89, 89, 89, 90, 89, 89, 92, 91, 93, 91, + 91, 91, 94, 94, 95, 95, 95, 96, 96, 97, + 97, 97, 97, 97, 98, 98, 99, 99, 100, 101, + 100, 102, 102, 103, 103, 104, 104, 105, 105, 106, + 106, 107, 107, 107, 107, 107, 108, 108, 109, 109, + 110, 110, 110, 110, 110, 110, 111, 111, 111, 111, + 111, 111, 111, 111, 112, 112, 112, 113, 113, 114, + 114, 115, 115, 115, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 117, 117, 117, 117, 117, + 117, 117, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 118, 119, 119, 120, 121, + 121, 122, 122, 123, 123, 124, 125, 126, 126, 127, + 128, 128, 129, 129, 130, 130, 130, 131, 132, 133, + 134, 134, 135, 136, 137 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -829,23 +803,23 @@ static const yytype_uint8 yyr2[] = { 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 4, 1, 2, 1, 0, 1, 4, 1, 1, 1, - 1, 5, 1, 1, 1, 2, 1, 1, 0, 7, - 0, 3, 1, 1, 0, 2, 2, 1, 2, 2, - 3, 1, 9, 6, 8, 8, 12, 11, 1, 2, - 2, 2, 2, 3, 0, 4, 2, 0, 4, 0, - 4, 4, 1, 0, 1, 0, 2, 2, 5, 4, - 1, 2, 2, 1, 1, 1, 1, 1, 3, 0, - 0, 3, 6, 9, 1, 2, 0, 1, 0, 2, - 0, 1, 1, 3, 1, 2, 3, 0, 1, 0, - 1, 1, 3, 1, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 5, 1, 1, 1, 2, 1, 1, - 1, 1, 1, 1, 2, 1, 3, 3, 3, 3, - 3, 3, 3, 2, 2, 5, 4, 3, 3, 3, - 3, 3, 3, 1, 2, 3, 4, 4, 1, 1, - 1, 2, 2, 1, 1, 2, 2, 1, 2, 4, - 0, 1, 0, 2, 1, 2, 1, 3, 1, 2, - 2, 1, 2, 1, 3, 1, 1, 0, 2, 2, - 1, 0, 1, 1, 1, 2 + 1, 5, 1, 1, 1, 2, 1, 1, 6, 0, + 3, 1, 1, 0, 2, 2, 1, 2, 2, 3, + 1, 9, 6, 8, 8, 12, 11, 1, 2, 2, + 2, 2, 3, 0, 4, 2, 0, 4, 0, 4, + 4, 1, 0, 1, 0, 2, 2, 5, 4, 1, + 2, 2, 1, 1, 1, 1, 1, 3, 0, 0, + 3, 6, 9, 1, 2, 0, 1, 0, 2, 0, + 1, 1, 3, 1, 2, 3, 0, 1, 0, 1, + 1, 3, 1, 2, 3, 3, 3, 3, 3, 3, + 3, 3, 5, 1, 1, 1, 2, 1, 1, 1, + 1, 1, 1, 2, 1, 3, 3, 3, 3, 3, + 3, 3, 2, 2, 5, 4, 3, 3, 3, 3, + 3, 3, 1, 2, 3, 4, 4, 1, 1, 1, + 2, 2, 1, 1, 2, 2, 1, 2, 4, 0, + 1, 0, 2, 1, 2, 1, 3, 1, 2, 2, + 1, 2, 1, 3, 1, 1, 0, 2, 2, 1, + 0, 1, 1, 1, 2 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -853,353 +827,353 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 0, 1, 6, 0, 171, 153, 154, 17, 18, - 28, 19, 20, 160, 0, 0, 0, 148, 5, 84, - 33, 0, 0, 32, 0, 0, 0, 0, 3, 0, - 0, 143, 30, 4, 15, 114, 122, 123, 125, 149, - 157, 173, 150, 0, 0, 168, 0, 172, 0, 88, - 161, 151, 152, 0, 0, 0, 156, 150, 155, 144, - 0, 177, 150, 103, 0, 101, 0, 158, 86, 183, - 7, 8, 37, 34, 86, 9, 0, 85, 118, 0, - 0, 0, 0, 0, 86, 119, 121, 120, 0, 0, - 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 116, 115, 133, 134, 0, 0, 0, - 0, 101, 0, 170, 169, 23, 22, 26, 27, 0, - 0, 24, 0, 132, 0, 0, 0, 175, 176, 174, - 104, 86, 180, 0, 0, 145, 13, 0, 0, 87, - 178, 0, 38, 31, 110, 111, 108, 109, 0, 0, - 112, 160, 130, 131, 127, 128, 129, 126, 141, 142, - 138, 139, 140, 137, 117, 107, 159, 167, 25, 0, - 89, 146, 147, 105, 185, 0, 106, 102, 12, 10, - 36, 0, 54, 0, 0, 0, 86, 0, 0, 0, - 75, 76, 0, 97, 0, 86, 35, 48, 0, 57, - 41, 62, 34, 181, 86, 0, 16, 136, 94, 92, - 0, 0, 135, 0, 97, 59, 0, 0, 0, 0, - 63, 49, 50, 51, 0, 98, 52, 179, 56, 0, - 0, 86, 182, 39, 113, 86, 95, 0, 0, 0, - 162, 0, 0, 0, 0, 171, 64, 0, 53, 0, - 79, 77, 40, 21, 29, 96, 93, 86, 55, 60, - 0, 164, 166, 61, 86, 86, 0, 0, 86, 0, - 80, 58, 0, 163, 165, 0, 0, 0, 0, 0, - 78, 0, 82, 65, 43, 0, 86, 0, 86, 81, - 86, 0, 86, 0, 86, 63, 0, 67, 0, 0, - 66, 0, 44, 45, 63, 0, 83, 70, 73, 0, - 0, 74, 0, 184, 86, 42, 0, 86, 72, 71, - 86, 34, 86, 0, 34, 0, 0, 47, 0, 46 + 2, 0, 1, 6, 0, 170, 152, 153, 17, 18, + 0, 19, 20, 159, 0, 0, 0, 147, 5, 83, + 32, 0, 0, 31, 0, 0, 0, 0, 3, 0, + 0, 142, 29, 4, 15, 113, 121, 122, 124, 148, + 156, 172, 149, 0, 0, 167, 0, 171, 23, 22, + 26, 27, 0, 0, 24, 87, 160, 150, 151, 0, + 0, 0, 155, 149, 154, 143, 0, 176, 149, 102, + 0, 100, 0, 157, 85, 182, 7, 8, 36, 33, + 85, 9, 0, 84, 117, 0, 0, 0, 0, 0, + 85, 118, 120, 119, 0, 0, 123, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 114, 132, 133, 0, 0, 0, 0, 100, 0, 169, + 168, 25, 0, 0, 131, 0, 0, 0, 174, 175, + 173, 103, 85, 179, 0, 0, 144, 13, 0, 0, + 86, 177, 0, 37, 30, 109, 110, 107, 108, 0, + 0, 111, 159, 129, 130, 126, 127, 128, 125, 140, + 141, 137, 138, 139, 136, 116, 106, 158, 166, 93, + 91, 0, 0, 88, 145, 146, 104, 184, 0, 105, + 101, 12, 10, 35, 0, 53, 0, 0, 0, 85, + 0, 0, 0, 74, 75, 0, 96, 0, 85, 34, + 47, 0, 56, 40, 61, 33, 180, 85, 0, 16, + 135, 85, 94, 0, 134, 0, 96, 58, 0, 0, + 0, 0, 62, 48, 49, 50, 0, 97, 51, 178, + 55, 0, 0, 85, 181, 38, 112, 28, 95, 92, + 0, 0, 161, 0, 0, 0, 0, 170, 63, 0, + 52, 0, 78, 76, 39, 21, 85, 54, 59, 0, + 163, 165, 60, 85, 85, 0, 0, 85, 0, 79, + 57, 0, 162, 164, 0, 0, 0, 0, 0, 77, + 0, 81, 64, 42, 0, 85, 0, 85, 80, 85, + 0, 85, 0, 85, 62, 0, 66, 0, 0, 65, + 0, 43, 44, 62, 0, 82, 69, 72, 0, 0, + 73, 0, 183, 85, 41, 0, 85, 71, 70, 85, + 33, 85, 0, 33, 0, 0, 46, 0, 45 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 28, 138, 29, 70, 120, 121, 30, 48, - 31, 76, 32, 141, 71, 196, 197, 214, 198, 229, - 240, 247, 291, 300, 312, 199, 250, 271, 281, 200, - 139, 140, 123, 210, 211, 224, 109, 110, 201, 108, - 87, 88, 35, 36, 37, 38, 39, 40, 49, 259, - 260, 261, 45, 46, 47, 41, 42, 129, 202, 203, - 135, 231, 204, 314, 134 + -1, 1, 28, 139, 29, 76, 53, 54, 30, 31, + 82, 32, 142, 77, 199, 200, 216, 201, 231, 242, + 249, 290, 299, 311, 202, 252, 270, 280, 203, 140, + 141, 124, 171, 172, 226, 115, 116, 204, 114, 93, + 94, 35, 36, 37, 38, 39, 40, 55, 258, 259, + 260, 45, 46, 47, 41, 42, 130, 205, 206, 136, + 233, 207, 313, 135 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -269 +#define YYPACT_NINF -264 static const yytype_int16 yypact[] = { - -269, 335, -269, -269, -31, -24, -269, -269, -269, -269, - -269, -269, -269, 12, 12, 12, -19, -12, -269, -269, - -269, 978, 978, -269, 978, 1023, 804, 21, -269, 115, - -21, -269, -269, 8, 1062, 952, -20, 330, -269, -269, - -269, -269, 246, 736, 804, -269, 2, -269, 205, 15, - -269, -269, -269, 736, 736, 70, 52, 80, 52, 52, - 978, 147, -269, -269, 50, 308, 174, -269, 64, -269, - -269, -269, 8, -269, 64, -269, 129, -269, -269, 978, - 143, 978, 978, 978, 64, -269, -269, -269, 978, 112, - -20, 978, 978, 978, 978, 978, 978, 978, 978, 978, - 978, 978, 978, -269, -269, -269, -269, 141, 978, 90, - 152, 1101, 48, -269, -269, -269, -269, -269, -269, 111, - 105, -269, 978, -269, 90, 90, 308, -269, -269, -269, - 978, 64, -269, 134, 830, -269, -269, 13, -16, 8, - -269, 552, -269, -269, 53, -269, 142, 300, 1081, 978, - 103, 12, 185, 185, 52, 52, 52, 52, 185, 185, - 52, 52, 52, 52, -269, 1101, -269, -269, -269, 63, - -20, -269, -269, 1101, -269, 143, -269, 1101, -269, -269, - -269, 121, -269, 6, 130, 137, 64, 139, -16, -16, - -269, -269, -16, 978, -16, 64, -269, -269, -16, -269, - -269, 1101, -269, 127, 64, 978, 1101, -269, -269, -269, - 90, 118, -269, 978, 978, -269, 180, 978, 978, 665, - 875, -269, -269, -269, -16, 1101, -269, -269, -269, 598, - 552, 64, -269, -269, 1101, 64, -269, 28, 308, -16, - -24, 140, 308, 308, 189, -14, -269, 127, -269, 804, - 201, -269, -269, -269, -269, -269, -269, 64, -269, -269, - 14, -269, -269, -269, 64, 64, 158, 143, 64, 50, - -269, -269, 665, -269, -269, -21, 665, 978, 90, 710, - 134, 978, 198, -269, -269, 308, 64, 1056, 64, 952, - 64, 60, 64, 665, 64, 907, 665, -269, 119, 177, - -269, 155, -269, -269, 907, 90, -269, -269, -269, 224, - 228, -269, 177, -269, 64, -269, 90, 64, -269, -269, - 64, -269, 64, 665, -269, 406, 665, -269, 479, -269 + -264, 367, -264, -264, -31, -42, -264, -264, -264, -264, + 165, -264, -264, 46, 46, 46, -29, -27, -264, -264, + -264, 1010, 1010, -264, 1010, 1055, 836, 27, -264, -35, + -7, -264, -264, 17, 1088, 984, 288, 362, -264, -264, + -264, -264, 146, 768, 836, -264, 1, -264, -264, -264, + -264, -264, 60, -18, -264, 11, -264, -264, -264, 768, + 768, 74, 52, 9, 52, 52, 1010, 13, -264, -264, + 53, 341, 28, -264, 79, -264, -264, -264, 17, -264, + 79, -264, 119, -264, -264, 1010, 148, 1010, 1010, 1010, + 79, -264, -264, -264, 1010, 122, 288, 1010, 1010, 1010, + 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, -264, + -264, -264, -264, 151, 1010, 94, 81, 1094, 40, -264, + -264, -264, 45, 1010, -264, 94, 94, 341, -264, -264, + -264, 1010, 79, -264, 125, 862, -264, -264, 82, -22, + 17, -264, 584, -264, -264, 62, -264, 212, 267, 301, + 1010, 118, 46, 127, 127, 52, 52, 52, 52, 127, + 127, 52, 52, 52, 52, -264, 1094, -264, -264, -264, + -264, 94, 61, 288, -264, -264, 1094, -264, 148, -264, + 1094, -264, -264, -264, 105, -264, 10, 109, 112, 79, + 113, -22, -22, -264, -264, -22, 1010, -22, 79, -264, + -264, -22, -264, -264, 1094, -264, 107, 79, 1010, 1094, + -264, 79, -264, 43, -264, 1010, 1010, -264, 180, 1010, + 1010, 697, 907, -264, -264, -264, -22, 1094, -264, -264, + -264, 630, 584, 79, -264, -264, 1094, -264, -264, -264, + 341, -22, -42, 126, 341, 341, 166, -14, -264, 107, + -264, 836, 190, -264, -264, -264, 79, -264, -264, 16, + -264, -264, -264, 79, 79, 136, 148, 79, 53, -264, + -264, 697, -264, -264, -7, 697, 1010, 94, 742, 125, + 1010, 186, -264, -264, 341, 79, 278, 79, 984, 79, + 132, 79, 697, 79, 939, 697, -264, 240, 155, -264, + 137, -264, -264, 939, 94, -264, -264, -264, 205, 206, + -264, 155, -264, 79, -264, 94, 79, -264, -264, 79, + -264, 79, 697, -264, 438, 697, -264, 511, -264 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -269, -269, -269, -269, -269, 208, -269, -269, -269, -269, - -58, -269, -269, -193, 72, -171, -269, -269, -189, -269, - -269, -268, -269, -269, -269, -269, -269, -269, -269, -269, - 45, 37, -269, -269, -269, 38, -48, -23, -1, -269, - -269, -269, -26, 44, -269, 217, -269, 1, 102, -269, - -269, -3, -39, -269, -269, -72, -2, -269, -28, -213, - -49, -269, -25, -47, 66 + -264, -264, -264, -264, -264, 187, -264, -264, -264, -74, + -264, -264, -197, 98, -203, -264, -264, -213, -264, -264, + -263, -264, -264, -264, -264, -264, -264, -264, -264, 44, + 73, -264, -264, -264, 18, -54, -23, -1, -264, -264, + -264, -55, 39, -264, 202, -264, 124, 77, -264, -264, + -19, -39, -264, -264, -70, -2, -264, -28, -222, -46, + -264, -25, -79, 70 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -101 +#define YYTABLE_NINF -100 static const yytype_int16 yytable[] = { - 34, 73, 73, 64, 74, 124, 125, 114, 145, 230, - 215, 50, 51, 52, 178, 133, 5, 252, 113, 57, - 57, 112, 57, 62, 4, 65, 267, 305, 67, 255, - 273, 246, 256, 57, 19, 43, 316, 91, 92, 93, - 94, 95, 111, 111, 96, 44, 33, 53, 244, 130, - 68, 130, 111, 111, 54, 44, 67, 69, 77, 126, - 166, 297, 78, -11, 208, 56, 58, 209, 59, 66, - 122, 44, 216, 4, 72, 171, 172, 25, 144, 90, - 146, 147, 148, 44, 298, 299, -11, 150, 315, 57, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 282, 131, 212, 131, 284, 246, 165, 85, 86, - 19, 142, -101, 74, 19, 246, 96, 132, 167, 236, - 57, 149, 303, 105, 106, 306, 307, 308, 325, 173, - -90, 328, -86, 177, 143, 152, 153, 154, 155, 156, - 157, 158, 159, 160, 161, 162, 163, 5, 206, 50, - 151, 78, 327, 130, 164, 329, 79, 132, -101, -101, - 168, 235, -100, 74, 74, 19, 170, 74, 174, 74, - 20, 169, 131, 74, 175, 136, 309, 310, 232, 23, - 137, 251, 80, 72, 241, -91, 68, 213, 69, 257, - 127, 128, 225, 264, 265, 278, 217, 85, 86, 74, - 69, 262, -100, 218, 234, 220, 131, 263, 115, 116, - 179, 270, 238, 225, 74, 266, 242, 243, 290, -100, - 280, 262, 268, 219, 277, -100, 269, 195, 111, 286, - 313, 318, 227, 72, 72, 319, 292, 72, 75, 72, - 311, 233, 61, 72, 93, 94, 95, 283, 65, 96, - 117, 118, 239, 207, 288, 289, 317, 274, 103, 104, - 221, 222, 294, 0, 223, 320, 226, 322, 253, 72, - 228, 0, 254, 119, 0, 0, 285, 237, 287, 57, - 0, 0, 0, 0, 72, 0, 0, 57, 0, 105, - 106, 0, 0, 0, 272, 0, 248, 107, 0, 0, - 0, 275, 276, 0, 0, 279, 0, 0, 0, 78, - 0, 258, 0, 0, 79, 0, 0, 78, 0, 0, - 0, 0, 79, 293, 0, 295, 0, 296, 301, 302, - 0, 304, 0, 90, 0, 2, 3, 0, 4, 5, - 80, 81, 6, 7, 0, 0, 0, 0, 80, 81, - 82, 321, 8, 9, 323, 85, 86, 324, 0, 326, - 83, 0, 0, 85, 86, 0, 0, 0, 0, 0, - 10, 11, 12, 13, 0, 132, 0, 0, 14, 15, - 16, 17, 18, 0, 0, 19, 20, 97, 98, 99, - 100, 101, 21, 22, 102, 23, 0, 24, 0, 0, - 25, 26, 0, 27, 0, 0, -14, 180, -14, 4, - 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 181, 0, 182, 183, 184, - -69, -69, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 0, 0, 0, 13, 194, 0, 0, 0, 14, - 15, 16, 17, 0, 0, 0, -69, 20, 0, 0, - 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, - 0, 25, 26, 0, 55, 0, 0, 68, -69, 69, - 180, 0, 4, 5, 0, 0, 6, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 181, 0, - 182, 183, 184, -68, -68, 185, 186, 187, 188, 189, - 190, 191, 192, 193, 0, 0, 0, 13, 194, 0, - 0, 0, 14, 15, 16, 17, 0, 0, 0, -68, - 20, 0, 0, 0, 0, 0, 21, 22, 0, 23, - 0, 24, 0, 0, 25, 26, 0, 55, 0, 0, - 68, -68, 69, 180, 0, 4, 5, 0, 0, 6, - 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 181, 0, 182, 183, 184, 0, 0, 185, 186, - 187, 188, 189, 190, 191, 192, 193, 0, 0, 0, - 13, 194, 0, 0, 0, 14, 15, 16, 17, 63, - 0, 4, 5, 20, 0, 6, 7, 0, -99, 21, - 22, 0, 23, 0, 24, 0, 0, 25, 26, 0, - 55, 0, 0, 68, 195, 69, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, - 0, 14, 15, 16, 17, 0, 0, 0, -99, 20, + 34, 79, 79, 70, 80, 125, 126, 120, 232, 248, + 254, 56, 57, 58, 217, 19, 146, 119, 246, 63, + 63, 118, 63, 68, 134, 71, 266, 44, 19, 137, + 4, 304, 272, 63, 138, 43, 74, 59, 75, 60, + 315, 131, 117, 117, 238, 33, 169, 239, 122, 170, + 5, 75, 111, 112, 131, 44, 128, 129, 117, 117, + 62, 64, 212, 65, 74, 127, 123, 83, 281, 167, + 44, 84, 283, 78, 96, 72, 218, 4, 314, 174, + 175, 248, 131, 181, 145, 44, 147, 148, 149, 302, + 248, -99, 305, 151, 132, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 132, 214, 121, + 168, 25, -89, 166, 80, 132, 102, 91, 92, 326, + 133, 63, 328, 324, 144, 211, 327, -100, -90, 19, + 176, -99, -11, 296, 180, 132, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 163, 164, -99, 209, + 56, 73, 5, 143, -99, -11, 297, 298, 109, 110, + 152, 133, 173, 150, 165, 178, 80, 80, 48, 49, + 80, 215, 80, -100, -100, 219, 80, 253, 220, 222, + 75, 234, 19, 78, 243, 73, 99, 100, 101, 111, + 112, 102, 265, 262, 256, 227, 277, 113, 263, 264, + 269, 80, 276, 261, -85, 177, 289, 236, 312, 198, + 50, 51, 317, 318, 240, 227, 80, 81, 244, 245, + 261, 84, 279, 310, 267, 288, 85, 67, 268, 210, + 117, 285, 319, 52, 241, 78, 78, 182, 291, 78, + 273, 78, 213, 0, 0, 78, 282, 306, 307, 0, + 71, 0, 86, 287, 0, 0, 0, 0, 316, 0, + 0, 293, 221, 0, 0, 0, 0, 91, 92, 321, + 78, 229, 0, 0, 0, 284, 84, 286, 63, 0, + 235, 85, 0, 0, 237, 78, 63, 84, 0, 223, + 224, 20, 85, 225, 0, 228, 0, 308, 309, 230, + 23, 0, 0, 0, 0, 0, 255, 86, 87, 0, + 84, 0, 0, 0, 0, 85, 0, 0, 86, 87, + 88, 0, 91, 92, 250, 0, 0, 96, 0, 271, + 89, 0, 0, 91, 92, 0, 274, 275, 0, 257, + 278, 86, 87, 88, 0, 97, 98, 99, 100, 101, + 84, 75, 102, 89, 208, 85, 91, 92, 292, 0, + 294, 0, 295, 300, 301, 0, 303, 2, 3, 0, + 4, 5, 0, 0, 6, 7, 0, 0, 0, 0, + 0, 86, 87, 88, 8, 9, 320, 0, 0, 322, + 0, 0, 323, 89, 325, 0, 91, 92, 0, 0, + 0, 0, 10, 11, 12, 13, 0, 0, 133, 0, + 14, 15, 16, 17, 18, 0, 0, 19, 20, 103, + 104, 105, 106, 107, 21, 22, 108, 23, 0, 24, + 0, 0, 25, 26, 0, 27, 0, 0, -14, 183, + -14, 4, 5, 0, 0, 6, 7, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 184, 0, 185, + 186, 187, -68, -68, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 0, 0, 0, 13, 197, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, -68, 20, 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, - 24, 0, 0, 25, 249, -99, 55, 0, 4, 5, - 0, -99, 6, 7, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 181, 0, 182, 183, 184, 0, - 0, 185, 186, 187, 188, 189, 190, 191, 192, 193, - 0, 0, 0, 13, 194, 0, 0, 0, 14, 15, - 16, 17, 0, 4, 5, 0, 20, 6, 7, 0, - 0, 0, 21, 22, 0, 23, 0, 24, 0, 0, - 25, 26, 0, 55, 0, 0, 68, 63, 69, 4, - 5, 0, 0, 6, 7, 0, 0, 0, 13, 0, - 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, - 0, 20, 0, 0, 0, 0, 0, 21, 22, 0, - 23, 0, 24, 0, 13, 25, 26, 0, 55, 14, - 15, 16, 17, 69, 0, 0, 0, 20, 0, 0, - 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, - 0, 25, 26, -99, 55, 63, 0, 4, 5, 0, + 24, 0, 0, 25, 26, 0, 61, 0, 0, 74, + -68, 75, 183, 0, 4, 5, 0, 0, 6, 7, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 184, 0, 185, 186, 187, -67, -67, 188, 189, 190, + 191, 192, 193, 194, 195, 196, 0, 0, 0, 13, + 197, 0, 0, 0, 14, 15, 16, 17, 0, 0, + 0, -67, 20, 0, 0, 0, 0, 0, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 0, 61, + 0, 0, 74, -67, 75, 183, 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 184, 0, 185, 186, 187, 0, 0, + 188, 189, 190, 191, 192, 193, 194, 195, 196, 0, + 0, 0, 13, 197, 0, 0, 0, 14, 15, 16, + 17, 69, 0, 4, 5, 20, 0, 6, 7, 0, + -98, 21, 22, 0, 23, 0, 24, 0, 0, 25, + 26, 0, 61, 0, 0, 74, 198, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, + -98, 20, 0, 0, 0, 0, 0, 21, 22, 0, + 23, 0, 24, 0, 0, 25, 251, -98, 61, 0, + 4, 5, 0, -98, 6, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 184, 0, 185, 186, + 187, 0, 0, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 0, 0, 0, 13, 197, 0, 0, 0, + 14, 15, 16, 17, 0, 4, 5, 0, 20, 6, + 7, 0, 0, 0, 21, 22, 0, 23, 0, 24, + 0, 0, 25, 26, 0, 61, 0, 0, 74, 69, + 75, 4, 5, 0, 0, 6, 7, 0, 0, 0, + 13, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 21, + 22, 0, 23, 0, 24, 0, 13, 25, 26, 0, + 61, 14, 15, 16, 17, 75, 0, 0, 0, 20, + 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 26, -98, 61, 69, 0, 4, + 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 176, 0, 4, 5, 0, 0, 6, 7, 0, + 0, 0, 0, 179, 0, 4, 5, 0, 0, 6, + 7, 0, 0, 0, 13, 0, 0, 0, 0, 14, + 15, 16, 17, 0, 0, 0, 0, 20, 0, 0, + 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, + 13, 25, 26, 0, 61, 14, 15, 16, 17, 0, + 4, 247, 0, 20, 6, 7, 0, 0, 0, 21, + 22, 0, 23, 0, 24, 0, 0, 25, 26, 186, + 61, 0, 0, 0, 0, 0, 0, 0, 193, 194, + 0, 0, 4, 5, 0, 13, 6, 7, 0, 0, + 14, 15, 16, 17, 0, 0, 0, 0, 20, 0, + 0, 186, 0, 0, 21, 22, 0, 23, 0, 24, + 193, 194, 25, 26, 0, 61, 0, 13, 0, 0, + 0, 0, 14, 15, 16, 17, 0, 4, 5, 0, + 20, 6, 7, 0, 0, 95, 21, 22, 0, 23, + 0, 24, 0, 0, 25, 26, 0, 61, 0, 0, + 0, 0, 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, 13, 0, 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, 13, 25, - 26, 0, 55, 14, 15, 16, 17, 0, 4, 245, + 26, 0, 61, 14, 15, 16, 17, 0, 4, 5, 0, 20, 6, 7, 0, 0, 0, 21, 22, 0, - 23, 0, 24, 0, 0, 25, 26, 183, 55, 0, - 0, 0, 0, 0, 0, 0, 190, 191, 0, 0, - 4, 5, 0, 13, 6, 7, 0, 0, 14, 15, - 16, 17, 0, 0, 0, 0, 20, 0, 0, 183, - 0, 0, 21, 22, 0, 23, 0, 24, 190, 191, - 25, 26, 0, 55, 0, 13, 0, 0, 0, 0, - 14, 15, 16, 17, 0, 4, 5, 0, 20, 6, - 7, 0, 0, 89, 21, 22, 0, 23, 0, 24, - 0, 0, 25, 26, 0, 55, 0, 0, 0, 0, - 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, - 13, 0, 0, 0, 0, 14, 15, 16, 17, 0, - 0, 0, 0, 20, 0, 0, 0, 0, 0, 21, - 22, 0, 23, 0, 24, 0, 13, 25, 26, 0, - 55, 14, 15, 16, 17, 0, 4, 5, 0, 20, - 6, 7, 0, 0, 0, 21, 22, 0, 23, 0, - 24, 0, 0, 25, 26, 0, 55, 0, 0, 0, + 23, 0, 24, 0, 0, 25, 26, 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 78, 14, 15, 16, 17, - 79, 78, 0, 0, 20, 0, 79, 0, 0, 0, - 21, 22, 0, 23, 0, 24, 0, 0, 25, 60, - 78, 55, 0, 0, 0, 79, 80, 81, 82, 0, - 0, 0, 80, 81, 82, 0, 0, 0, 83, 0, - 78, 85, 86, 0, 83, 79, 84, 85, 86, 0, - 0, 80, 81, 82, 0, 0, 0, 0, 0, 69, - 0, 0, 0, 83, 205, 0, 85, 86, 0, 0, - 0, 80, 81, 82, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 83, 0, 0, 85, 86 + 0, 0, 0, 0, 0, 0, 0, 84, 14, 15, + 16, 17, 85, 84, 0, 0, 20, 0, 85, 0, + 0, 0, 21, 22, 0, 23, 0, 24, 0, 0, + 25, 66, 0, 61, 0, 0, 0, 0, 86, 87, + 88, 0, 0, 0, 86, 87, 88, 0, 0, 0, + 89, 0, 90, 91, 92, 0, 89, 0, 0, 91, + 92 }; #define yypact_value_is_default(yystate) \ - ((yystate) == (-269)) + ((yystate) == (-264)) #define yytable_value_is_error(yytable_value) \ - ((yytable_value) == (-101)) + ((yytable_value) == (-100)) static const yytype_int16 yycheck[] = { - 1, 29, 30, 26, 29, 53, 54, 46, 80, 202, - 4, 13, 14, 15, 1, 64, 4, 230, 16, 21, - 22, 44, 24, 25, 3, 26, 40, 295, 27, 1, - 16, 220, 4, 35, 50, 66, 304, 57, 58, 59, - 60, 61, 43, 44, 64, 69, 1, 66, 219, 1, - 71, 1, 53, 54, 66, 69, 55, 73, 50, 60, - 109, 1, 9, 50, 1, 21, 22, 4, 24, 48, - 55, 69, 66, 3, 29, 124, 125, 65, 79, 35, - 81, 82, 83, 69, 24, 25, 73, 88, 301, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 272, 54, 175, 54, 276, 295, 108, 55, 56, - 50, 74, 9, 138, 50, 304, 64, 67, 70, 1, - 122, 84, 293, 43, 44, 296, 7, 8, 321, 130, - 67, 324, 72, 134, 5, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 4, 149, 151, - 38, 9, 323, 1, 13, 326, 14, 67, 55, 56, - 49, 210, 10, 188, 189, 50, 122, 192, 131, 194, - 51, 66, 54, 198, 40, 1, 57, 58, 203, 60, - 6, 229, 40, 138, 4, 67, 71, 66, 73, 238, - 43, 44, 193, 242, 243, 267, 66, 55, 56, 224, - 73, 240, 50, 66, 205, 66, 54, 67, 3, 4, - 138, 10, 213, 214, 239, 26, 217, 218, 20, 67, - 269, 260, 247, 186, 66, 73, 249, 72, 229, 278, - 53, 7, 195, 188, 189, 7, 285, 192, 30, 194, - 298, 204, 25, 198, 59, 60, 61, 275, 249, 64, - 45, 46, 214, 151, 279, 281, 305, 260, 12, 13, - 188, 189, 287, -1, 192, 312, 194, 316, 231, 224, - 198, -1, 235, 68, -1, -1, 277, 211, 279, 281, - -1, -1, -1, -1, 239, -1, -1, 289, -1, 43, - 44, -1, -1, -1, 257, -1, 224, 51, -1, -1, - -1, 264, 265, -1, -1, 268, -1, -1, -1, 9, - -1, 239, -1, -1, 14, -1, -1, 9, -1, -1, - -1, -1, 14, 286, -1, 288, -1, 290, 291, 292, - -1, 294, -1, 289, -1, 0, 1, -1, 3, 4, - 40, 41, 7, 8, -1, -1, -1, -1, 40, 41, - 42, 314, 17, 18, 317, 55, 56, 320, -1, 322, - 52, -1, -1, 55, 56, -1, -1, -1, -1, -1, - 35, 36, 37, 38, -1, 67, -1, -1, 43, 44, - 45, 46, 47, -1, -1, 50, 51, 57, 58, 59, - 60, 61, 57, 58, 64, 60, -1, 62, -1, -1, - 65, 66, -1, 68, -1, -1, 71, 1, 73, 3, - 4, -1, -1, 7, 8, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 19, -1, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, -1, -1, -1, 38, 39, -1, -1, -1, 43, - 44, 45, 46, -1, -1, -1, 50, 51, -1, -1, - -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, - -1, 65, 66, -1, 68, -1, -1, 71, 72, 73, - 1, -1, 3, 4, -1, -1, 7, 8, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, -1, -1, -1, 38, 39, -1, - -1, -1, 43, 44, 45, 46, -1, -1, -1, 50, - 51, -1, -1, -1, -1, -1, 57, 58, -1, 60, - -1, 62, -1, -1, 65, 66, -1, 68, -1, -1, - 71, 72, 73, 1, -1, 3, 4, -1, -1, 7, - 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 19, -1, 21, 22, 23, -1, -1, 26, 27, - 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, - 38, 39, -1, -1, -1, 43, 44, 45, 46, 1, - -1, 3, 4, 51, -1, 7, 8, -1, 10, 57, - 58, -1, 60, -1, 62, -1, -1, 65, 66, -1, - 68, -1, -1, 71, 72, 73, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, + 1, 29, 30, 26, 29, 59, 60, 46, 205, 222, + 232, 13, 14, 15, 4, 50, 86, 16, 221, 21, + 22, 44, 24, 25, 70, 26, 40, 69, 50, 1, + 3, 294, 16, 35, 6, 66, 71, 66, 73, 66, + 303, 1, 43, 44, 1, 1, 1, 4, 66, 4, + 4, 73, 43, 44, 1, 69, 43, 44, 59, 60, + 21, 22, 1, 24, 71, 66, 55, 50, 271, 115, + 69, 9, 275, 29, 35, 48, 66, 3, 300, 125, + 126, 294, 1, 1, 85, 69, 87, 88, 89, 292, + 303, 10, 295, 94, 54, 97, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 54, 178, 49, + 70, 65, 67, 114, 139, 54, 64, 55, 56, 322, + 67, 123, 325, 320, 5, 171, 323, 9, 67, 50, + 131, 50, 50, 1, 135, 54, 97, 98, 99, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 67, 150, + 152, 27, 4, 80, 73, 73, 24, 25, 12, 13, + 38, 67, 123, 90, 13, 40, 191, 192, 3, 4, + 195, 66, 197, 55, 56, 66, 201, 231, 66, 66, + 73, 206, 50, 139, 4, 61, 59, 60, 61, 43, + 44, 64, 26, 67, 240, 196, 266, 51, 244, 245, + 10, 226, 66, 242, 72, 132, 20, 208, 53, 72, + 45, 46, 7, 7, 215, 216, 241, 30, 219, 220, + 259, 9, 268, 297, 249, 280, 14, 25, 251, 152, + 231, 277, 311, 68, 216, 191, 192, 139, 284, 195, + 259, 197, 172, -1, -1, 201, 274, 7, 8, -1, + 251, -1, 40, 278, -1, -1, -1, -1, 304, -1, + -1, 286, 189, -1, -1, -1, -1, 55, 56, 315, + 226, 198, -1, -1, -1, 276, 9, 278, 280, -1, + 207, 14, -1, -1, 211, 241, 288, 9, -1, 191, + 192, 51, 14, 195, -1, 197, -1, 57, 58, 201, + 60, -1, -1, -1, -1, -1, 233, 40, 41, -1, + 9, -1, -1, -1, -1, 14, -1, -1, 40, 41, + 42, -1, 55, 56, 226, -1, -1, 288, -1, 256, + 52, -1, -1, 55, 56, -1, 263, 264, -1, 241, + 267, 40, 41, 42, -1, 57, 58, 59, 60, 61, + 9, 73, 64, 52, 53, 14, 55, 56, 285, -1, + 287, -1, 289, 290, 291, -1, 293, 0, 1, -1, + 3, 4, -1, -1, 7, 8, -1, -1, -1, -1, + -1, 40, 41, 42, 17, 18, 313, -1, -1, 316, + -1, -1, 319, 52, 321, -1, 55, 56, -1, -1, + -1, -1, 35, 36, 37, 38, -1, -1, 67, -1, + 43, 44, 45, 46, 47, -1, -1, 50, 51, 57, + 58, 59, 60, 61, 57, 58, 64, 60, -1, 62, + -1, -1, 65, 66, -1, 68, -1, -1, 71, 1, + 73, 3, 4, -1, -1, 7, 8, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 19, -1, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, -1, -1, -1, 38, 39, -1, -1, -1, 43, 44, 45, 46, -1, -1, -1, 50, 51, -1, -1, -1, -1, -1, 57, 58, -1, 60, -1, - 62, -1, -1, 65, 66, 67, 68, -1, 3, 4, - -1, 73, 7, 8, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 19, -1, 21, 22, 23, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, - -1, -1, -1, 38, 39, -1, -1, -1, 43, 44, - 45, 46, -1, 3, 4, -1, 51, 7, 8, -1, - -1, -1, 57, 58, -1, 60, -1, 62, -1, -1, - 65, 66, -1, 68, -1, -1, 71, 1, 73, 3, - 4, -1, -1, 7, 8, -1, -1, -1, 38, -1, - -1, -1, -1, 43, 44, 45, 46, -1, -1, -1, - -1, 51, -1, -1, -1, -1, -1, 57, 58, -1, - 60, -1, 62, -1, 38, 65, 66, -1, 68, 43, - 44, 45, 46, 73, -1, -1, -1, 51, -1, -1, - -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, - -1, 65, 66, 67, 68, 1, -1, 3, 4, -1, + 62, -1, -1, 65, 66, -1, 68, -1, -1, 71, + 72, 73, 1, -1, 3, 4, -1, -1, 7, 8, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 19, -1, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, -1, -1, -1, 38, + 39, -1, -1, -1, 43, 44, 45, 46, -1, -1, + -1, 50, 51, -1, -1, -1, -1, -1, 57, 58, + -1, 60, -1, 62, -1, -1, 65, 66, -1, 68, + -1, -1, 71, 72, 73, 1, -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 19, -1, 21, 22, 23, -1, -1, + 26, 27, 28, 29, 30, 31, 32, 33, 34, -1, + -1, -1, 38, 39, -1, -1, -1, 43, 44, 45, + 46, 1, -1, 3, 4, 51, -1, 7, 8, -1, + 10, 57, 58, -1, 60, -1, 62, -1, -1, 65, + 66, -1, 68, -1, -1, 71, 72, 73, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, + -1, -1, -1, 43, 44, 45, 46, -1, -1, -1, + 50, 51, -1, -1, -1, -1, -1, 57, 58, -1, + 60, -1, 62, -1, -1, 65, 66, 67, 68, -1, + 3, 4, -1, 73, 7, 8, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 19, -1, 21, 22, + 23, -1, -1, 26, 27, 28, 29, 30, 31, 32, + 33, 34, -1, -1, -1, 38, 39, -1, -1, -1, + 43, 44, 45, 46, -1, 3, 4, -1, 51, 7, + 8, -1, -1, -1, 57, 58, -1, 60, -1, 62, + -1, -1, 65, 66, -1, 68, -1, -1, 71, 1, + 73, 3, 4, -1, -1, 7, 8, -1, -1, -1, + 38, -1, -1, -1, -1, 43, 44, 45, 46, -1, + -1, -1, -1, 51, -1, -1, -1, -1, -1, 57, + 58, -1, 60, -1, 62, -1, 38, 65, 66, -1, + 68, 43, 44, 45, 46, 73, -1, -1, -1, 51, + -1, -1, -1, -1, -1, 57, 58, -1, 60, -1, + 62, -1, -1, 65, 66, 67, 68, 1, -1, 3, + 4, -1, -1, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 1, -1, 3, 4, -1, -1, 7, 8, -1, + -1, -1, -1, 1, -1, 3, 4, -1, -1, 7, + 8, -1, -1, -1, 38, -1, -1, -1, -1, 43, + 44, 45, 46, -1, -1, -1, -1, 51, -1, -1, + -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, + 38, 65, 66, -1, 68, 43, 44, 45, 46, -1, + 3, 4, -1, 51, 7, 8, -1, -1, -1, 57, + 58, -1, 60, -1, 62, -1, -1, 65, 66, 22, + 68, -1, -1, -1, -1, -1, -1, -1, 31, 32, + -1, -1, 3, 4, -1, 38, 7, 8, -1, -1, + 43, 44, 45, 46, -1, -1, -1, -1, 51, -1, + -1, 22, -1, -1, 57, 58, -1, 60, -1, 62, + 31, 32, 65, 66, -1, 68, -1, 38, -1, -1, + -1, -1, 43, 44, 45, 46, -1, 3, 4, -1, + 51, 7, 8, -1, -1, 11, 57, 58, -1, 60, + -1, 62, -1, -1, 65, 66, -1, 68, -1, -1, + -1, -1, -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, 38, -1, -1, -1, -1, 43, 44, 45, 46, -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, 38, 65, 66, -1, 68, 43, 44, 45, 46, -1, 3, 4, -1, 51, 7, 8, -1, -1, -1, 57, 58, -1, - 60, -1, 62, -1, -1, 65, 66, 22, 68, -1, - -1, -1, -1, -1, -1, -1, 31, 32, -1, -1, - 3, 4, -1, 38, 7, 8, -1, -1, 43, 44, - 45, 46, -1, -1, -1, -1, 51, -1, -1, 22, - -1, -1, 57, 58, -1, 60, -1, 62, 31, 32, - 65, 66, -1, 68, -1, 38, -1, -1, -1, -1, - 43, 44, 45, 46, -1, 3, 4, -1, 51, 7, - 8, -1, -1, 11, 57, 58, -1, 60, -1, 62, - -1, -1, 65, 66, -1, 68, -1, -1, -1, -1, - -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, - 38, -1, -1, -1, -1, 43, 44, 45, 46, -1, - -1, -1, -1, 51, -1, -1, -1, -1, -1, 57, - 58, -1, 60, -1, 62, -1, 38, 65, 66, -1, - 68, 43, 44, 45, 46, -1, 3, 4, -1, 51, - 7, 8, -1, -1, -1, 57, 58, -1, 60, -1, - 62, -1, -1, 65, 66, -1, 68, -1, -1, -1, + 60, -1, 62, -1, -1, 65, 66, -1, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 9, 43, 44, 45, 46, - 14, 9, -1, -1, 51, -1, 14, -1, -1, -1, - 57, 58, -1, 60, -1, 62, -1, -1, 65, 66, - 9, 68, -1, -1, -1, 14, 40, 41, 42, -1, - -1, -1, 40, 41, 42, -1, -1, -1, 52, -1, - 9, 55, 56, -1, 52, 14, 54, 55, 56, -1, - -1, 40, 41, 42, -1, -1, -1, -1, -1, 73, - -1, -1, -1, 52, 53, -1, 55, 56, -1, -1, - -1, 40, 41, 42, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 52, -1, -1, 55, 56 + -1, -1, -1, -1, -1, -1, -1, 9, 43, 44, + 45, 46, 14, 9, -1, -1, 51, -1, 14, -1, + -1, -1, 57, 58, -1, 60, -1, 62, -1, -1, + 65, 66, -1, 68, -1, -1, -1, -1, 40, 41, + 42, -1, -1, -1, 40, 41, 42, -1, -1, -1, + 52, -1, 54, 55, 56, -1, 52, -1, -1, 55, + 56 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -1209,36 +1183,36 @@ static const yytype_uint8 yystos[] = 0, 75, 0, 1, 3, 4, 7, 8, 17, 18, 35, 36, 37, 38, 43, 44, 45, 46, 47, 50, 51, 57, 58, 60, 62, 65, 66, 68, 76, 78, - 82, 84, 86, 104, 112, 116, 117, 118, 119, 120, - 121, 129, 130, 66, 69, 126, 127, 128, 83, 122, - 130, 130, 130, 66, 66, 68, 117, 130, 117, 117, - 66, 119, 130, 1, 111, 112, 48, 121, 71, 73, - 79, 88, 104, 132, 136, 79, 85, 50, 9, 14, - 40, 41, 42, 52, 54, 55, 56, 114, 115, 11, - 117, 57, 58, 59, 60, 61, 64, 57, 58, 59, - 60, 61, 64, 12, 13, 43, 44, 51, 113, 110, - 111, 112, 111, 16, 126, 3, 4, 45, 46, 68, - 80, 81, 55, 106, 110, 110, 112, 43, 44, 131, - 1, 54, 67, 134, 138, 134, 1, 6, 77, 104, - 105, 87, 105, 5, 112, 129, 112, 112, 112, 105, - 112, 38, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 13, 112, 134, 70, 49, 66, - 117, 134, 134, 112, 105, 40, 1, 112, 1, 88, - 1, 19, 21, 22, 23, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 39, 72, 89, 90, 92, 99, - 103, 112, 132, 133, 136, 53, 112, 122, 1, 4, - 107, 108, 129, 66, 91, 4, 66, 66, 66, 105, - 66, 88, 88, 88, 109, 112, 88, 105, 88, 93, - 87, 135, 136, 105, 112, 134, 1, 138, 112, 109, - 94, 4, 112, 112, 89, 4, 92, 95, 88, 66, - 100, 110, 133, 105, 105, 1, 4, 134, 88, 123, - 124, 125, 126, 67, 134, 134, 26, 40, 136, 111, - 10, 101, 105, 16, 125, 105, 105, 66, 129, 105, - 134, 102, 89, 132, 89, 112, 134, 112, 136, 116, - 20, 96, 134, 105, 136, 105, 105, 1, 24, 25, - 97, 105, 105, 89, 105, 95, 89, 7, 8, 57, - 58, 84, 98, 53, 137, 133, 95, 134, 7, 7, - 137, 105, 134, 105, 105, 87, 105, 89, 87, 89 + 82, 83, 85, 103, 111, 115, 116, 117, 118, 119, + 120, 128, 129, 66, 69, 125, 126, 127, 3, 4, + 45, 46, 68, 80, 81, 121, 129, 129, 129, 66, + 66, 68, 116, 129, 116, 116, 66, 118, 129, 1, + 110, 111, 48, 120, 71, 73, 79, 87, 103, 131, + 135, 79, 84, 50, 9, 14, 40, 41, 42, 52, + 54, 55, 56, 113, 114, 11, 116, 57, 58, 59, + 60, 61, 64, 57, 58, 59, 60, 61, 64, 12, + 13, 43, 44, 51, 112, 109, 110, 111, 110, 16, + 125, 49, 66, 55, 105, 109, 109, 111, 43, 44, + 130, 1, 54, 67, 133, 137, 133, 1, 6, 77, + 103, 104, 86, 104, 5, 111, 128, 111, 111, 111, + 104, 111, 38, 116, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 13, 111, 133, 70, 1, + 4, 106, 107, 116, 133, 133, 111, 104, 40, 1, + 111, 1, 87, 1, 19, 21, 22, 23, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 39, 72, 88, + 89, 91, 98, 102, 111, 131, 132, 135, 53, 111, + 121, 133, 1, 137, 128, 66, 90, 4, 66, 66, + 66, 104, 66, 87, 87, 87, 108, 111, 87, 104, + 87, 92, 86, 134, 135, 104, 111, 104, 1, 4, + 111, 108, 93, 4, 111, 111, 88, 4, 91, 94, + 87, 66, 99, 109, 132, 104, 133, 87, 122, 123, + 124, 125, 67, 133, 133, 26, 40, 135, 110, 10, + 100, 104, 16, 124, 104, 104, 66, 128, 104, 133, + 101, 88, 131, 88, 111, 133, 111, 135, 115, 20, + 95, 133, 104, 135, 104, 104, 1, 24, 25, 96, + 104, 104, 88, 104, 94, 88, 7, 8, 57, 58, + 83, 97, 53, 136, 132, 94, 133, 7, 7, 136, + 104, 133, 104, 104, 86, 104, 88, 86, 88 }; #define yyerrok (yyerrstatus = 0) @@ -2066,7 +2040,7 @@ yyreduce: case 3: /* Line 1806 of yacc.c */ -#line 221 "awkgram.y" +#line 195 "awkgram.y" { rule = 0; yyerrok; @@ -2076,7 +2050,7 @@ yyreduce: case 5: /* Line 1806 of yacc.c */ -#line 227 "awkgram.y" +#line 201 "awkgram.y" { next_sourcefile(); } @@ -2085,7 +2059,7 @@ yyreduce: case 6: /* Line 1806 of yacc.c */ -#line 231 "awkgram.y" +#line 205 "awkgram.y" { rule = 0; /* @@ -2099,7 +2073,7 @@ yyreduce: case 7: /* Line 1806 of yacc.c */ -#line 243 "awkgram.y" +#line 217 "awkgram.y" { (void) append_rule((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -2108,7 +2082,7 @@ yyreduce: case 8: /* Line 1806 of yacc.c */ -#line 247 "awkgram.y" +#line 221 "awkgram.y" { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -2124,12 +2098,10 @@ yyreduce: case 9: /* Line 1806 of yacc.c */ -#line 258 "awkgram.y" +#line 232 "awkgram.y" { - can_return = FALSE; - if ((yyvsp[(1) - (2)]) && func_install((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])) < 0) - YYABORT; - func_params = NULL; + in_function = NULL; + (void) mk_function((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); yyerrok; } break; @@ -2137,7 +2109,7 @@ yyreduce: case 10: /* Line 1806 of yacc.c */ -#line 266 "awkgram.y" +#line 238 "awkgram.y" { want_source = FALSE; yyerrok; @@ -2147,7 +2119,7 @@ yyreduce: case 11: /* Line 1806 of yacc.c */ -#line 274 "awkgram.y" +#line 246 "awkgram.y" { if (include_source((yyvsp[(1) - (1)])) < 0) YYABORT; @@ -2160,35 +2132,35 @@ yyreduce: case 12: /* Line 1806 of yacc.c */ -#line 282 "awkgram.y" +#line 254 "awkgram.y" { (yyval) = NULL; } break; case 13: /* Line 1806 of yacc.c */ -#line 284 "awkgram.y" +#line 256 "awkgram.y" { (yyval) = NULL; } break; case 14: /* Line 1806 of yacc.c */ -#line 289 "awkgram.y" +#line 261 "awkgram.y" { (yyval) = NULL; rule = Rule; } break; case 15: /* Line 1806 of yacc.c */ -#line 291 "awkgram.y" +#line 263 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); rule = Rule; } break; case 16: /* Line 1806 of yacc.c */ -#line 293 "awkgram.y" +#line 265 "awkgram.y" { INSTRUCTION *tp; @@ -2196,7 +2168,7 @@ yyreduce: add_lint((yyvsp[(4) - (4)]), LINT_assign_in_cond); tp = instruction(Op_no_op); - list_prepend((yyvsp[(1) - (4)]), bcalloc(Op_line_range, !!do_profiling + 1, 0)); + list_prepend((yyvsp[(1) - (4)]), bcalloc(Op_line_range, !!do_pretty_print + 1, 0)); (yyvsp[(1) - (4)])->nexti->triggered = FALSE; (yyvsp[(1) - (4)])->nexti->target_jmp = (yyvsp[(4) - (4)])->nexti; @@ -2207,7 +2179,7 @@ yyreduce: list_append((yyvsp[(4) - (4)]), instruction(Op_cond_pair)); (yyvsp[(4) - (4)])->lasti->line_range = (yyvsp[(1) - (4)])->nexti; (yyvsp[(4) - (4)])->lasti->target_jmp = tp; - if (do_profiling) { + if (do_pretty_print) { ((yyvsp[(1) - (4)])->nexti + 1)->condpair_left = (yyvsp[(1) - (4)])->lasti; ((yyvsp[(1) - (4)])->nexti + 1)->condpair_right = (yyvsp[(4) - (4)])->lasti; } @@ -2219,7 +2191,7 @@ yyreduce: case 17: /* Line 1806 of yacc.c */ -#line 319 "awkgram.y" +#line 291 "awkgram.y" { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -2235,7 +2207,7 @@ yyreduce: case 18: /* Line 1806 of yacc.c */ -#line 330 "awkgram.y" +#line 302 "awkgram.y" { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -2251,7 +2223,7 @@ yyreduce: case 19: /* Line 1806 of yacc.c */ -#line 341 "awkgram.y" +#line 313 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = BEGINFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2262,7 +2234,7 @@ yyreduce: case 20: /* Line 1806 of yacc.c */ -#line 347 "awkgram.y" +#line 319 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = ENDFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2273,7 +2245,7 @@ yyreduce: case 21: /* Line 1806 of yacc.c */ -#line 356 "awkgram.y" +#line 328 "awkgram.y" { if ((yyvsp[(2) - (5)]) == NULL) (yyval) = list_create(instruction(Op_no_op)); @@ -2285,89 +2257,69 @@ yyreduce: case 22: /* Line 1806 of yacc.c */ -#line 366 "awkgram.y" +#line 338 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: /* Line 1806 of yacc.c */ -#line 368 "awkgram.y" +#line 340 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 24: /* Line 1806 of yacc.c */ -#line 370 "awkgram.y" +#line 342 "awkgram.y" { yyerror(_("`%s' is a built-in function, it cannot be redefined"), - tokstart); - (yyvsp[(1) - (1)])->opcode = Op_symbol; /* Op_symbol instead of Op_token so that - * free_bc_internal does not try to free it - */ - (yyvsp[(1) - (1)])->lextok = builtin_func; - (yyval) = (yyvsp[(1) - (1)]); - /* yyerrok; */ + tokstart); + YYABORT; } break; case 25: /* Line 1806 of yacc.c */ -#line 381 "awkgram.y" +#line 348 "awkgram.y" { (yyval) = (yyvsp[(2) - (2)]); } break; case 28: /* Line 1806 of yacc.c */ -#line 391 "awkgram.y" +#line 358 "awkgram.y" { - param_counter = 0; - func_params = NULL; + (yyvsp[(1) - (6)])->source_file = source; + if (install_function((yyvsp[(2) - (6)])->lextok, (yyvsp[(1) - (6)]), (yyvsp[(4) - (6)])) < 0) + YYABORT; + in_function = (yyvsp[(2) - (6)])->lextok; + (yyvsp[(2) - (6)])->lextok = NULL; + bcfree((yyvsp[(2) - (6)])); + /* $4 already free'd in install_function */ + (yyval) = (yyvsp[(1) - (6)]); } break; case 29: /* Line 1806 of yacc.c */ -#line 396 "awkgram.y" - { - NODE *t; - - (yyvsp[(1) - (7)])->source_file = source; - t = make_param((yyvsp[(3) - (7)])->lextok); - (yyvsp[(3) - (7)])->lextok = NULL; - bcfree((yyvsp[(3) - (7)])); - t->flags |= FUNC; - t->rnode = func_params; - func_params = t; - (yyval) = (yyvsp[(1) - (7)]); - can_return = TRUE; - /* check for duplicate parameter names */ - if (dup_parms((yyvsp[(1) - (7)]), t)) - errcount++; - } - break; - - case 30: - -/* Line 1806 of yacc.c */ -#line 420 "awkgram.y" +#line 376 "awkgram.y" { ++want_regexp; } break; - case 31: + case 30: /* Line 1806 of yacc.c */ -#line 422 "awkgram.y" +#line 378 "awkgram.y" { NODE *n, *exp; char *re; size_t len; re = (yyvsp[(3) - (3)])->lextok; + (yyvsp[(3) - (3)])->lextok = NULL; len = strlen(re); if (do_lint) { if (len == 0) @@ -2391,24 +2343,24 @@ yyreduce: } break; - case 32: + case 31: /* Line 1806 of yacc.c */ -#line 453 "awkgram.y" +#line 410 "awkgram.y" { bcfree((yyvsp[(1) - (1)])); } break; - case 34: + case 33: /* Line 1806 of yacc.c */ -#line 459 "awkgram.y" +#line 416 "awkgram.y" { (yyval) = NULL; } break; - case 35: + case 34: /* Line 1806 of yacc.c */ -#line 461 "awkgram.y" +#line 418 "awkgram.y" { if ((yyvsp[(2) - (2)]) == NULL) (yyval) = (yyvsp[(1) - (2)]); @@ -2423,43 +2375,43 @@ yyreduce: } break; - case 36: + case 35: /* Line 1806 of yacc.c */ -#line 474 "awkgram.y" +#line 431 "awkgram.y" { (yyval) = NULL; } break; - case 39: + case 38: /* Line 1806 of yacc.c */ -#line 484 "awkgram.y" +#line 441 "awkgram.y" { (yyval) = NULL; } break; - case 40: + case 39: /* Line 1806 of yacc.c */ -#line 486 "awkgram.y" +#line 443 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; - case 41: + case 40: /* Line 1806 of yacc.c */ -#line 488 "awkgram.y" +#line 445 "awkgram.y" { - if (do_profiling) + if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); else (yyval) = (yyvsp[(1) - (1)]); } break; - case 42: + case 41: /* Line 1806 of yacc.c */ -#line 495 "awkgram.y" +#line 452 "awkgram.y" { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2518,7 +2470,7 @@ yyreduce: else dflt->target_jmp = casestmt->nexti; - if (do_profiling) { + if (do_pretty_print) { curr->stmt_start = casestmt->nexti; curr->stmt_end = casestmt->lasti; (void) list_prepend(cexp, curr); @@ -2533,7 +2485,7 @@ yyreduce: efree(case_values); ip = (yyvsp[(3) - (9)]); - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, (yyvsp[(1) - (9)])); (void) list_prepend(ip, instruction(Op_exec_count)); (yyvsp[(1) - (9)])->target_break = tbreak; @@ -2551,10 +2503,10 @@ yyreduce: } break; - case 43: + case 42: /* Line 1806 of yacc.c */ -#line 585 "awkgram.y" +#line 542 "awkgram.y" { /* * ----------------- @@ -2577,7 +2529,7 @@ yyreduce: ip = list_append((yyvsp[(3) - (6)]), instruction(Op_jmp_false)); ip->lasti->target_jmp = tbreak; - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); (yyvsp[(1) - (6)])->target_break = tbreak; (yyvsp[(1) - (6)])->target_continue = tcont; @@ -2598,10 +2550,10 @@ yyreduce: } break; - case 44: + case 43: /* Line 1806 of yacc.c */ -#line 627 "awkgram.y" +#line 584 "awkgram.y" { /* * ----------------- @@ -2624,7 +2576,7 @@ yyreduce: ip = list_merge((yyvsp[(3) - (8)]), (yyvsp[(6) - (8)])); else ip = list_prepend((yyvsp[(6) - (8)]), instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(ip, instruction(Op_exec_count)); (void) list_append(ip, instruction(Op_jmp_true)); ip->lasti->target_jmp = ip->nexti; @@ -2634,7 +2586,7 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { (yyvsp[(1) - (8)])->target_break = tbreak; (yyvsp[(1) - (8)])->target_continue = tcont; ((yyvsp[(1) - (8)]) + 1)->doloop_cond = tcont; @@ -2645,10 +2597,10 @@ yyreduce: } break; - case 45: + case 44: /* Line 1806 of yacc.c */ -#line 669 "awkgram.y" +#line 626 "awkgram.y" { INSTRUCTION *ip; char *var_name = (yyvsp[(3) - (8)])->lextok; @@ -2715,14 +2667,14 @@ regular_loop: tbreak = instruction(Op_arrayfor_final); (yyvsp[(4) - (8)])->opcode = Op_arrayfor_incr; - (yyvsp[(4) - (8)])->array_var = variable(var_name, Node_var); + (yyvsp[(4) - (8)])->array_var = variable((yyvsp[(3) - (8)])->source_line, var_name, Node_var); (yyvsp[(4) - (8)])->target_jmp = tbreak; tcont = (yyvsp[(4) - (8)]); (yyvsp[(3) - (8)])->opcode = Op_arrayfor_init; (yyvsp[(3) - (8)])->target_jmp = tbreak; (void) list_append(ip, (yyvsp[(3) - (8)])); - if (do_profiling) { + if (do_pretty_print) { (yyvsp[(1) - (8)])->opcode = Op_K_arrayfor; (yyvsp[(1) - (8)])->target_continue = tcont; (yyvsp[(1) - (8)])->target_break = tbreak; @@ -2743,7 +2695,7 @@ regular_loop: ip->lasti->assign_var = (yyvsp[(4) - (8)])->array_var->var_assign; } - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); ((yyvsp[(1) - (8)]) + 1)->forloop_cond = (yyvsp[(4) - (8)]); ((yyvsp[(1) - (8)]) + 1)->forloop_body = ip->lasti; @@ -2763,10 +2715,10 @@ regular_loop: } break; - case 46: + case 45: /* Line 1806 of yacc.c */ -#line 782 "awkgram.y" +#line 739 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]), (yyvsp[(6) - (12)]), (yyvsp[(9) - (12)]), (yyvsp[(12) - (12)])); @@ -2775,10 +2727,10 @@ regular_loop: } break; - case 47: + case 46: /* Line 1806 of yacc.c */ -#line 789 "awkgram.y" +#line 746 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (11)]), (yyvsp[(3) - (11)]), (INSTRUCTION *) NULL, (yyvsp[(8) - (11)]), (yyvsp[(11) - (11)])); @@ -2787,22 +2739,22 @@ regular_loop: } break; - case 48: + case 47: /* Line 1806 of yacc.c */ -#line 796 "awkgram.y" +#line 753 "awkgram.y" { - if (do_profiling) + if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); else (yyval) = (yyvsp[(1) - (1)]); } break; - case 49: + case 48: /* Line 1806 of yacc.c */ -#line 806 "awkgram.y" +#line 763 "awkgram.y" { if (! break_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2813,10 +2765,10 @@ regular_loop: } break; - case 50: + case 49: /* Line 1806 of yacc.c */ -#line 815 "awkgram.y" +#line 772 "awkgram.y" { if (! continue_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2827,10 +2779,10 @@ regular_loop: } break; - case 51: + case 50: /* Line 1806 of yacc.c */ -#line 824 "awkgram.y" +#line 781 "awkgram.y" { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2841,10 +2793,10 @@ regular_loop: } break; - case 52: + case 51: /* Line 1806 of yacc.c */ -#line 833 "awkgram.y" +#line 790 "awkgram.y" { if (do_traditional) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2861,10 +2813,10 @@ regular_loop: } break; - case 53: + case 52: /* Line 1806 of yacc.c */ -#line 848 "awkgram.y" +#line 805 "awkgram.y" { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2875,47 +2827,59 @@ regular_loop: if ((yyvsp[(2) - (3)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (3)])); (void) list_prepend((yyval), instruction(Op_push_i)); - (yyval)->nexti->memory = Nnull_string; + (yyval)->nexti->memory = dupnode(Nnull_string); } else (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); } break; - case 54: + case 53: /* Line 1806 of yacc.c */ -#line 863 "awkgram.y" +#line 820 "awkgram.y" { - if (! can_return) + if (! in_function) yyerror(_("`return' used outside function context")); } break; - case 55: + case 54: /* Line 1806 of yacc.c */ -#line 866 "awkgram.y" +#line 823 "awkgram.y" { if ((yyvsp[(3) - (4)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (4)])); (void) list_prepend((yyval), instruction(Op_push_i)); - (yyval)->nexti->memory = Nnull_string; - } else + (yyval)->nexti->memory = dupnode(Nnull_string); + } else { + if (do_optimize > 1 + && (yyvsp[(3) - (4)])->lasti->opcode == Op_func_call + && strcmp((yyvsp[(3) - (4)])->lasti->func_name, in_function) == 0 + ) { + /* Do tail recursion optimization. Tail + * call without a return value is recognized + * in mk_function(). + */ + ((yyvsp[(3) - (4)])->lasti + 1)->tail_call = TRUE; + } + (yyval) = list_append((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); + } } break; - case 57: + case 56: /* Line 1806 of yacc.c */ -#line 886 "awkgram.y" +#line 855 "awkgram.y" { in_print = TRUE; in_parens = 0; } break; - case 58: + case 57: /* Line 1806 of yacc.c */ -#line 887 "awkgram.y" +#line 856 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2924,13 +2888,13 @@ regular_loop: */ if ((yyvsp[(1) - (4)])->opcode == Op_K_print && - ((yyvsp[(3) - (4)]) == NULL - || ((yyvsp[(3) - (4)])->lasti->opcode == Op_field_spec - && (yyvsp[(3) - (4)])->nexti->nexti->nexti == (yyvsp[(3) - (4)])->lasti - && (yyvsp[(3) - (4)])->nexti->nexti->opcode == Op_push_i - && (yyvsp[(3) - (4)])->nexti->nexti->memory->type == Node_val - && (yyvsp[(3) - (4)])->nexti->nexti->memory->numbr == 0.0) - ) + ((yyvsp[(3) - (4)]) == NULL + || ((yyvsp[(3) - (4)])->lasti->opcode == Op_field_spec + && (yyvsp[(3) - (4)])->nexti->nexti->nexti == (yyvsp[(3) - (4)])->lasti + && (yyvsp[(3) - (4)])->nexti->nexti->opcode == Op_push_i + && (yyvsp[(3) - (4)])->nexti->nexti->memory->type == Node_val + && (yyvsp[(3) - (4)])->nexti->nexti->memory->numbr == 0.0) + ) ) { static short warned = FALSE; /* ----------------- @@ -2944,8 +2908,6 @@ regular_loop: if ((yyvsp[(3) - (4)]) != NULL) { bcfree((yyvsp[(3) - (4)])->lasti); /* Op_field_spec */ - (yyvsp[(3) - (4)])->nexti->nexti->memory->flags &= ~PERM; - (yyvsp[(3) - (4)])->nexti->nexti->memory->flags |= MALLOC; unref((yyvsp[(3) - (4)])->nexti->nexti->memory); /* Node_val */ bcfree((yyvsp[(3) - (4)])->nexti->nexti); /* Op_push_i */ bcfree((yyvsp[(3) - (4)])->nexti); /* Op_list */ @@ -3012,22 +2974,22 @@ regular_loop: } break; - case 59: + case 58: /* Line 1806 of yacc.c */ -#line 982 "awkgram.y" +#line 949 "awkgram.y" { sub_counter = 0; } break; - case 60: + case 59: /* Line 1806 of yacc.c */ -#line 983 "awkgram.y" +#line 950 "awkgram.y" { char *arr = (yyvsp[(2) - (4)])->lextok; (yyvsp[(2) - (4)])->opcode = Op_push_array; - (yyvsp[(2) - (4)])->memory = variable(arr, Node_var_new); + (yyvsp[(2) - (4)])->memory = variable((yyvsp[(2) - (4)])->source_line, arr, Node_var_new); if ((yyvsp[(4) - (4)]) == NULL) { static short warned = FALSE; @@ -3049,10 +3011,10 @@ regular_loop: } break; - case 61: + case 60: /* Line 1806 of yacc.c */ -#line 1012 "awkgram.y" +#line 979 "awkgram.y" { static short warned = FALSE; char *arr = (yyvsp[(3) - (4)])->lextok; @@ -3066,45 +3028,45 @@ regular_loop: error_ln((yyvsp[(1) - (4)])->source_line, _("`delete array' is a gawk extension")); } - (yyvsp[(3) - (4)])->memory = variable(arr, Node_var_new); + (yyvsp[(3) - (4)])->memory = variable((yyvsp[(3) - (4)])->source_line, arr, Node_var_new); (yyvsp[(3) - (4)])->opcode = Op_push_array; (yyvsp[(1) - (4)])->expr_count = 0; (yyval) = list_append(list_create((yyvsp[(3) - (4)])), (yyvsp[(1) - (4)])); } break; - case 62: + case 61: /* Line 1806 of yacc.c */ -#line 1031 "awkgram.y" +#line 998 "awkgram.y" { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } break; - case 63: + case 62: /* Line 1806 of yacc.c */ -#line 1036 "awkgram.y" +#line 1003 "awkgram.y" { (yyval) = NULL; } break; - case 64: + case 63: /* Line 1806 of yacc.c */ -#line 1038 "awkgram.y" +#line 1005 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 65: + case 64: /* Line 1806 of yacc.c */ -#line 1043 "awkgram.y" +#line 1010 "awkgram.y" { (yyval) = NULL; } break; - case 66: + case 65: /* Line 1806 of yacc.c */ -#line 1045 "awkgram.y" +#line 1012 "awkgram.y" { if ((yyvsp[(1) - (2)]) == NULL) (yyval) = list_create((yyvsp[(2) - (2)])); @@ -3113,22 +3075,22 @@ regular_loop: } break; - case 67: + case 66: /* Line 1806 of yacc.c */ -#line 1052 "awkgram.y" +#line 1019 "awkgram.y" { (yyval) = NULL; } break; - case 68: + case 67: /* Line 1806 of yacc.c */ -#line 1057 "awkgram.y" +#line 1024 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); if ((yyvsp[(5) - (5)]) == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); (yyvsp[(1) - (5)])->case_exp = (yyvsp[(2) - (5)]); (yyvsp[(1) - (5)])->case_stmt = casestmt; @@ -3137,15 +3099,15 @@ regular_loop: } break; - case 69: + case 68: /* Line 1806 of yacc.c */ -#line 1069 "awkgram.y" +#line 1036 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); if ((yyvsp[(4) - (4)]) == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); bcfree((yyvsp[(2) - (4)])); (yyvsp[(1) - (4)])->case_stmt = casestmt; @@ -3153,17 +3115,17 @@ regular_loop: } break; - case 70: + case 69: /* Line 1806 of yacc.c */ -#line 1083 "awkgram.y" +#line 1050 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 71: + case 70: /* Line 1806 of yacc.c */ -#line 1085 "awkgram.y" +#line 1052 "awkgram.y" { (yyvsp[(2) - (2)])->memory->numbr = -(force_number((yyvsp[(2) - (2)])->memory)); bcfree((yyvsp[(1) - (2)])); @@ -3171,60 +3133,60 @@ regular_loop: } break; - case 72: + case 71: /* Line 1806 of yacc.c */ -#line 1091 "awkgram.y" +#line 1058 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); } break; - case 73: + case 72: /* Line 1806 of yacc.c */ -#line 1096 "awkgram.y" +#line 1063 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 74: + case 73: /* Line 1806 of yacc.c */ -#line 1098 "awkgram.y" +#line 1065 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_push_re; (yyval) = (yyvsp[(1) - (1)]); } break; - case 75: + case 74: /* Line 1806 of yacc.c */ -#line 1106 "awkgram.y" +#line 1073 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 76: + case 75: /* Line 1806 of yacc.c */ -#line 1108 "awkgram.y" +#line 1075 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 78: + case 77: /* Line 1806 of yacc.c */ -#line 1118 "awkgram.y" +#line 1085 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; - case 79: + case 78: /* Line 1806 of yacc.c */ -#line 1125 "awkgram.y" +#line 1092 "awkgram.y" { in_print = FALSE; in_parens = 0; @@ -3232,17 +3194,17 @@ regular_loop: } break; - case 80: + case 79: /* Line 1806 of yacc.c */ -#line 1130 "awkgram.y" +#line 1097 "awkgram.y" { in_print = FALSE; in_parens = 0; } break; - case 81: + case 80: /* Line 1806 of yacc.c */ -#line 1131 "awkgram.y" +#line 1098 "awkgram.y" { if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir @@ -3252,162 +3214,174 @@ regular_loop: } break; - case 82: + case 81: /* Line 1806 of yacc.c */ -#line 1142 "awkgram.y" +#line 1109 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); } break; - case 83: + case 82: /* Line 1806 of yacc.c */ -#line 1147 "awkgram.y" +#line 1114 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); } break; - case 88: + case 87: /* Line 1806 of yacc.c */ -#line 1164 "awkgram.y" +#line 1131 "awkgram.y" { (yyval) = NULL; } break; - case 89: + case 88: /* Line 1806 of yacc.c */ -#line 1166 "awkgram.y" +#line 1133 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); } break; - case 92: + case 89: + +/* Line 1806 of yacc.c */ +#line 1141 "awkgram.y" + { (yyval) = NULL; } + break; + + case 90: /* Line 1806 of yacc.c */ -#line 1179 "awkgram.y" +#line 1143 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]) ; } + break; + + case 91: + +/* Line 1806 of yacc.c */ +#line 1148 "awkgram.y" { - append_param((yyvsp[(1) - (1)])->lextok); - (yyvsp[(1) - (1)])->lextok = NULL; - bcfree((yyvsp[(1) - (1)])); + (yyvsp[(1) - (1)])->param_count = 0; + (yyval) = list_create((yyvsp[(1) - (1)])); } break; - case 93: + case 92: /* Line 1806 of yacc.c */ -#line 1185 "awkgram.y" +#line 1153 "awkgram.y" { - append_param((yyvsp[(3) - (3)])->lextok); - (yyvsp[(3) - (3)])->lextok = NULL; - bcfree((yyvsp[(3) - (3)])); + (yyvsp[(3) - (3)])->param_count = (yyvsp[(1) - (3)])->lasti->param_count + 1; + (yyval) = list_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; } break; - case 94: + case 93: /* Line 1806 of yacc.c */ -#line 1192 "awkgram.y" - { /* func_params = NULL; */ } +#line 1159 "awkgram.y" + { (yyval) = NULL; } break; - case 95: + case 94: /* Line 1806 of yacc.c */ -#line 1194 "awkgram.y" - { /* func_params = NULL; */ } +#line 1161 "awkgram.y" + { (yyval) = (yyvsp[(1) - (2)]); } break; - case 96: + case 95: /* Line 1806 of yacc.c */ -#line 1196 "awkgram.y" - { /* func_params = NULL; */ } +#line 1163 "awkgram.y" + { (yyval) = (yyvsp[(1) - (3)]); } break; - case 97: + case 96: /* Line 1806 of yacc.c */ -#line 1202 "awkgram.y" +#line 1169 "awkgram.y" { (yyval) = NULL; } break; - case 98: + case 97: /* Line 1806 of yacc.c */ -#line 1204 "awkgram.y" +#line 1171 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 99: + case 98: /* Line 1806 of yacc.c */ -#line 1209 "awkgram.y" +#line 1176 "awkgram.y" { (yyval) = NULL; } break; - case 100: + case 99: /* Line 1806 of yacc.c */ -#line 1211 "awkgram.y" +#line 1178 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 101: + case 100: /* Line 1806 of yacc.c */ -#line 1216 "awkgram.y" +#line 1183 "awkgram.y" { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } break; - case 102: + case 101: /* Line 1806 of yacc.c */ -#line 1218 "awkgram.y" +#line 1185 "awkgram.y" { (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; } break; - case 103: + case 102: /* Line 1806 of yacc.c */ -#line 1223 "awkgram.y" +#line 1190 "awkgram.y" { (yyval) = NULL; } break; - case 104: + case 103: /* Line 1806 of yacc.c */ -#line 1225 "awkgram.y" +#line 1192 "awkgram.y" { (yyval) = NULL; } break; - case 105: + case 104: /* Line 1806 of yacc.c */ -#line 1227 "awkgram.y" +#line 1194 "awkgram.y" { (yyval) = NULL; } break; - case 106: + case 105: /* Line 1806 of yacc.c */ -#line 1229 "awkgram.y" +#line 1196 "awkgram.y" { (yyval) = NULL; } break; - case 107: + case 106: /* Line 1806 of yacc.c */ -#line 1235 "awkgram.y" +#line 1202 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3416,24 +3390,24 @@ regular_loop: } break; - case 108: + case 107: /* Line 1806 of yacc.c */ -#line 1242 "awkgram.y" +#line 1209 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; - case 109: + case 108: /* Line 1806 of yacc.c */ -#line 1244 "awkgram.y" +#line 1211 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; - case 110: + case 109: /* Line 1806 of yacc.c */ -#line 1246 "awkgram.y" +#line 1213 "awkgram.y" { if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3451,13 +3425,13 @@ regular_loop: } break; - case 111: + case 110: /* Line 1806 of yacc.c */ -#line 1262 "awkgram.y" +#line 1229 "awkgram.y" { if (do_lint_old) - warning_ln((yyvsp[(2) - (3)])->source_line, + warning_ln((yyvsp[(2) - (3)])->source_line, _("old awk does not support the keyword `in' except after `for'")); (yyvsp[(3) - (3)])->nexti->opcode = Op_push_array; (yyvsp[(2) - (3)])->opcode = Op_in_array; @@ -3466,10 +3440,10 @@ regular_loop: } break; - case 112: + case 111: /* Line 1806 of yacc.c */ -#line 1272 "awkgram.y" +#line 1239 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3478,90 +3452,90 @@ regular_loop: } break; - case 113: + case 112: /* Line 1806 of yacc.c */ -#line 1279 "awkgram.y" +#line 1246 "awkgram.y" { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } break; - case 114: + case 113: /* Line 1806 of yacc.c */ -#line 1281 "awkgram.y" +#line 1248 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 115: + case 114: /* Line 1806 of yacc.c */ -#line 1286 "awkgram.y" +#line 1253 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 116: + case 115: /* Line 1806 of yacc.c */ -#line 1288 "awkgram.y" +#line 1255 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 117: + case 116: /* Line 1806 of yacc.c */ -#line 1290 "awkgram.y" +#line 1257 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; (yyval) = (yyvsp[(2) - (2)]); } break; + case 117: + +/* Line 1806 of yacc.c */ +#line 1265 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + case 118: /* Line 1806 of yacc.c */ -#line 1298 "awkgram.y" +#line 1267 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 119: /* Line 1806 of yacc.c */ -#line 1300 "awkgram.y" +#line 1272 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 120: /* Line 1806 of yacc.c */ -#line 1305 "awkgram.y" +#line 1274 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 121: /* Line 1806 of yacc.c */ -#line 1307 "awkgram.y" +#line 1279 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 122: /* Line 1806 of yacc.c */ -#line 1312 "awkgram.y" +#line 1281 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 123: /* Line 1806 of yacc.c */ -#line 1314 "awkgram.y" - { (yyval) = (yyvsp[(1) - (1)]); } - break; - - case 124: - -/* Line 1806 of yacc.c */ -#line 1316 "awkgram.y" +#line 1283 "awkgram.y" { int count = 2; int is_simple_var = FALSE; @@ -3573,32 +3547,29 @@ regular_loop: (yyvsp[(1) - (2)])->lasti->opcode = Op_no_op; } else { is_simple_var = ((yyvsp[(1) - (2)])->nexti->opcode == Op_push - && (yyvsp[(1) - (2)])->lasti == (yyvsp[(1) - (2)])->nexti); /* first exp. is a simple - * variable?; kludge for use - * in Op_assign_concat. - */ + && (yyvsp[(1) - (2)])->lasti == (yyvsp[(1) - (2)])->nexti); /* first exp. is a simple + * variable?; kludge for use + * in Op_assign_concat. + */ } if (do_optimize > 1 - && (yyvsp[(1) - (2)])->nexti == (yyvsp[(1) - (2)])->lasti && (yyvsp[(1) - (2)])->nexti->opcode == Op_push_i - && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i + && (yyvsp[(1) - (2)])->nexti == (yyvsp[(1) - (2)])->lasti && (yyvsp[(1) - (2)])->nexti->opcode == Op_push_i + && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i ) { NODE *n1 = (yyvsp[(1) - (2)])->nexti->memory; NODE *n2 = (yyvsp[(2) - (2)])->nexti->memory; size_t nlen; - (void) force_string(n1); - (void) force_string(n2); + n1 = force_string(n1); + n2 = force_string(n2); nlen = n1->stlen + n2->stlen; erealloc(n1->stptr, char *, nlen + 2, "constant fold"); memcpy(n1->stptr + n1->stlen, n2->stptr, n2->stlen); n1->stlen = nlen; n1->stptr[nlen] = '\0'; - n1->flags &= ~(NUMCUR|NUMBER); + n1->flags &= ~(NUMCUR|NUMBER|NUMINT); n1->flags |= (STRING|STRCUR); - - n2->flags &= ~PERM; - n2->flags |= MALLOC; unref(n2); bcfree((yyvsp[(2) - (2)])->nexti); bcfree((yyvsp[(2) - (2)])); @@ -3613,52 +3584,52 @@ regular_loop: } break; + case 125: + +/* Line 1806 of yacc.c */ +#line 1335 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + case 126: /* Line 1806 of yacc.c */ -#line 1371 "awkgram.y" +#line 1337 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 127: /* Line 1806 of yacc.c */ -#line 1373 "awkgram.y" +#line 1339 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 128: /* Line 1806 of yacc.c */ -#line 1375 "awkgram.y" +#line 1341 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 129: /* Line 1806 of yacc.c */ -#line 1377 "awkgram.y" +#line 1343 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 130: /* Line 1806 of yacc.c */ -#line 1379 "awkgram.y" +#line 1345 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 131: /* Line 1806 of yacc.c */ -#line 1381 "awkgram.y" - { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } - break; - - case 132: - -/* Line 1806 of yacc.c */ -#line 1383 "awkgram.y" +#line 1347 "awkgram.y" { /* * In BEGINFILE/ENDFILE, allow `getline var < file' @@ -3683,30 +3654,30 @@ regular_loop: } break; - case 133: + case 132: /* Line 1806 of yacc.c */ -#line 1406 "awkgram.y" +#line 1370 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); } break; - case 134: + case 133: /* Line 1806 of yacc.c */ -#line 1411 "awkgram.y" +#line 1375 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); } break; - case 135: + case 134: /* Line 1806 of yacc.c */ -#line 1416 "awkgram.y" +#line 1380 "awkgram.y" { if (do_lint_old) { warning_ln((yyvsp[(4) - (5)])->source_line, @@ -3728,81 +3699,81 @@ regular_loop: } break; - case 136: + case 135: /* Line 1806 of yacc.c */ -#line 1441 "awkgram.y" +#line 1405 "awkgram.y" { (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); bcfree((yyvsp[(2) - (4)])); } break; + case 136: + +/* Line 1806 of yacc.c */ +#line 1411 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + case 137: /* Line 1806 of yacc.c */ -#line 1447 "awkgram.y" +#line 1413 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 138: /* Line 1806 of yacc.c */ -#line 1449 "awkgram.y" +#line 1415 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 139: /* Line 1806 of yacc.c */ -#line 1451 "awkgram.y" +#line 1417 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 140: /* Line 1806 of yacc.c */ -#line 1453 "awkgram.y" +#line 1419 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 141: /* Line 1806 of yacc.c */ -#line 1455 "awkgram.y" +#line 1421 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 142: /* Line 1806 of yacc.c */ -#line 1457 "awkgram.y" - { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } - break; - - case 143: - -/* Line 1806 of yacc.c */ -#line 1462 "awkgram.y" +#line 1426 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } break; - case 144: + case 143: /* Line 1806 of yacc.c */ -#line 1466 "awkgram.y" +#line 1430 "awkgram.y" { if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { (yyvsp[(2) - (2)])->opcode = Op_nomatch; (yyvsp[(1) - (2)])->opcode = Op_push_i; - (yyvsp[(1) - (2)])->memory = mk_number(0.0, (PERM|NUMCUR|NUMBER)); + (yyvsp[(1) - (2)])->memory = make_number(0.0); (yyval) = list_append(list_append(list_create((yyvsp[(1) - (2)])), - instruction(Op_field_spec)), (yyvsp[(2) - (2)])); + instruction(Op_field_spec)), (yyvsp[(2) - (2)])); } else { if (do_optimize > 1 && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti - && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i + && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i ) { NODE *n = (yyvsp[(2) - (2)])->nexti->memory; if ((n->flags & (STRCUR|STRING)) != 0) { @@ -3825,17 +3796,17 @@ regular_loop: } break; - case 145: + case 144: /* Line 1806 of yacc.c */ -#line 1497 "awkgram.y" +#line 1461 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; - case 146: + case 145: /* Line 1806 of yacc.c */ -#line 1499 "awkgram.y" +#line 1463 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3843,10 +3814,10 @@ regular_loop: } break; - case 147: + case 146: /* Line 1806 of yacc.c */ -#line 1505 "awkgram.y" +#line 1469 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3854,10 +3825,10 @@ regular_loop: } break; - case 148: + case 147: /* Line 1806 of yacc.c */ -#line 1511 "awkgram.y" +#line 1475 "awkgram.y" { static short warned1 = FALSE; @@ -3872,51 +3843,52 @@ regular_loop: } break; - case 151: + case 150: /* Line 1806 of yacc.c */ -#line 1526 "awkgram.y" +#line 1490 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); } break; - case 152: + case 151: /* Line 1806 of yacc.c */ -#line 1531 "awkgram.y" +#line 1495 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); } break; - case 153: + case 152: /* Line 1806 of yacc.c */ -#line 1536 "awkgram.y" +#line 1500 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } break; - case 154: + case 153: /* Line 1806 of yacc.c */ -#line 1540 "awkgram.y" +#line 1504 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } break; - case 155: + case 154: /* Line 1806 of yacc.c */ -#line 1544 "awkgram.y" +#line 1508 "awkgram.y" { if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i - && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0) { + && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0 + ) { (yyvsp[(2) - (2)])->lasti->memory->numbr = -(force_number((yyvsp[(2) - (2)])->lasti->memory)); (yyval) = (yyvsp[(2) - (2)]); bcfree((yyvsp[(1) - (2)])); @@ -3927,35 +3899,35 @@ regular_loop: } break; - case 156: + case 155: /* Line 1806 of yacc.c */ -#line 1556 "awkgram.y" +#line 1521 "awkgram.y" { /* * was: $$ = $2 * POSIX semantics: force a conversion to numeric type */ (yyvsp[(1) - (2)])->opcode = Op_plus_i; - (yyvsp[(1) - (2)])->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (yyvsp[(1) - (2)])->memory = make_number(0.0); (yyval) = list_append((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); } break; - case 157: + case 156: /* Line 1806 of yacc.c */ -#line 1569 "awkgram.y" +#line 1534 "awkgram.y" { func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[(1) - (1)]); } break; - case 158: + case 157: /* Line 1806 of yacc.c */ -#line 1574 "awkgram.y" +#line 1539 "awkgram.y" { /* indirect function call */ INSTRUCTION *f, *t; @@ -3976,7 +3948,7 @@ regular_loop: name = estrdup(f->func_name, strlen(f->func_name)); if (is_std_var(name)) yyerror(_("can not use special variable `%s' for indirect function call"), name); - indirect_var = variable(name, Node_var_new); + indirect_var = variable(f->source_line, name, Node_var_new); t = instruction(Op_push); t->memory = indirect_var; @@ -3990,10 +3962,10 @@ regular_loop: } break; - case 159: + case 158: /* Line 1806 of yacc.c */ -#line 1610 "awkgram.y" +#line 1575 "awkgram.y" { param_sanity((yyvsp[(3) - (4)])); (yyvsp[(1) - (4)])->opcode = Op_func_call; @@ -4009,54 +3981,54 @@ regular_loop: } break; - case 160: + case 159: /* Line 1806 of yacc.c */ -#line 1627 "awkgram.y" +#line 1592 "awkgram.y" { (yyval) = NULL; } break; - case 161: + case 160: /* Line 1806 of yacc.c */ -#line 1629 "awkgram.y" +#line 1594 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 162: + case 161: /* Line 1806 of yacc.c */ -#line 1634 "awkgram.y" +#line 1599 "awkgram.y" { (yyval) = NULL; } break; - case 163: + case 162: /* Line 1806 of yacc.c */ -#line 1636 "awkgram.y" +#line 1601 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; - case 164: + case 163: /* Line 1806 of yacc.c */ -#line 1641 "awkgram.y" +#line 1606 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 165: + case 164: /* Line 1806 of yacc.c */ -#line 1643 "awkgram.y" +#line 1608 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } break; - case 166: + case 165: /* Line 1806 of yacc.c */ -#line 1650 "awkgram.y" +#line 1615 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -4072,10 +4044,10 @@ regular_loop: } break; - case 167: + case 166: /* Line 1806 of yacc.c */ -#line 1667 "awkgram.y" +#line 1632 "awkgram.y" { INSTRUCTION *t = (yyvsp[(2) - (3)]); if ((yyvsp[(2) - (3)]) == NULL) { @@ -4083,7 +4055,7 @@ regular_loop: _("invalid subscript expression")); /* install Null string as subscript. */ t = list_create(instruction(Op_push_i)); - t->nexti->memory = Nnull_string; + t->nexti->memory = dupnode(Nnull_string); (yyvsp[(3) - (3)])->sub_count = 1; } else (yyvsp[(3) - (3)])->sub_count = count_expressions(&t, FALSE); @@ -4091,67 +4063,63 @@ regular_loop: } break; - case 168: + case 167: /* Line 1806 of yacc.c */ -#line 1684 "awkgram.y" +#line 1649 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 169: + case 168: /* Line 1806 of yacc.c */ -#line 1686 "awkgram.y" +#line 1651 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } break; - case 170: + case 169: /* Line 1806 of yacc.c */ -#line 1693 "awkgram.y" +#line 1658 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; - case 171: + case 170: /* Line 1806 of yacc.c */ -#line 1698 "awkgram.y" +#line 1663 "awkgram.y" { char *var_name = (yyvsp[(1) - (1)])->lextok; (yyvsp[(1) - (1)])->opcode = Op_push; - (yyvsp[(1) - (1)])->memory = variable(var_name, Node_var_new); + (yyvsp[(1) - (1)])->memory = variable((yyvsp[(1) - (1)])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[(1) - (1)])); } break; - case 172: + case 171: /* Line 1806 of yacc.c */ -#line 1706 "awkgram.y" +#line 1671 "awkgram.y" { - NODE *n; - char *arr = (yyvsp[(1) - (2)])->lextok; - if ((n = lookup(arr)) != NULL && ! isarray(n)) - yyerror(_("use of non-array as array")); - (yyvsp[(1) - (2)])->memory = variable(arr, Node_var_new); + (yyvsp[(1) - (2)])->memory = variable((yyvsp[(1) - (2)])->source_line, arr, Node_var_new); (yyvsp[(1) - (2)])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); } break; - case 173: + case 172: /* Line 1806 of yacc.c */ -#line 1720 "awkgram.y" +#line 1681 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; if (ip->opcode == Op_push - && ip->memory->type == Node_var - && ip->memory->var_update + && ip->memory->type == Node_var + && ip->memory->var_update ) { (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_var_update)); (yyval)->nexti->update_var = ip->memory->var_update; @@ -4160,81 +4128,81 @@ regular_loop: } break; - case 174: + case 173: /* Line 1806 of yacc.c */ -#line 1732 "awkgram.y" +#line 1693 "awkgram.y" { (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); if ((yyvsp[(3) - (3)]) != NULL) - mk_assignment((yyvsp[(2) - (3)]), NULL, (yyvsp[(3) - (3)])); + mk_assignment((yyvsp[(2) - (3)]), NULL, (yyvsp[(3) - (3)])); } break; - case 175: + case 174: /* Line 1806 of yacc.c */ -#line 1741 "awkgram.y" +#line 1702 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postincrement; } break; - case 176: + case 175: /* Line 1806 of yacc.c */ -#line 1745 "awkgram.y" +#line 1706 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postdecrement; } break; - case 177: + case 176: /* Line 1806 of yacc.c */ -#line 1748 "awkgram.y" +#line 1709 "awkgram.y" { (yyval) = NULL; } break; - case 179: + case 178: /* Line 1806 of yacc.c */ -#line 1756 "awkgram.y" +#line 1717 "awkgram.y" { yyerrok; } break; - case 180: + case 179: /* Line 1806 of yacc.c */ -#line 1760 "awkgram.y" +#line 1721 "awkgram.y" { yyerrok; } break; - case 183: + case 182: /* Line 1806 of yacc.c */ -#line 1769 "awkgram.y" +#line 1730 "awkgram.y" { yyerrok; } break; - case 184: + case 183: /* Line 1806 of yacc.c */ -#line 1773 "awkgram.y" +#line 1734 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } break; - case 185: + case 184: /* Line 1806 of yacc.c */ -#line 1777 "awkgram.y" +#line 1738 "awkgram.y" { yyerrok; } break; /* Line 1806 of yacc.c */ -#line 4250 "awkgram.c" +#line 4218 "awkgram.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4465,7 +4433,7 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 1779 "awkgram.y" +#line 1740 "awkgram.y" struct token { @@ -4513,9 +4481,12 @@ static const struct token tokentab[] = { {"END", Op_rule, LEX_END, 0, 0}, {"ENDFILE", Op_rule, LEX_ENDFILE, GAWKX, 0}, #ifdef ARRAYDEBUG -{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_adump}, +{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_adump}, #endif {"and", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_and}, +#ifdef ARRAYDEBUG +{"aoption", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_aoption}, +#endif {"asort", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asort}, {"asorti", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asorti}, {"atan2", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2}, @@ -4568,9 +4539,6 @@ static const struct token tokentab[] = { {"sprintf", Op_builtin, LEX_BUILTIN, 0, do_sprintf}, {"sqrt", Op_builtin, LEX_BUILTIN, A(1), do_sqrt}, {"srand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand}, -#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) /* || ... */ -{"stopme", Op_builtin, LEX_BUILTIN, GAWKX|A(0), stopme}, -#endif {"strftime", Op_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2)|A(3), do_strftime}, {"strtonum", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum}, {"sub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0}, @@ -4640,7 +4608,7 @@ print_included_from() line--; msg("%s %s:%d%c", s->prev == sourcefile ? "In file included from" - : " from", + : " from", (s->stype == SRC_INC || s->stype == SRC_FILE) ? s->src : "cmd. line", line, @@ -4922,7 +4890,10 @@ parse_program(INSTRUCTION **pcode) ip_atexit = instruction(Op_atexit); /* target for `exit' in END block */ } - sourcefile = srcfiles->next; + for (sourcefile = srcfiles->next; sourcefile->stype == SRC_EXTLIB; + sourcefile = sourcefile->next) + ; + lexeof = FALSE; lexptr = NULL; lasttok = 0; @@ -4939,6 +4910,11 @@ parse_program(INSTRUCTION **pcode) if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ check_funcs(); + if (args_array == NULL) + emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + else + erealloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + return (ret || errcount); } @@ -4981,7 +4957,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int if (stype == SRC_CMDLINE || stype == SRC_STDIN) return do_add_srcfile(stype, src, NULL, thisfile); - path = find_source(src, &sbuf, &errno_val); + path = find_source(src, & sbuf, &errno_val, stype == SRC_EXTLIB); if (path == NULL) { if (errcode) { *errcode = errno_val; @@ -4992,7 +4968,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int } for (s = srcfiles->next; s != srcfiles; s = s->next) { - if ((s->stype == SRC_FILE || s->stype == SRC_INC) + if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == SRC_EXTLIB) && files_are_same(path, s) ) { if (do_lint) { @@ -5094,6 +5070,7 @@ next_sourcefile() * * assert(lexeof == TRUE); */ + lexeof = FALSE; eof_warned = FALSE; sourcefile->srclines = sourceline; /* total no of lines in current file */ @@ -5108,9 +5085,12 @@ next_sourcefile() sourcefile->lexptr_begin = NULL; } - sourcefile = sourcefile->next; - if (sourcefile == srcfiles) - return; + while ((sourcefile = sourcefile->next) != NULL) { + if (sourcefile == srcfiles) + return; + if (sourcefile->stype != SRC_EXTLIB) + break; + } if (sourcefile->lexptr_begin != NULL) { /* resume reading from already opened file (postponed to process '@include') */ @@ -5484,6 +5464,7 @@ yylex(void) char *tokkey; int inhex = FALSE; int intlstr = FALSE; + AWKNUM d; #define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline) @@ -5922,9 +5903,7 @@ retry: yylval->opcode = Op_push_i; yylval->memory = make_str_node(tokstart, - tok - tokstart, esc_seen ? SCAN : 0); - yylval->memory->flags &= ~MALLOC; - yylval->memory->flags |= PERM; + tok - tokstart, esc_seen ? SCAN : 0); if (intlstr) { yylval->memory->flags |= INTLSTR; intlstr = FALSE; @@ -6066,10 +6045,12 @@ retry: lintwarn("numeric constant `%.*s' treated as hexadecimal", (int) strlen(tokstart)-1, tokstart); } - yylval->memory = mk_number(nondec2awknum(tokstart, strlen(tokstart)), - PERM|NUMCUR|NUMBER); + d = nondec2awknum(tokstart, strlen(tokstart)); } else - yylval->memory = mk_number(atof(tokstart), PERM|NUMCUR|NUMBER); + d = atof(tokstart); + yylval->memory = make_number(d); + if (d <= INT32_MAX && d >= INT32_MIN && d == (int32_t) d) + yylval->memory->flags |= NUMINT; return lasttok = YNUMBER; case '&': @@ -6206,7 +6187,7 @@ retry: case LEX_WHILE: case LEX_DO: case LEX_SWITCH: - if (! do_profiling) + if (! do_pretty_print) return lasttok = class; /* fall through */ case LEX_CASE: @@ -6246,23 +6227,6 @@ out: #undef NEWLINE_EOF } -/* mk_symbol --- allocates a symbol for the symbol table. */ - -NODE * -mk_symbol(NODETYPE type, NODE *value) -{ - NODE *r; - - getnode(r); - r->type = type; - r->flags = MALLOC; - r->lnode = value; - r->rnode = NULL; - r->parent_array = NULL; - r->var_assign = (Func_ptr) 0; - return r; -} - /* snode --- instructions for builtin functions. Checks for arg. count and supplies defaults where possible. */ @@ -6314,7 +6278,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) INSTRUCTION *expr; expr = list_create(instruction(Op_push_i)); - expr->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + expr->nexti->memory = make_number(0.0); (void) mk_expression_list(subn, list_append(expr, instruction(Op_field_spec))); } @@ -6358,7 +6322,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) r->sub_flags |= GENSUB; if (nexp == 3) { ip = instruction(Op_push_i); - ip->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + ip->memory = make_number(0.0); (void) mk_expression_list(subn, list_append(list_create(ip), instruction(Op_field_spec))); } @@ -6381,7 +6345,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) list = list_create(r); (void) list_prepend(list, instruction(Op_field_spec)); (void) list_prepend(list, instruction(Op_push_i)); - list->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + list->nexti->memory = make_number(0.0); return list; } else { arg = subn->nexti; @@ -6509,7 +6473,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) if (ip->opcode == Op_push) ip->opcode = Op_push_array; } -#endif +#endif if (subn != NULL) { r->expr_count = count_expressions(&subn, FALSE); @@ -6520,75 +6484,6 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) return list_create(r); } -/* append_param --- append PNAME to the list of parameters - * for the current function. - */ - -static void -append_param(char *pname) -{ - static NODE *savetail = NULL; - NODE *p; - - p = make_param(pname); - if (func_params == NULL) { - func_params = p; - savetail = p; - } else if (savetail != NULL) { - savetail->rnode = p; - savetail = p; - } -} - -/* dup_parms --- return TRUE if there are duplicate parameters */ - -static int -dup_parms(INSTRUCTION *fp, NODE *func) -{ - NODE *np; - const char *fname, **names; - int count, i, j, dups; - NODE *params; - - if (func == NULL) /* error earlier */ - return TRUE; - - fname = func->param; - count = func->param_cnt; - params = func->rnode; - - if (count == 0) /* no args, no problem */ - return FALSE; - - if (params == NULL) /* error earlier */ - return TRUE; - - emalloc(names, const char **, count * sizeof(char *), "dup_parms"); - - i = 0; - for (np = params; np != NULL; np = np->rnode) { - if (np->param == NULL) { /* error earlier, give up, go home */ - efree(names); - return TRUE; - } - 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_ln(fp->source_line, - _("function `%s': parameter #%d, `%s', duplicates parameter #%d"), - fname, i + 1, names[j], j+1); - } - } - } - - efree(names); - return (dups > 0 ? TRUE : FALSE); -} /* parms_shadow --- check if parameters shadow globals */ @@ -6597,18 +6492,19 @@ parms_shadow(INSTRUCTION *pc, int *shadow) { int pcount, i; int ret = FALSE; - NODE *func; + NODE *func, *fp; char *fname; func = pc->func_body; - fname = func->lnode->param; - + fname = func->vname; + fp = func->fparms; + #if 0 /* can't happen, already exited if error ? */ if (fname == NULL || func == NULL) /* error earlier */ return FALSE; #endif - pcount = func->lnode->param_cnt; + pcount = func->param_cnt; if (pcount == 0) /* no args, no problem */ return 0; @@ -6620,10 +6516,10 @@ parms_shadow(INSTRUCTION *pc, int *shadow) * about all shadowed parameters. */ for (i = 0; i < pcount; i++) { - if (lookup(func->parmlist[i]) != NULL) { + if (lookup(fp[i].param) != NULL) { warning( _("function `%s': parameter `%s' shadows global variable"), - fname, func->parmlist[i]); + fname, fp[i].param); ret = TRUE; } } @@ -6632,80 +6528,10 @@ parms_shadow(INSTRUCTION *pc, int *shadow) return 0; } - -/* - * install_symbol: - * Install a name in the symbol table, even if it is already there. - * Caller must check against redefinition if that is desired. - */ - - -NODE * -install_symbol(char *name, NODE *value) -{ - NODE *hp; - size_t len; - int bucket; - - if (install_func) - (*install_func)(name); - - var_count++; - len = strlen(name); - bucket = hash(name, len, (unsigned long) HASHSIZE, NULL); - 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; -} - -/* lookup --- find the most recent hash node for name installed by install_symbol */ - -NODE * -lookup(const char *name) -{ - NODE *bucket; - size_t len; - - len = strlen(name); - for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]; - bucket != NULL; bucket = bucket->hnext) - if (bucket->hlength == len && strncmp(bucket->hname, name, len) == 0) - return bucket->hvalue; - return NULL; -} - -/* sym_comp --- compare two symbol (variable or function) names */ - -static int -sym_comp(const void *v1, const void *v2) -{ - const NODE *const *npp1, *const *npp2; - const NODE *n1, *n2; - int minlen; - - npp1 = (const NODE *const *) v1; - npp2 = (const NODE *const *) v2; - n1 = *npp1; - n2 = *npp2; - - if (n1->hlength > n2->hlength) - minlen = n1->hlength; - else - minlen = n2->hlength; - - return strncmp(n1->hname, n2->hname, minlen); -} - /* valinfo --- dump var info */ void -valinfo(NODE *n, int (*print_func)(FILE *, const char *, ...), FILE *fp) +valinfo(NODE *n, Func_print print_func, FILE *fp) { if (n == Nnull_string) print_func(fp, "uninitialized scalar\n"); @@ -6723,52 +6549,6 @@ valinfo(NODE *n, int (*print_func)(FILE *, const char *, ...), FILE *fp) print_func(fp, "?? flags %s\n", flags2str(n->flags)); } -/* get_varlist --- list of global variables */ - -NODE ** -get_varlist() -{ - int i, j; - NODE **table; - NODE *p; - - emalloc(table, NODE **, (var_count + 1) * sizeof(NODE *), "get_varlist"); - update_global_values(); - for (i = j = 0; i < HASHSIZE; i++) - for (p = variables[i]; p != NULL; p = p->hnext) - table[j++] = p; - assert(j == var_count); - - /* Shazzam! */ - qsort(table, j, sizeof(NODE *), sym_comp); - - table[j] = NULL; - return table; -} - -/* print_vars --- print names and values of global variables */ - -void -print_vars(int (*print_func)(FILE *, const char *, ...), FILE *fp) -{ - int i; - NODE **table; - NODE *p; - - table = get_varlist(); - for (i = 0; (p = table[i]) != NULL; i++) { - if (p->hvalue->type == Node_func) - continue; - print_func(fp, "%.*s: ", (int) p->hlength, p->hname); - if (p->hvalue->type == Node_var_array) - print_func(fp, "array, %ld elements\n", p->hvalue->table_size); - else if (p->hvalue->type == Node_var_new) - print_func(fp, "untyped variable\n"); - else if (p->hvalue->type == Node_var) - valinfo(p->hvalue->var_value, print_func, fp); - } - efree(table); -} /* dump_vars --- dump the symbol table */ @@ -6776,6 +6556,7 @@ void dump_vars(const char *fname) { FILE *fp; + NODE **vars; if (fname == NULL) fp = stderr; @@ -6785,48 +6566,25 @@ dump_vars(const char *fname) fp = stderr; } - print_vars(fprintf, fp); + vars = variable_list(); + print_vars(vars, fprintf, fp); + efree(vars); if (fp != stderr && fclose(fp) != 0) warning(_("%s: close failed (%s)"), fname, strerror(errno)); } -/* release_all_vars --- free all variable memory */ - -void -release_all_vars() -{ - int i; - NODE *p, *next; - - for (i = 0; i < HASHSIZE; i++) { - for (p = variables[i]; p != NULL; p = next) { - next = p->hnext; - - if (p->hvalue->type == Node_func) - continue; - else if (p->hvalue->type == Node_var_array) - assoc_clear(p->hvalue); - else if (p->hvalue->type != Node_var_new) - unref(p->hvalue->var_value); - - efree(p->hname); - freenode(p->hvalue); - freenode(p); - } - } -} - /* dump_funcs --- print all functions */ void dump_funcs() { - if (func_count <= 0) - return; - - (void) foreach_func((int (*)(INSTRUCTION *, void *)) pp_func, TRUE, (void *) 0); + NODE **funcs; + funcs = function_list(TRUE); + (void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) pp_func, (void *) 0); + efree(funcs); } + /* shadow_funcs --- check all functions for parameters that shadow globals */ void @@ -6834,175 +6592,164 @@ shadow_funcs() { static int calls = 0; int shadow = FALSE; - - if (func_count <= 0) - return; + NODE **funcs; if (calls++ != 0) fatal(_("shadow_funcs() called twice!")); - (void) foreach_func((int (*)(INSTRUCTION *, void *)) parms_shadow, TRUE, &shadow); + funcs = function_list(TRUE); + (void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) parms_shadow, & shadow); + efree(funcs); /* End with fatal if the user requested it. */ if (shadow && lintfunc != warning) lintwarn(_("there were shadowed variables.")); } -/* - * func_install: - * 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. - * - * Extra work, build up and save a list of the parameter names in a table - * and hang it off params->parmlist. This is used to set the `vname' field - * of each function parameter during a function call. See eval.c. + +/* mk_function --- finalize function definition node; remove parameters + * out of the symbol table. */ -static int -func_install(INSTRUCTION *func, INSTRUCTION *def) +static INSTRUCTION * +mk_function(INSTRUCTION *fi, INSTRUCTION *def) { - NODE *params; - NODE *r, *n, *thisfunc, *hp; - char **pnames = NULL; - char *fname; - int pcount = 0; - int i; + NODE *thisfunc; - params = func_params; + thisfunc = fi->func_body; + assert(thisfunc != NULL); - /* check for function foo(foo) { ... }. bleah. */ - for (n = params->rnode; n != NULL; n = n->rnode) { - if (strcmp(n->param, params->param) == 0) { - error_ln(func->source_line, - _("function `%s': can't use function name as parameter name"), params->param); - return -1; - } else if (is_std_var(n->param)) { - error_ln(func->source_line, - _("function `%s': can't use special variable `%s' as a function parameter"), - params->param, n->param); - return -1; - } - } + if (do_optimize > 1 && def->lasti->opcode == Op_pop) { + /* tail call which does not return any value. */ - thisfunc = NULL; /* turn off warnings */ + INSTRUCTION *t; - fname = params->param; - /* symbol table management */ - hp = remove_symbol(params->param); /* remove function name out of symbol table */ - if (hp != NULL) - freenode(hp); - r = lookup(fname); - if (r != NULL) { - error_ln(func->source_line, - _("function name `%s' previously defined"), fname); - return -1; - } else if (fname == builtin_func) /* not a valid function name */ - goto remove_params; + for (t = def->nexti; t->nexti != def->lasti; t = t->nexti) + ; + if (t->opcode == Op_func_call + && strcmp(t->func_name, thisfunc->vname) == 0) + (t + 1)->tail_call = TRUE; + } /* add an implicit return at end; * also used by 'return' command in debugger */ - + (void) list_append(def, instruction(Op_push_i)); - def->lasti->memory = Nnull_string; + def->lasti->memory = dupnode(Nnull_string); (void) list_append(def, instruction(Op_K_return)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(def, instruction(Op_exec_count)); - /* func->opcode is Op_func */ - (func + 1)->firsti = def->nexti; - (func + 1)->lasti = def->lasti; - (func + 2)->first_line = func->source_line; - (func + 2)->last_line = lastline; - - func->nexti = def->nexti; + /* fi->opcode = Op_func */ + (fi + 1)->firsti = def->nexti; + (fi + 1)->lasti = def->lasti; + (fi + 2)->first_line = fi->source_line; + (fi + 2)->last_line = lastline; + fi->nexti = def->nexti; bcfree(def); - (void) list_append(rule_list, func + 1); /* debugging */ - - /* install the function */ - thisfunc = mk_symbol(Node_func, params); - (void) install_symbol(fname, thisfunc); - thisfunc->code_ptr = func; - func->func_body = thisfunc; - - for (n = params->rnode; n != NULL; n = n->rnode) - pcount++; - - if (pcount != 0) { - emalloc(pnames, char **, (pcount + 1) * sizeof(char *), "func_install"); - for (i = 0, n = params->rnode; i < pcount; i++, n = n->rnode) - pnames[i] = n->param; - pnames[pcount] = NULL; - } - thisfunc->parmlist = pnames; + (void) list_append(rule_list, fi + 1); /* debugging */ /* update lint table info */ - func_use(fname, FUNC_DEFINE); - - func_count++; /* used in profiler / pretty printer */ + func_use(thisfunc->vname, FUNC_DEFINE); -remove_params: /* remove params from symbol table */ - pop_params(params->rnode); - return 0; + remove_params(thisfunc); + return fi; } -/* remove_symbol --- remove a variable from the symbol table */ +/* + * install_function: + * install function name in the symbol table. + * Extra work, build up and install a list of the parameter names. + */ -NODE * -remove_symbol(char *name) +static int +install_function(char *fname, INSTRUCTION *fi, INSTRUCTION *plist) { - NODE *bucket, **save; - size_t len; + NODE *r, *f; + int pcount = 0; - len = strlen(name); - save = &(variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]); - for (bucket = *save; bucket != NULL; bucket = bucket->hnext) { - if (len == bucket->hlength && strncmp(bucket->hname, name, len) == 0) { - var_count--; - *save = bucket->hnext; - return bucket; - } - save = &(bucket->hnext); + r = lookup(fname); + if (r != NULL) { + error_ln(fi->source_line, _("function name `%s' previously defined"), fname); + return -1; } - return NULL; + + if (plist != NULL) + pcount = plist->lasti->param_count + 1; + f = install_symbol(fname, Node_func); + fi->func_body = f; + f->param_cnt = pcount; + f->code_ptr = fi; + f->fparms = NULL; + if (pcount > 0) { + char **pnames; + pnames = check_params(fname, pcount, plist); /* frees plist */ + f->fparms = make_params(pnames, pcount); + efree(pnames); + install_params(f); + } + return 0; } -/* pop_params --- remove list of function parameters from symbol table */ -/* - * pop parameters out of the symbol table. do this in reverse order to - * avoid reading freed memory if there were duplicated parameters. +/* check_params --- build a list of function parameter names after + * making sure that the names are valid and there are no duplicates. */ -static void -pop_params(NODE *params) + +static char ** +check_params(char *fname, int pcount, INSTRUCTION *list) { - NODE *hp; - if (params == NULL) - return; - pop_params(params->rnode); - hp = remove_symbol(params->param); - if (hp != NULL) - freenode(hp); -} + INSTRUCTION *p, *np; + int i, j; + char *name; + char **pnames; -/* make_param --- make NAME into a function parameter */ + assert(pcount > 0); -static NODE * -make_param(char *name) -{ - NODE *r; + emalloc(pnames, char **, pcount * sizeof(char *), "check_params"); + + for (i = 0, p = list->nexti; p != NULL; i++, p = np) { + np = p->nexti; + name = p->lextok; + p->lextok = NULL; + + if (strcmp(name, fname) == 0) { + /* check for function foo(foo) { ... }. bleah. */ + error_ln(p->source_line, + _("function `%s': can't use function name as parameter name"), fname); + } else if (is_std_var(name)) { + error_ln(p->source_line, + _("function `%s': can't use special variable `%s' as a function parameter"), + fname, name); + } + + /* check for duplicate parameters */ + for (j = 0; j < i; j++) { + if (strcmp(name, pnames[j]) == 0) { + error_ln(p->source_line, + _("function `%s': parameter #%d, `%s', duplicates parameter #%d"), + fname, i + 1, name, j + 1); + } + } + + pnames[i] = name; + bcfree(p); + } + bcfree(list); - getnode(r); - r->type = Node_param_list; - r->rnode = NULL; - r->param_cnt = param_counter++; - return (install_symbol(name, r)); + return pnames; } + +#ifdef HASHSIZE +undef HASHSIZE +#endif +#define HASHSIZE 1021 + static struct fdesc { char *name; short used; @@ -7110,69 +6857,6 @@ param_sanity(INSTRUCTION *arglist) } } -/* foreach_func --- execute given function for each awk function in symbol table. */ - -int -foreach_func(int (*pfunc)(INSTRUCTION *, void *), int sort, void *data) -{ - int i, j; - NODE *p; - int ret = 0; - - if (sort) { - NODE **tab; - - /* - * Walk through symbol table counting functions. - * Could be more than func_count if there are - * extension functions. - */ - for (i = j = 0; i < HASHSIZE; i++) { - for (p = variables[i]; p != NULL; p = p->hnext) { - if (p->hvalue->type == Node_func) { - j++; - } - } - } - - if (j == 0) - return 0; - - emalloc(tab, NODE **, j * sizeof(NODE *), "foreach_func"); - - /* now walk again, copying info */ - for (i = j = 0; i < HASHSIZE; i++) { - for (p = variables[i]; p != NULL; p = p->hnext) { - if (p->hvalue->type == Node_func) { - tab[j] = p; - j++; - } - } - } - - /* Shazzam! */ - qsort(tab, j, sizeof(NODE *), sym_comp); - - for (i = 0; i < j; i++) { - if ((ret = pfunc(tab[i]->hvalue->code_ptr, data)) != 0) - break; - } - - efree(tab); - return ret; - } - - /* unsorted */ - for (i = 0; i < HASHSIZE; i++) { - for (p = variables[i]; p != NULL; p = p->hnext) { - if (p->hvalue->type == Node_func - && (ret = pfunc(p->hvalue->code_ptr, data)) != 0) - return ret; - } - } - return 0; -} - /* deferred variables --- those that are only defined if needed. */ /* @@ -7207,17 +6891,14 @@ register_deferred_variable(const char *name, NODE *(*load_func)(void)) /* variable --- make sure NAME is in the symbol table */ NODE * -variable(char *name, NODETYPE type) +variable(int location, char *name, NODETYPE type) { NODE *r; if ((r = lookup(name)) != NULL) { - if (r->type == Node_func) { - error(_("function `%s' called with space between name and `(',\nor used as a variable or an array"), + if (r->type == Node_func || r->type == Node_ext_func ) + error_ln(location, _("function `%s' called with space between name and `(',\nor used as a variable or an array"), r->vname); - errcount++; - r->type = Node_var_new; /* continue parsing instead of exiting */ - } } else { /* not found */ struct deferred_variable *dv; @@ -7227,11 +6908,7 @@ variable(char *name, NODETYPE type) /* * This is the only case in which we may not free the string. */ - if (type == Node_var) - r = mk_symbol(type, Nnull_string); - else - r = mk_symbol(type, (NODE *) NULL); - return install_symbol(name, r); + return install_symbol(name, type); } if (strcmp(name, dv->name) == 0) { r = (*dv->load_func)(); @@ -7338,9 +7015,6 @@ make_assignable(INSTRUCTION *ip) { switch (ip->opcode) { case Op_push: - if (ip->memory->type == Node_param_list - && (ip->memory->flags & FUNC) != 0) - return NULL; ip->opcode = Op_push_lhs; return ip; case Op_field_spec: @@ -7355,14 +7029,6 @@ make_assignable(INSTRUCTION *ip) return NULL; } -/* stopme --- for debugging */ - -NODE * -stopme(int nargs ATTRIBUTE_UNUSED) -{ - return (NODE *) 0; -} - /* dumpintlstr --- write out an initial .po file entry for the string */ static void @@ -7412,27 +7078,6 @@ dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2) fflush(stdout); } -/* isarray --- can this type be subscripted? */ - -static int -isarray(NODE *n) -{ - switch (n->type) { - case Node_var_new: - case Node_var_array: - return TRUE; - case Node_param_list: - return (n->flags & FUNC) == 0; - case Node_array_ref: - cant_happen(); - break; - default: - break; /* keeps gcc -Wall happy */ - } - - return FALSE; -} - /* mk_binary --- instructions for binary operators */ static INSTRUCTION * @@ -7493,11 +7138,7 @@ mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) } op->opcode = Op_push_i; - op->memory = mk_number(res, (PERM|NUMCUR|NUMBER)); - n1->flags &= ~PERM; - n1->flags |= MALLOC; - n2->flags &= ~PERM; - n2->flags |= MALLOC; + op->memory = make_number(res); unref(n1); unref(n2); bcfree(ip1); @@ -7623,7 +7264,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, if (false_branch == NULL) { false_branch = list_create(instruction(Op_no_op)); if (elsep != NULL) { /* else { } */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(false_branch, elsep); else bcfree(elsep); @@ -7634,7 +7275,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, /* avoid a series of no_op's: if .. else if .. else if .. */ if (false_branch->lasti->opcode != Op_no_op) (void) list_append(false_branch, instruction(Op_no_op)); - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(false_branch, elsep); false_branch->nexti->branch_end = false_branch->lasti; (void) list_prepend(false_branch, instruction(Op_exec_count)); @@ -7649,7 +7290,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, ip = list_append(cond, instruction(Op_jmp_false)); ip->lasti->target_jmp = false_branch->nexti->nexti; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, ifp); (void) list_append(ip, instruction(Op_exec_count)); ip->nexti->branch_if = ip->lasti; @@ -7711,7 +7352,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (rule != Rule) { rp = pattern; - if (do_profiling) + if (do_pretty_print) (void) list_append(action, instruction(Op_no_op)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = action->lasti; @@ -7727,7 +7368,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (pattern == NULL) { /* assert(action != NULL); */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = tp; @@ -7743,12 +7384,12 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (action == NULL) { (rp + 2)->last_line = find_line(pattern, LAST_LINE); action = list_create(instruction(Op_K_print_rec)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); } else (rp + 2)->last_line = lastline; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(pattern, instruction(Op_exec_count)); (void) list_prepend(action, instruction(Op_exec_count)); } @@ -7828,9 +7469,7 @@ mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op) static INSTRUCTION * optimize_assignment(INSTRUCTION *exp) { - INSTRUCTION *i1; - INSTRUCTION *i2; - INSTRUCTION *i3; + INSTRUCTION *i1, *i2, *i3; /* * Optimize assignment statements array[subs] = x; var = x; $n = x; @@ -7866,7 +7505,7 @@ optimize_assignment(INSTRUCTION *exp) if ( ! do_optimize || ( i1->opcode != Op_assign && i1->opcode != Op_field_assign) - ) + ) return list_append(exp, instruction(Op_pop)); for (i2 = exp->nexti; i2 != i1; i2 = i2->nexti) { @@ -7951,13 +7590,26 @@ optimize_assignment(INSTRUCTION *exp) case Op_push_lhs: if (i2->nexti == i1 - && i1->opcode == Op_assign + && i1->opcode == Op_assign ) { /* var = .. */ i2->opcode = Op_store_var; i2->nexti = NULL; bcfree(i1); /* Op_assign */ exp->lasti = i2; /* update Op_list */ + + i3 = exp->nexti; + if (i3->opcode == Op_push_i + && (i3->memory->flags & INTLSTR) == 0 + && i3->nexti == i2 + ) { + /* constant initializer */ + i2->initval = i3->memory; + bcfree(i3); + exp->nexti = i2; + } else + i2->initval = NULL; + return exp; } break; @@ -8078,7 +7730,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, if (init != NULL) ip = list_merge(init, ip); - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); (forp + 1)->forloop_cond = pp_cond; (forp + 1)->forloop_body = ip->lasti; @@ -8100,7 +7752,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, ret = list_append(ip, tbreak); fix_break_continue(ret, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { forp->target_break = tbreak; forp->target_continue = tcont; ret = list_prepend(ret, forp); @@ -8259,320 +7911,6 @@ fix_break_continue(INSTRUCTION *list, INSTRUCTION *b_target, INSTRUCTION *c_targ } } - -/* append_symbol --- append symbol to the list of symbols - * installed in the symbol table. - */ - -void -append_symbol(char *name) -{ - NODE *hp; - - /* N.B.: func_install removes func name and reinstalls it; - * and we get two entries for it here!. destroy_symbol() - * will find and destroy the Node_func which is what we want. - */ - - getnode(hp); - hp->hname = name; /* shallow copy */ - hp->hnext = symbol_list->hnext; - symbol_list->hnext = hp; -} - -/* release_symbol --- free symbol list and optionally remove symbol from symbol table */ - -void -release_symbols(NODE *symlist, int keep_globals) -{ - NODE *hp, *n; - - for (hp = symlist->hnext; hp != NULL; hp = n) { - if (! keep_globals) { - /* destroys globals, function, and params - * if still in symbol table and not removed by func_install - * due to syntax error. - */ - destroy_symbol(hp->hname); - } - n = hp->hnext; - freenode(hp); - } - symlist->hnext = NULL; -} - -/* destroy_symbol --- remove a symbol from symbol table -* and free all associated memory. -*/ - -void -destroy_symbol(char *name) -{ - NODE *symbol, *hp; - - symbol = lookup(name); - if (symbol == NULL) - return; - - if (symbol->type == Node_func) { - char **varnames; - NODE *func, *n; - - func = symbol; - varnames = func->parmlist; - if (varnames != NULL) - efree(varnames); - - /* function parameters of type Node_param_list */ - for (n = func->lnode->rnode; n != NULL; ) { - NODE *np; - np = n->rnode; - efree(n->param); - freenode(n); - n = np; - } - freenode(func->lnode); - func_count--; - - } else if (symbol->type == Node_var_array) - assoc_clear(symbol); - else if (symbol->type == Node_var) - unref(symbol->var_value); - - /* remove from symbol table */ - hp = remove_symbol(name); - efree(hp->hname); - freenode(hp->hvalue); - freenode(hp); -} - -#define pool_size d.dl -#define freei x.xi -static INSTRUCTION *pool_list; -static AWK_CONTEXT *curr_ctxt = NULL; - -/* new_context --- create a new execution context. */ - -AWK_CONTEXT * -new_context() -{ - AWK_CONTEXT *ctxt; - - emalloc(ctxt, AWK_CONTEXT *, sizeof(AWK_CONTEXT), "new_context"); - memset(ctxt, 0, sizeof(AWK_CONTEXT)); - ctxt->srcfiles.next = ctxt->srcfiles.prev = &ctxt->srcfiles; - ctxt->rule_list.opcode = Op_list; - ctxt->rule_list.lasti = &ctxt->rule_list; - return ctxt; -} - -/* set_context --- change current execution context. */ - -static void -set_context(AWK_CONTEXT *ctxt) -{ - pool_list = &ctxt->pools; - symbol_list = &ctxt->symbols; - srcfiles = &ctxt->srcfiles; - rule_list = &ctxt->rule_list; - install_func = ctxt->install_func; - curr_ctxt = ctxt; -} - -/* - * push_context: - * - * Switch to the given context after saving the current one. The set - * of active execution contexts forms a stack; the global or main context - * is at the bottom of the stack. - */ - -void -push_context(AWK_CONTEXT *ctxt) -{ - ctxt->prev = curr_ctxt; - /* save current source and sourceline */ - if (curr_ctxt != NULL) { - curr_ctxt->sourceline = sourceline; - curr_ctxt->source = source; - } - sourceline = 0; - source = NULL; - set_context(ctxt); -} - -/* pop_context --- switch to previous execution context. */ - -void -pop_context() -{ - AWK_CONTEXT *ctxt; - - assert(curr_ctxt != NULL); - ctxt = curr_ctxt->prev; - /* restore source and sourceline */ - sourceline = ctxt->sourceline; - source = ctxt->source; - set_context(ctxt); -} - -/* in_main_context --- are we in the main context ? */ - -int -in_main_context() -{ - assert(curr_ctxt != NULL); - return (curr_ctxt->prev == NULL); -} - -/* free_context --- free context structure and related data. */ - -void -free_context(AWK_CONTEXT *ctxt, int keep_globals) -{ - SRCFILE *s, *sn; - - if (ctxt == NULL) - return; - - assert(curr_ctxt != ctxt); - - /* free all code including function codes */ - free_bcpool(&ctxt->pools); - /* free symbols */ - release_symbols(&ctxt->symbols, keep_globals); - /* free srcfiles */ - for (s = &ctxt->srcfiles; s != &ctxt->srcfiles; s = sn) { - sn = s->next; - if (s->stype != SRC_CMDLINE && s->stype != SRC_STDIN) - efree(s->fullpath); - efree(s->src); - efree(s); - } - efree(ctxt); -} - -/* free_bc_internal --- free internal memory of an instruction. */ - -static void -free_bc_internal(INSTRUCTION *cp) -{ - NODE *m; - - switch(cp->opcode) { - case Op_func_call: - if (cp->func_name != NULL - && cp->func_name != builtin_func - ) - efree(cp->func_name); - break; - case Op_push_re: - case Op_match_rec: - case Op_match: - case Op_nomatch: - m = cp->memory; - if (m->re_reg != NULL) - refree(m->re_reg); - if (m->re_exp != NULL) - unref(m->re_exp); - if (m->re_text != NULL) - unref(m->re_text); - freenode(m); - break; - case Op_token: /* token lost during error recovery in yyparse */ - if (cp->lextok != NULL) - efree(cp->lextok); - break; - case Op_illegal: - cant_happen(); - default: - break; - } -} - - -/* INSTR_CHUNK must be > largest code size (3) */ -#define INSTR_CHUNK 127 - -/* bcfree --- deallocate instruction */ - -void -bcfree(INSTRUCTION *cp) -{ - cp->opcode = 0; - cp->nexti = pool_list->freei; - pool_list->freei = cp; -} - -/* bcalloc --- allocate a new instruction */ - -INSTRUCTION * -bcalloc(OPCODE op, int size, int srcline) -{ - INSTRUCTION *cp; - - if (size > 1) { - /* wide instructions Op_rule, Op_func_call .. */ - emalloc(cp, INSTRUCTION *, (size + 1) * sizeof(INSTRUCTION), "bcalloc"); - cp->pool_size = size; - cp->nexti = pool_list->nexti; - pool_list->nexti = cp++; - } else { - INSTRUCTION *pool; - - pool = pool_list->freei; - if (pool == NULL) { - INSTRUCTION *last; - emalloc(cp, INSTRUCTION *, (INSTR_CHUNK + 1) * sizeof(INSTRUCTION), "bcalloc"); - - cp->pool_size = INSTR_CHUNK; - cp->nexti = pool_list->nexti; - pool_list->nexti = cp; - pool = ++cp; - last = &pool[INSTR_CHUNK - 1]; - for (; cp <= last; cp++) { - cp->opcode = 0; - cp->nexti = cp + 1; - } - --cp; - cp->nexti = NULL; - } - cp = pool; - pool_list->freei = cp->nexti; - } - - memset(cp, 0, size * sizeof(INSTRUCTION)); - cp->opcode = op; - cp->source_line = srcline; - return cp; -} - -/* free_bcpool --- free list of instruction memory pools */ - -static void -free_bcpool(INSTRUCTION *pl) -{ - INSTRUCTION *pool, *tmp; - - for (pool = pl->nexti; pool != NULL; pool = tmp) { - INSTRUCTION *cp, *last; - long psiz; - psiz = pool->pool_size; - if (psiz == INSTR_CHUNK) - last = pool + psiz; - else - last = pool + 1; - for (cp = pool + 1; cp <= last ; cp++) { - if (cp->opcode != 0) - free_bc_internal(cp); - } - tmp = pool->nexti; - efree(pool); - } - memset(pl, 0, sizeof(INSTRUCTION)); -} - - static inline INSTRUCTION * list_create(INSTRUCTION *x) { |