aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2022-01-05 21:13:40 +0200
committerArnold D. Robbins <arnold@skeeve.com>2022-01-05 21:13:40 +0200
commit8bd2904afb35a19d48552b10d3215ba16fe4ce35 (patch)
tree04f2ff8100f9e6e7ddeb905f2acad759695b8222
parentf285f960bdfb5acb50a8ec7ed4b98f17d0bd624a (diff)
downloadegawk-8bd2904afb35a19d48552b10d3215ba16fe4ce35.tar.gz
egawk-8bd2904afb35a19d48552b10d3215ba16fe4ce35.tar.bz2
egawk-8bd2904afb35a19d48552b10d3215ba16fe4ce35.zip
Fix a namespace issue.
-rw-r--r--ChangeLog13
-rw-r--r--awkgram.c904
-rw-r--r--awkgram.y60
-rw-r--r--pc/ChangeLog4
-rw-r--r--pc/Makefile.tst7
-rw-r--r--symbol.c5
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/nsidentifier.awk36
-rw-r--r--test/nsidentifier.ok118
12 files changed, 724 insertions, 446 deletions
diff --git a/ChangeLog b/ChangeLog
index e2f179fe..6f89d610 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-01-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (change_namespace): New function. Extracted from
+ set_namespace.
+ (want_namespace): New variable.
+ [grammar]: Add explanatory comment about the change.
+ (yylex): Change the namespace immediately from the lexer.
+ (set_namespace): Adjust code.
+ * symbol.c (load_symbols): Strip off leading awk:: so that
+ PROCINFO["identifiers"] is like SYMTAB and FUNCTAB. This makes
+ the code match the documentation. Thanks to John Naman
+ <gawker@703n.com> for the bug report.
+
2021-12-17 Yuri Gribov <tetra2005@gmail.com>
Make a number of functions and variables static.
diff --git a/awkgram.c b/awkgram.c
index 30c207e1..6ad01d6c 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -102,6 +102,7 @@ static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t
static bool include_source(INSTRUCTION *file, void **srcfile_p);
static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void set_namespace(INSTRUCTION *ns, INSTRUCTION *comment);
+static void change_namespace(const char *new_namespace);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
@@ -157,6 +158,7 @@ static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
static bool want_source = false;
+static bool want_namespace = false;
static bool want_regexp = false; /* lexical scanning kludge */
static enum {
FUNC_HEADER,
@@ -233,7 +235,7 @@ extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 237 "awkgram.c"
+#line 239 "awkgram.c"
# ifndef YY_CAST
# ifdef __cplusplus
@@ -954,27 +956,27 @@ static const yytype_int8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] =
{
- 0, 233, 233, 234, 239, 249, 253, 265, 273, 287,
- 298, 308, 318, 331, 341, 343, 348, 358, 360, 365,
- 367, 369, 375, 379, 384, 414, 426, 438, 444, 453,
- 471, 472, 483, 489, 497, 498, 502, 502, 536, 535,
- 569, 584, 586, 591, 592, 612, 617, 618, 622, 633,
- 638, 645, 753, 804, 854, 980, 1002, 1023, 1033, 1043,
- 1053, 1064, 1077, 1095, 1094, 1111, 1129, 1129, 1231, 1231,
- 1264, 1294, 1302, 1303, 1309, 1310, 1317, 1322, 1335, 1350,
- 1352, 1360, 1367, 1369, 1377, 1386, 1388, 1397, 1398, 1406,
- 1411, 1411, 1424, 1431, 1444, 1448, 1470, 1471, 1477, 1478,
- 1487, 1488, 1493, 1498, 1515, 1517, 1519, 1526, 1527, 1533,
- 1534, 1539, 1541, 1548, 1550, 1558, 1563, 1574, 1575, 1580,
- 1582, 1589, 1591, 1599, 1604, 1614, 1615, 1620, 1621, 1626,
- 1633, 1637, 1639, 1641, 1654, 1671, 1681, 1688, 1690, 1695,
- 1697, 1699, 1707, 1709, 1714, 1716, 1721, 1723, 1725, 1782,
- 1784, 1786, 1788, 1790, 1792, 1794, 1796, 1810, 1815, 1820,
- 1846, 1852, 1854, 1856, 1858, 1860, 1862, 1867, 1871, 1903,
- 1911, 1917, 1923, 1936, 1937, 1938, 1943, 1948, 1952, 1956,
- 1971, 1992, 1997, 2034, 2071, 2072, 2078, 2079, 2084, 2086,
- 2093, 2110, 2127, 2129, 2136, 2141, 2147, 2158, 2170, 2179,
- 2183, 2188, 2192, 2196, 2200, 2205, 2206, 2210, 2214, 2218
+ 0, 235, 235, 236, 241, 251, 255, 267, 275, 289,
+ 300, 310, 320, 346, 356, 358, 363, 373, 375, 380,
+ 382, 384, 390, 394, 399, 429, 441, 453, 459, 468,
+ 486, 487, 498, 504, 512, 513, 517, 517, 551, 550,
+ 584, 599, 601, 606, 607, 627, 632, 633, 637, 648,
+ 653, 660, 768, 819, 869, 995, 1017, 1038, 1048, 1058,
+ 1068, 1079, 1092, 1110, 1109, 1126, 1144, 1144, 1246, 1246,
+ 1279, 1309, 1317, 1318, 1324, 1325, 1332, 1337, 1350, 1365,
+ 1367, 1375, 1382, 1384, 1392, 1401, 1403, 1412, 1413, 1421,
+ 1426, 1426, 1439, 1446, 1459, 1463, 1485, 1486, 1492, 1493,
+ 1502, 1503, 1508, 1513, 1530, 1532, 1534, 1541, 1542, 1548,
+ 1549, 1554, 1556, 1563, 1565, 1573, 1578, 1589, 1590, 1595,
+ 1597, 1604, 1606, 1614, 1619, 1629, 1630, 1635, 1636, 1641,
+ 1648, 1652, 1654, 1656, 1669, 1686, 1696, 1703, 1705, 1710,
+ 1712, 1714, 1722, 1724, 1729, 1731, 1736, 1738, 1740, 1797,
+ 1799, 1801, 1803, 1805, 1807, 1809, 1811, 1825, 1830, 1835,
+ 1861, 1867, 1869, 1871, 1873, 1875, 1877, 1882, 1886, 1918,
+ 1926, 1932, 1938, 1951, 1952, 1953, 1958, 1963, 1967, 1971,
+ 1986, 2007, 2012, 2049, 2086, 2087, 2093, 2094, 2099, 2101,
+ 2108, 2125, 2142, 2144, 2151, 2156, 2162, 2173, 2185, 2194,
+ 2198, 2203, 2207, 2211, 2215, 2220, 2221, 2225, 2229, 2233
};
#endif
@@ -1956,22 +1958,22 @@ yyreduce:
switch (yyn)
{
case 2: /* program: %empty */
-#line 233 "awkgram.y"
+#line 235 "awkgram.y"
{ yyval = NULL; }
-#line 1962 "awkgram.c"
+#line 1964 "awkgram.c"
break;
case 3: /* program: program rule */
-#line 235 "awkgram.y"
+#line 237 "awkgram.y"
{
rule = 0;
yyerrok;
}
-#line 1971 "awkgram.c"
+#line 1973 "awkgram.c"
break;
case 4: /* program: program nls */
-#line 240 "awkgram.y"
+#line 242 "awkgram.y"
{
if (yyvsp[0] != NULL) {
if (yyvsp[-1] == NULL)
@@ -1981,19 +1983,19 @@ yyreduce:
}
yyval = yyvsp[-1];
}
-#line 1985 "awkgram.c"
+#line 1987 "awkgram.c"
break;
case 5: /* program: program LEX_EOF */
-#line 250 "awkgram.y"
+#line 252 "awkgram.y"
{
next_sourcefile();
}
-#line 1993 "awkgram.c"
+#line 1995 "awkgram.c"
break;
case 6: /* program: program error */
-#line 254 "awkgram.y"
+#line 256 "awkgram.y"
{
rule = 0;
/*
@@ -2002,11 +2004,11 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 2006 "awkgram.c"
+#line 2008 "awkgram.c"
break;
case 7: /* rule: pattern action */
-#line 266 "awkgram.y"
+#line 268 "awkgram.y"
{
(void) append_rule(yyvsp[-1], yyvsp[0]);
if (pending_comment != NULL) {
@@ -2014,11 +2016,11 @@ yyreduce:
pending_comment = NULL;
}
}
-#line 2018 "awkgram.c"
+#line 2020 "awkgram.c"
break;
case 8: /* rule: pattern statement_term */
-#line 274 "awkgram.y"
+#line 276 "awkgram.y"
{
if (rule != Rule) {
msg(_("%s blocks must have an action part"), ruletab[rule]);
@@ -2032,11 +2034,11 @@ yyreduce:
(void) append_rule(yyvsp[-1], NULL);
}
}
-#line 2036 "awkgram.c"
+#line 2038 "awkgram.c"
break;
case 9: /* rule: function_prologue action */
-#line 288 "awkgram.y"
+#line 290 "awkgram.y"
{
in_function = false;
(void) mk_function(yyvsp[-1], yyvsp[0]);
@@ -2047,11 +2049,11 @@ yyreduce:
}
yyerrok;
}
-#line 2051 "awkgram.c"
+#line 2053 "awkgram.c"
break;
case 10: /* rule: '@' LEX_INCLUDE source statement_term */
-#line 299 "awkgram.y"
+#line 301 "awkgram.y"
{
want_source = false;
at_seen = false;
@@ -2061,11 +2063,11 @@ yyreduce:
}
yyerrok;
}
-#line 2065 "awkgram.c"
+#line 2067 "awkgram.c"
break;
case 11: /* rule: '@' LEX_LOAD library statement_term */
-#line 309 "awkgram.y"
+#line 311 "awkgram.y"
{
want_source = false;
at_seen = false;
@@ -2075,13 +2077,26 @@ yyreduce:
}
yyerrok;
}
-#line 2079 "awkgram.c"
+#line 2081 "awkgram.c"
break;
case 12: /* rule: '@' LEX_NAMESPACE namespace statement_term */
-#line 319 "awkgram.y"
+#line 321 "awkgram.y"
{
+ /*
+ * 1/2022:
+ * We have an interesting isssue here. This production isn't
+ * reduced until after the token following the statement_term
+ * is seen. As a result, the change in namespace doesn't take
+ * effect until then. That's fine if the first token is 'function'
+ * or BEGIN or some such, but it's a disaster if it's an identifer;
+ * that identifier will be in the previous namespace.
+ * Therefore, the actual setting of the namespace is done immediately
+ * down in the scanner.
+ */
+
want_source = false;
+ want_namespace = false;
at_seen = false;
// this frees $3 storage in all cases
@@ -2089,11 +2104,11 @@ yyreduce:
yyerrok;
}
-#line 2093 "awkgram.c"
+#line 2108 "awkgram.c"
break;
case 13: /* source: FILENAME */
-#line 332 "awkgram.y"
+#line 347 "awkgram.y"
{
void *srcfile = NULL;
@@ -2103,23 +2118,23 @@ yyreduce:
bcfree(yyvsp[0]);
yyval = (INSTRUCTION *) srcfile;
}
-#line 2107 "awkgram.c"
+#line 2122 "awkgram.c"
break;
case 14: /* source: FILENAME error */
-#line 342 "awkgram.y"
+#line 357 "awkgram.y"
{ yyval = NULL; }
-#line 2113 "awkgram.c"
+#line 2128 "awkgram.c"
break;
case 15: /* source: error */
-#line 344 "awkgram.y"
+#line 359 "awkgram.y"
{ yyval = NULL; }
-#line 2119 "awkgram.c"
+#line 2134 "awkgram.c"
break;
case 16: /* library: FILENAME */
-#line 349 "awkgram.y"
+#line 364 "awkgram.y"
{
void *srcfile;
@@ -2129,58 +2144,58 @@ yyreduce:
bcfree(yyvsp[0]);
yyval = (INSTRUCTION *) srcfile;
}
-#line 2133 "awkgram.c"
+#line 2148 "awkgram.c"
break;
case 17: /* library: FILENAME error */
-#line 359 "awkgram.y"
+#line 374 "awkgram.y"
{ yyval = NULL; }
-#line 2139 "awkgram.c"
+#line 2154 "awkgram.c"
break;
case 18: /* library: error */
-#line 361 "awkgram.y"
+#line 376 "awkgram.y"
{ yyval = NULL; }
-#line 2145 "awkgram.c"
+#line 2160 "awkgram.c"
break;
case 19: /* namespace: FILENAME */
-#line 366 "awkgram.y"
+#line 381 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 2151 "awkgram.c"
+#line 2166 "awkgram.c"
break;
case 20: /* namespace: FILENAME error */
-#line 368 "awkgram.y"
+#line 383 "awkgram.y"
{ yyval = NULL; }
-#line 2157 "awkgram.c"
+#line 2172 "awkgram.c"
break;
case 21: /* namespace: error */
-#line 370 "awkgram.y"
+#line 385 "awkgram.y"
{ yyval = NULL; }
-#line 2163 "awkgram.c"
+#line 2178 "awkgram.c"
break;
case 22: /* pattern: %empty */
-#line 375 "awkgram.y"
+#line 390 "awkgram.y"
{
rule = Rule;
yyval = NULL;
}
-#line 2172 "awkgram.c"
+#line 2187 "awkgram.c"
break;
case 23: /* pattern: exp */
-#line 380 "awkgram.y"
+#line 395 "awkgram.y"
{
rule = Rule;
}
-#line 2180 "awkgram.c"
+#line 2195 "awkgram.c"
break;
case 24: /* pattern: exp comma exp */
-#line 385 "awkgram.y"
+#line 400 "awkgram.y"
{
INSTRUCTION *tp;
@@ -2210,11 +2225,11 @@ yyreduce:
yyval = list_append(list_merge(yyvsp[-2], yyvsp[0]), tp);
rule = Rule;
}
-#line 2214 "awkgram.c"
+#line 2229 "awkgram.c"
break;
case 25: /* pattern: LEX_BEGIN */
-#line 415 "awkgram.y"
+#line 430 "awkgram.y"
{
static int begin_seen = 0;
@@ -2226,11 +2241,11 @@ yyreduce:
yyvsp[0]->source_file = source;
yyval = yyvsp[0];
}
-#line 2230 "awkgram.c"
+#line 2245 "awkgram.c"
break;
case 26: /* pattern: LEX_END */
-#line 427 "awkgram.y"
+#line 442 "awkgram.y"
{
static int end_seen = 0;
@@ -2242,31 +2257,31 @@ yyreduce:
yyvsp[0]->source_file = source;
yyval = yyvsp[0];
}
-#line 2246 "awkgram.c"
+#line 2261 "awkgram.c"
break;
case 27: /* pattern: LEX_BEGINFILE */
-#line 439 "awkgram.y"
+#line 454 "awkgram.y"
{
yyvsp[0]->in_rule = rule = BEGINFILE;
yyvsp[0]->source_file = source;
yyval = yyvsp[0];
}
-#line 2256 "awkgram.c"
+#line 2271 "awkgram.c"
break;
case 28: /* pattern: LEX_ENDFILE */
-#line 445 "awkgram.y"
+#line 460 "awkgram.y"
{
yyvsp[0]->in_rule = rule = ENDFILE;
yyvsp[0]->source_file = source;
yyval = yyvsp[0];
}
-#line 2266 "awkgram.c"
+#line 2281 "awkgram.c"
break;
case 29: /* action: l_brace statements r_brace opt_semi opt_nls */
-#line 454 "awkgram.y"
+#line 469 "awkgram.y"
{
INSTRUCTION *ip = make_braced_statements(yyvsp[-4], yyvsp[-3], yyvsp[-2]);
@@ -2281,11 +2296,11 @@ yyreduce:
yyval = ip;
}
-#line 2285 "awkgram.c"
+#line 2300 "awkgram.c"
break;
case 31: /* func_name: FUNC_CALL */
-#line 473 "awkgram.y"
+#line 488 "awkgram.y"
{
const char *name = yyvsp[0]->lextok;
char *qname = qualify_name(name, strlen(name));
@@ -2296,36 +2311,36 @@ yyreduce:
}
yyval = yyvsp[0];
}
-#line 2300 "awkgram.c"
+#line 2315 "awkgram.c"
break;
case 32: /* func_name: lex_builtin */
-#line 484 "awkgram.y"
+#line 499 "awkgram.y"
{
yyerror(_("`%s' is a built-in function, it cannot be redefined"),
tokstart);
YYABORT;
}
-#line 2310 "awkgram.c"
+#line 2325 "awkgram.c"
break;
case 33: /* func_name: '@' LEX_EVAL */
-#line 490 "awkgram.y"
+#line 505 "awkgram.y"
{
yyval = yyvsp[0];
at_seen = false;
}
-#line 2319 "awkgram.c"
+#line 2334 "awkgram.c"
break;
case 36: /* $@1: %empty */
-#line 502 "awkgram.y"
+#line 517 "awkgram.y"
{ want_param_names = FUNC_HEADER; }
-#line 2325 "awkgram.c"
+#line 2340 "awkgram.c"
break;
case 37: /* function_prologue: LEX_FUNCTION func_name '(' $@1 opt_param_list r_paren opt_nls */
-#line 503 "awkgram.y"
+#line 518 "awkgram.y"
{
INSTRUCTION *func_comment = NULL;
// Merge any comments found in the parameter list with those
@@ -2351,17 +2366,17 @@ yyreduce:
yyval = yyvsp[-6];
want_param_names = FUNC_BODY;
}
-#line 2355 "awkgram.c"
+#line 2370 "awkgram.c"
break;
case 38: /* $@2: %empty */
-#line 536 "awkgram.y"
+#line 551 "awkgram.y"
{ want_regexp = true; }
-#line 2361 "awkgram.c"
+#line 2376 "awkgram.c"
break;
case 39: /* regexp: a_slash $@2 REGEXP */
-#line 538 "awkgram.y"
+#line 553 "awkgram.y"
{
NODE *n, *exp;
char *re;
@@ -2390,11 +2405,11 @@ yyreduce:
yyval->opcode = Op_match_rec;
yyval->memory = n;
}
-#line 2394 "awkgram.c"
+#line 2409 "awkgram.c"
break;
case 40: /* typed_regexp: TYPED_REGEXP */
-#line 570 "awkgram.y"
+#line 585 "awkgram.y"
{
char *re;
size_t len;
@@ -2407,23 +2422,23 @@ yyreduce:
yyval->opcode = Op_push_re;
yyval->memory = make_typed_regex(re, len);
}
-#line 2411 "awkgram.c"
+#line 2426 "awkgram.c"
break;
case 41: /* a_slash: '/' */
-#line 585 "awkgram.y"
+#line 600 "awkgram.y"
{ bcfree(yyvsp[0]); }
-#line 2417 "awkgram.c"
+#line 2432 "awkgram.c"
break;
case 43: /* statements: %empty */
-#line 591 "awkgram.y"
+#line 606 "awkgram.y"
{ yyval = NULL; }
-#line 2423 "awkgram.c"
+#line 2438 "awkgram.c"
break;
case 44: /* statements: statements statement */
-#line 593 "awkgram.y"
+#line 608 "awkgram.y"
{
if (yyvsp[0] == NULL) {
yyval = yyvsp[-1];
@@ -2443,29 +2458,29 @@ yyreduce:
yyerrok;
}
-#line 2447 "awkgram.c"
+#line 2462 "awkgram.c"
break;
case 45: /* statements: statements error */
-#line 613 "awkgram.y"
+#line 628 "awkgram.y"
{ yyval = NULL; }
-#line 2453 "awkgram.c"
+#line 2468 "awkgram.c"
break;
case 46: /* statement_term: nls */
-#line 617 "awkgram.y"
+#line 632 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 2459 "awkgram.c"
+#line 2474 "awkgram.c"
break;
case 47: /* statement_term: semi opt_nls */
-#line 618 "awkgram.y"
+#line 633 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 2465 "awkgram.c"
+#line 2480 "awkgram.c"
break;
case 48: /* statement: semi opt_nls */
-#line 623 "awkgram.y"
+#line 638 "awkgram.y"
{
if (yyvsp[0] != NULL) {
INSTRUCTION *ip;
@@ -2476,31 +2491,31 @@ yyreduce:
} else
yyval = NULL;
}
-#line 2480 "awkgram.c"
+#line 2495 "awkgram.c"
break;
case 49: /* statement: l_brace statements r_brace */
-#line 634 "awkgram.y"
+#line 649 "awkgram.y"
{
trailing_comment = yyvsp[0]; // NULL or comment
yyval = make_braced_statements(yyvsp[-2], yyvsp[-1], yyvsp[0]);
}
-#line 2489 "awkgram.c"
+#line 2504 "awkgram.c"
break;
case 50: /* statement: if_statement */
-#line 639 "awkgram.y"
+#line 654 "awkgram.y"
{
if (do_pretty_print)
yyval = list_prepend(yyvsp[0], instruction(Op_exec_count));
else
yyval = yyvsp[0];
}
-#line 2500 "awkgram.c"
+#line 2515 "awkgram.c"
break;
case 51: /* statement: LEX_SWITCH '(' exp r_paren opt_nls l_brace case_statements opt_nls r_brace */
-#line 646 "awkgram.y"
+#line 661 "awkgram.y"
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2608,11 +2623,11 @@ yyreduce:
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2612 "awkgram.c"
+#line 2627 "awkgram.c"
break;
case 52: /* statement: LEX_WHILE '(' exp r_paren opt_nls statement */
-#line 754 "awkgram.y"
+#line 769 "awkgram.y"
{
/*
* -----------------
@@ -2663,11 +2678,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2667 "awkgram.c"
+#line 2682 "awkgram.c"
break;
case 53: /* statement: LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls */
-#line 805 "awkgram.y"
+#line 820 "awkgram.y"
{
/*
* -----------------
@@ -2717,11 +2732,11 @@ yyreduce:
/* else
$1 and $4 are NULLs */
}
-#line 2721 "awkgram.c"
+#line 2736 "awkgram.c"
break;
case 54: /* statement: LEX_FOR '(' NAME LEX_IN simple_variable r_paren opt_nls statement */
-#line 855 "awkgram.y"
+#line 870 "awkgram.y"
{
INSTRUCTION *ip;
char *var_name = yyvsp[-5]->lextok;
@@ -2847,11 +2862,11 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2851 "awkgram.c"
+#line 2866 "awkgram.c"
break;
case 55: /* statement: LEX_FOR '(' opt_simple_stmt semi opt_nls exp semi opt_nls opt_simple_stmt r_paren opt_nls statement */
-#line 981 "awkgram.y"
+#line 996 "awkgram.y"
{
if (yyvsp[-7] != NULL) {
merge_comments(yyvsp[-7], NULL);
@@ -2873,11 +2888,11 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2877 "awkgram.c"
+#line 2892 "awkgram.c"
break;
case 56: /* statement: LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r_paren opt_nls statement */
-#line 1003 "awkgram.y"
+#line 1018 "awkgram.y"
{
if (yyvsp[-6] != NULL) {
merge_comments(yyvsp[-6], NULL);
@@ -2898,22 +2913,22 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2902 "awkgram.c"
+#line 2917 "awkgram.c"
break;
case 57: /* statement: non_compound_stmt */
-#line 1024 "awkgram.y"
+#line 1039 "awkgram.y"
{
if (do_pretty_print)
yyval = list_prepend(yyvsp[0], instruction(Op_exec_count));
else
yyval = yyvsp[0];
}
-#line 2913 "awkgram.c"
+#line 2928 "awkgram.c"
break;
case 58: /* non_compound_stmt: LEX_BREAK statement_term */
-#line 1034 "awkgram.y"
+#line 1049 "awkgram.y"
{
if (! break_allowed)
error_ln(yyvsp[-1]->source_line,
@@ -2923,11 +2938,11 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 2927 "awkgram.c"
+#line 2942 "awkgram.c"
break;
case 59: /* non_compound_stmt: LEX_CONTINUE statement_term */
-#line 1044 "awkgram.y"
+#line 1059 "awkgram.y"
{
if (! continue_allowed)
error_ln(yyvsp[-1]->source_line,
@@ -2937,11 +2952,11 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 2941 "awkgram.c"
+#line 2956 "awkgram.c"
break;
case 60: /* non_compound_stmt: LEX_NEXT statement_term */
-#line 1054 "awkgram.y"
+#line 1069 "awkgram.y"
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2952,11 +2967,11 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 2956 "awkgram.c"
+#line 2971 "awkgram.c"
break;
case 61: /* non_compound_stmt: LEX_NEXTFILE statement_term */
-#line 1065 "awkgram.y"
+#line 1080 "awkgram.y"
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule == BEGIN || rule == END || rule == ENDFILE)
@@ -2969,11 +2984,11 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 2973 "awkgram.c"
+#line 2988 "awkgram.c"
break;
case 62: /* non_compound_stmt: LEX_EXIT opt_exp statement_term */
-#line 1078 "awkgram.y"
+#line 1093 "awkgram.y"
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2990,20 +3005,20 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 2994 "awkgram.c"
+#line 3009 "awkgram.c"
break;
case 63: /* $@3: %empty */
-#line 1095 "awkgram.y"
+#line 1110 "awkgram.y"
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 3003 "awkgram.c"
+#line 3018 "awkgram.c"
break;
case 64: /* non_compound_stmt: LEX_RETURN $@3 opt_fcall_exp statement_term */
-#line 1098 "awkgram.y"
+#line 1113 "awkgram.y"
{
if (called_from_eval)
yyvsp[-3]->opcode = Op_K_return_from_eval;
@@ -3017,28 +3032,28 @@ regular_loop:
if (yyvsp[0] != NULL)
yyval = list_append(yyval, yyvsp[0]);
}
-#line 3021 "awkgram.c"
+#line 3036 "awkgram.c"
break;
case 65: /* non_compound_stmt: simple_stmt statement_term */
-#line 1112 "awkgram.y"
+#line 1127 "awkgram.y"
{
if (yyvsp[0] != NULL)
yyval = list_append(yyvsp[-1], yyvsp[0]);
else
yyval = yyvsp[-1];
}
-#line 3032 "awkgram.c"
+#line 3047 "awkgram.c"
break;
case 66: /* $@4: %empty */
-#line 1129 "awkgram.y"
+#line 1144 "awkgram.y"
{ in_print = true; in_parens = 0; }
-#line 3038 "awkgram.c"
+#line 3053 "awkgram.c"
break;
case 67: /* simple_stmt: print $@4 print_expression_list output_redir */
-#line 1130 "awkgram.y"
+#line 1145 "awkgram.y"
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -3139,17 +3154,17 @@ regular_print:
}
}
}
-#line 3143 "awkgram.c"
+#line 3158 "awkgram.c"
break;
case 68: /* $@5: %empty */
-#line 1231 "awkgram.y"
+#line 1246 "awkgram.y"
{ sub_counter = 0; }
-#line 3149 "awkgram.c"
+#line 3164 "awkgram.c"
break;
case 69: /* simple_stmt: LEX_DELETE NAME $@5 delete_subscript_list */
-#line 1232 "awkgram.y"
+#line 1247 "awkgram.y"
{
char *arr = yyvsp[-2]->lextok;
@@ -3182,11 +3197,11 @@ regular_print:
yyval = list_append(list_append(yyvsp[0], yyvsp[-2]), yyvsp[-3]);
}
}
-#line 3186 "awkgram.c"
+#line 3201 "awkgram.c"
break;
case 70: /* simple_stmt: LEX_DELETE '(' NAME ')' */
-#line 1269 "awkgram.y"
+#line 1284 "awkgram.y"
{
static bool warned = false;
char *arr = yyvsp[-1]->lextok;
@@ -3212,54 +3227,54 @@ regular_print:
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
-#line 3216 "awkgram.c"
+#line 3231 "awkgram.c"
break;
case 71: /* simple_stmt: exp */
-#line 1295 "awkgram.y"
+#line 1310 "awkgram.y"
{
yyval = optimize_assignment(yyvsp[0]);
}
-#line 3224 "awkgram.c"
+#line 3239 "awkgram.c"
break;
case 72: /* opt_simple_stmt: %empty */
-#line 1302 "awkgram.y"
+#line 1317 "awkgram.y"
{ yyval = NULL; }
-#line 3230 "awkgram.c"
+#line 3245 "awkgram.c"
break;
case 73: /* opt_simple_stmt: simple_stmt */
-#line 1304 "awkgram.y"
+#line 1319 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3236 "awkgram.c"
+#line 3251 "awkgram.c"
break;
case 74: /* case_statements: %empty */
-#line 1309 "awkgram.y"
+#line 1324 "awkgram.y"
{ yyval = NULL; }
-#line 3242 "awkgram.c"
+#line 3257 "awkgram.c"
break;
case 75: /* case_statements: case_statements case_statement */
-#line 1311 "awkgram.y"
+#line 1326 "awkgram.y"
{
if (yyvsp[-1] == NULL)
yyval = list_create(yyvsp[0]);
else
yyval = list_prepend(yyvsp[-1], yyvsp[0]);
}
-#line 3253 "awkgram.c"
+#line 3268 "awkgram.c"
break;
case 76: /* case_statements: case_statements error */
-#line 1318 "awkgram.y"
+#line 1333 "awkgram.y"
{ yyval = NULL; }
-#line 3259 "awkgram.c"
+#line 3274 "awkgram.c"
break;
case 77: /* case_statement: LEX_CASE case_value colon opt_nls statements */
-#line 1323 "awkgram.y"
+#line 1338 "awkgram.y"
{
INSTRUCTION *casestmt = yyvsp[0];
if (yyvsp[0] == NULL)
@@ -3272,11 +3287,11 @@ regular_print:
bcfree(yyvsp[-2]);
yyval = yyvsp[-4];
}
-#line 3276 "awkgram.c"
+#line 3291 "awkgram.c"
break;
case 78: /* case_statement: LEX_DEFAULT colon opt_nls statements */
-#line 1336 "awkgram.y"
+#line 1351 "awkgram.y"
{
INSTRUCTION *casestmt = yyvsp[0];
if (yyvsp[0] == NULL)
@@ -3288,17 +3303,17 @@ regular_print:
yyvsp[-3]->comment = yyvsp[-1];
yyval = yyvsp[-3];
}
-#line 3292 "awkgram.c"
+#line 3307 "awkgram.c"
break;
case 79: /* case_value: YNUMBER */
-#line 1351 "awkgram.y"
+#line 1366 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3298 "awkgram.c"
+#line 3313 "awkgram.c"
break;
case 80: /* case_value: '-' YNUMBER */
-#line 1353 "awkgram.y"
+#line 1368 "awkgram.y"
{
NODE *n = yyvsp[0]->memory;
(void) force_number(n);
@@ -3306,28 +3321,28 @@ regular_print:
bcfree(yyvsp[-1]);
yyval = yyvsp[0];
}
-#line 3310 "awkgram.c"
+#line 3325 "awkgram.c"
break;
case 81: /* case_value: '+' YNUMBER */
-#line 1361 "awkgram.y"
+#line 1376 "awkgram.y"
{
NODE *n = yyvsp[0]->lasti->memory;
bcfree(yyvsp[-1]);
add_sign_to_num(n, '+');
yyval = yyvsp[0];
}
-#line 3321 "awkgram.c"
+#line 3336 "awkgram.c"
break;
case 82: /* case_value: YSTRING */
-#line 1368 "awkgram.y"
+#line 1383 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3327 "awkgram.c"
+#line 3342 "awkgram.c"
break;
case 83: /* case_value: regexp */
-#line 1370 "awkgram.y"
+#line 1385 "awkgram.y"
{
if (yyvsp[0]->memory->type == Node_regex)
yyvsp[0]->opcode = Op_push_re;
@@ -3335,57 +3350,57 @@ regular_print:
yyvsp[0]->opcode = Op_push;
yyval = yyvsp[0];
}
-#line 3339 "awkgram.c"
+#line 3354 "awkgram.c"
break;
case 84: /* case_value: typed_regexp */
-#line 1378 "awkgram.y"
+#line 1393 "awkgram.y"
{
assert((yyvsp[0]->memory->flags & REGEX) == REGEX);
yyvsp[0]->opcode = Op_push_re;
yyval = yyvsp[0];
}
-#line 3349 "awkgram.c"
+#line 3364 "awkgram.c"
break;
case 85: /* print: LEX_PRINT */
-#line 1387 "awkgram.y"
+#line 1402 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3355 "awkgram.c"
+#line 3370 "awkgram.c"
break;
case 86: /* print: LEX_PRINTF */
-#line 1389 "awkgram.y"
+#line 1404 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3361 "awkgram.c"
+#line 3376 "awkgram.c"
break;
case 88: /* print_expression_list: '(' expression_list r_paren */
-#line 1399 "awkgram.y"
+#line 1414 "awkgram.y"
{
yyval = yyvsp[-1];
}
-#line 3369 "awkgram.c"
+#line 3384 "awkgram.c"
break;
case 89: /* output_redir: %empty */
-#line 1406 "awkgram.y"
+#line 1421 "awkgram.y"
{
in_print = false;
in_parens = 0;
yyval = NULL;
}
-#line 3379 "awkgram.c"
+#line 3394 "awkgram.c"
break;
case 90: /* $@6: %empty */
-#line 1411 "awkgram.y"
+#line 1426 "awkgram.y"
{ in_print = false; in_parens = 0; }
-#line 3385 "awkgram.c"
+#line 3400 "awkgram.c"
break;
case 91: /* output_redir: IO_OUT $@6 common_exp */
-#line 1412 "awkgram.y"
+#line 1427 "awkgram.y"
{
if (yyvsp[-2]->redir_type == redirect_twoway
&& yyvsp[0]->lasti->opcode == Op_K_getline_redir
@@ -3395,22 +3410,22 @@ regular_print:
lintwarn(_("concatenation as I/O `>' redirection target is ambiguous"));
yyval = list_prepend(yyvsp[0], yyvsp[-2]);
}
-#line 3399 "awkgram.c"
+#line 3414 "awkgram.c"
break;
case 92: /* if_statement: LEX_IF '(' exp r_paren opt_nls statement */
-#line 1425 "awkgram.y"
+#line 1440 "awkgram.y"
{
if (yyvsp[-1] != NULL)
yyvsp[-5]->comment = yyvsp[-1];
add_lint(yyvsp[-3], LINT_assign_in_cond);
yyval = mk_condition(yyvsp[-3], yyvsp[-5], yyvsp[0], NULL, NULL);
}
-#line 3410 "awkgram.c"
+#line 3425 "awkgram.c"
break;
case 93: /* if_statement: LEX_IF '(' exp r_paren opt_nls statement LEX_ELSE opt_nls statement */
-#line 1433 "awkgram.y"
+#line 1448 "awkgram.y"
{
if (yyvsp[-4] != NULL)
yyvsp[-8]->comment = yyvsp[-4];
@@ -3419,19 +3434,19 @@ regular_print:
add_lint(yyvsp[-6], LINT_assign_in_cond);
yyval = mk_condition(yyvsp[-6], yyvsp[-8], yyvsp[-3], yyvsp[-2], yyvsp[0]);
}
-#line 3423 "awkgram.c"
+#line 3438 "awkgram.c"
break;
case 94: /* nls: NEWLINE */
-#line 1445 "awkgram.y"
+#line 1460 "awkgram.y"
{
yyval = yyvsp[0];
}
-#line 3431 "awkgram.c"
+#line 3446 "awkgram.c"
break;
case 95: /* nls: nls NEWLINE */
-#line 1449 "awkgram.y"
+#line 1464 "awkgram.y"
{
if (yyvsp[-1] != NULL && yyvsp[0] != NULL) {
if (yyvsp[-1]->memory->comment_type == EOL_COMMENT) {
@@ -3449,59 +3464,59 @@ regular_print:
} else
yyval = NULL;
}
-#line 3453 "awkgram.c"
+#line 3468 "awkgram.c"
break;
case 96: /* opt_nls: %empty */
-#line 1470 "awkgram.y"
+#line 1485 "awkgram.y"
{ yyval = NULL; }
-#line 3459 "awkgram.c"
+#line 3474 "awkgram.c"
break;
case 97: /* opt_nls: nls */
-#line 1472 "awkgram.y"
+#line 1487 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3465 "awkgram.c"
+#line 3480 "awkgram.c"
break;
case 98: /* input_redir: %empty */
-#line 1477 "awkgram.y"
+#line 1492 "awkgram.y"
{ yyval = NULL; }
-#line 3471 "awkgram.c"
+#line 3486 "awkgram.c"
break;
case 99: /* input_redir: '<' simp_exp */
-#line 1479 "awkgram.y"
+#line 1494 "awkgram.y"
{
bcfree(yyvsp[-1]);
yyval = yyvsp[0];
}
-#line 3480 "awkgram.c"
+#line 3495 "awkgram.c"
break;
case 100: /* opt_param_list: %empty */
-#line 1487 "awkgram.y"
+#line 1502 "awkgram.y"
{ yyval = NULL; }
-#line 3486 "awkgram.c"
+#line 3501 "awkgram.c"
break;
case 101: /* opt_param_list: param_list */
-#line 1489 "awkgram.y"
+#line 1504 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3492 "awkgram.c"
+#line 3507 "awkgram.c"
break;
case 102: /* param_list: NAME */
-#line 1494 "awkgram.y"
+#line 1509 "awkgram.y"
{
yyvsp[0]->param_count = 0;
yyval = list_create(yyvsp[0]);
}
-#line 3501 "awkgram.c"
+#line 3516 "awkgram.c"
break;
case 103: /* param_list: param_list comma NAME */
-#line 1499 "awkgram.y"
+#line 1514 "awkgram.y"
{
if (yyvsp[-2] != NULL && yyvsp[0] != NULL) {
yyvsp[0]->param_count = yyvsp[-2]->lasti->param_count + 1;
@@ -3518,76 +3533,76 @@ regular_print:
} else
yyval = NULL;
}
-#line 3522 "awkgram.c"
+#line 3537 "awkgram.c"
break;
case 104: /* param_list: error */
-#line 1516 "awkgram.y"
+#line 1531 "awkgram.y"
{ yyval = NULL; }
-#line 3528 "awkgram.c"
+#line 3543 "awkgram.c"
break;
case 105: /* param_list: param_list error */
-#line 1518 "awkgram.y"
+#line 1533 "awkgram.y"
{ yyval = yyvsp[-1]; }
-#line 3534 "awkgram.c"
+#line 3549 "awkgram.c"
break;
case 106: /* param_list: param_list comma error */
-#line 1520 "awkgram.y"
+#line 1535 "awkgram.y"
{ yyval = yyvsp[-2]; }
-#line 3540 "awkgram.c"
+#line 3555 "awkgram.c"
break;
case 107: /* opt_exp: %empty */
-#line 1526 "awkgram.y"
+#line 1541 "awkgram.y"
{ yyval = NULL; }
-#line 3546 "awkgram.c"
+#line 3561 "awkgram.c"
break;
case 108: /* opt_exp: exp */
-#line 1528 "awkgram.y"
+#line 1543 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3552 "awkgram.c"
+#line 3567 "awkgram.c"
break;
case 109: /* opt_expression_list: %empty */
-#line 1533 "awkgram.y"
+#line 1548 "awkgram.y"
{ yyval = NULL; }
-#line 3558 "awkgram.c"
+#line 3573 "awkgram.c"
break;
case 110: /* opt_expression_list: expression_list */
-#line 1535 "awkgram.y"
+#line 1550 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3564 "awkgram.c"
+#line 3579 "awkgram.c"
break;
case 111: /* expression_list: exp */
-#line 1540 "awkgram.y"
+#line 1555 "awkgram.y"
{ yyval = mk_expression_list(NULL, yyvsp[0]); }
-#line 3570 "awkgram.c"
+#line 3585 "awkgram.c"
break;
case 112: /* expression_list: expression_list comma exp */
-#line 1542 "awkgram.y"
+#line 1557 "awkgram.y"
{
if (yyvsp[-1] != NULL)
yyvsp[-2]->lasti->comment = yyvsp[-1];
yyval = mk_expression_list(yyvsp[-2], yyvsp[0]);
yyerrok;
}
-#line 3581 "awkgram.c"
+#line 3596 "awkgram.c"
break;
case 113: /* expression_list: error */
-#line 1549 "awkgram.y"
+#line 1564 "awkgram.y"
{ yyval = NULL; }
-#line 3587 "awkgram.c"
+#line 3602 "awkgram.c"
break;
case 114: /* expression_list: expression_list error */
-#line 1551 "awkgram.y"
+#line 1566 "awkgram.y"
{
/*
* Returning the expression list instead of NULL lets
@@ -3595,66 +3610,66 @@ regular_print:
*/
yyval = yyvsp[-1];
}
-#line 3599 "awkgram.c"
+#line 3614 "awkgram.c"
break;
case 115: /* expression_list: expression_list error exp */
-#line 1559 "awkgram.y"
+#line 1574 "awkgram.y"
{
/* Ditto */
yyval = mk_expression_list(yyvsp[-2], yyvsp[0]);
}
-#line 3608 "awkgram.c"
+#line 3623 "awkgram.c"
break;
case 116: /* expression_list: expression_list comma error */
-#line 1564 "awkgram.y"
+#line 1579 "awkgram.y"
{
/* Ditto */
if (yyvsp[-1] != NULL)
yyvsp[-2]->lasti->comment = yyvsp[-1];
yyval = yyvsp[-2];
}
-#line 3619 "awkgram.c"
+#line 3634 "awkgram.c"
break;
case 117: /* opt_fcall_expression_list: %empty */
-#line 1574 "awkgram.y"
+#line 1589 "awkgram.y"
{ yyval = NULL; }
-#line 3625 "awkgram.c"
+#line 3640 "awkgram.c"
break;
case 118: /* opt_fcall_expression_list: fcall_expression_list */
-#line 1576 "awkgram.y"
+#line 1591 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3631 "awkgram.c"
+#line 3646 "awkgram.c"
break;
case 119: /* fcall_expression_list: fcall_exp */
-#line 1581 "awkgram.y"
+#line 1596 "awkgram.y"
{ yyval = mk_expression_list(NULL, yyvsp[0]); }
-#line 3637 "awkgram.c"
+#line 3652 "awkgram.c"
break;
case 120: /* fcall_expression_list: fcall_expression_list comma fcall_exp */
-#line 1583 "awkgram.y"
+#line 1598 "awkgram.y"
{
if (yyvsp[-1] != NULL)
yyvsp[-2]->lasti->comment = yyvsp[-1];
yyval = mk_expression_list(yyvsp[-2], yyvsp[0]);
yyerrok;
}
-#line 3648 "awkgram.c"
+#line 3663 "awkgram.c"
break;
case 121: /* fcall_expression_list: error */
-#line 1590 "awkgram.y"
+#line 1605 "awkgram.y"
{ yyval = NULL; }
-#line 3654 "awkgram.c"
+#line 3669 "awkgram.c"
break;
case 122: /* fcall_expression_list: fcall_expression_list error */
-#line 1592 "awkgram.y"
+#line 1607 "awkgram.y"
{
/*
* Returning the expression list instead of NULL lets
@@ -3662,86 +3677,86 @@ regular_print:
*/
yyval = yyvsp[-1];
}
-#line 3666 "awkgram.c"
+#line 3681 "awkgram.c"
break;
case 123: /* fcall_expression_list: fcall_expression_list error fcall_exp */
-#line 1600 "awkgram.y"
+#line 1615 "awkgram.y"
{
/* Ditto */
yyval = mk_expression_list(yyvsp[-2], yyvsp[0]);
}
-#line 3675 "awkgram.c"
+#line 3690 "awkgram.c"
break;
case 124: /* fcall_expression_list: fcall_expression_list comma error */
-#line 1605 "awkgram.y"
+#line 1620 "awkgram.y"
{
/* Ditto */
if (yyvsp[-1] != NULL)
yyvsp[-2]->comment = yyvsp[-1];
yyval = yyvsp[-2];
}
-#line 3686 "awkgram.c"
+#line 3701 "awkgram.c"
break;
case 125: /* fcall_exp: exp */
-#line 1614 "awkgram.y"
+#line 1629 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3692 "awkgram.c"
+#line 3707 "awkgram.c"
break;
case 126: /* fcall_exp: typed_regexp */
-#line 1615 "awkgram.y"
+#line 1630 "awkgram.y"
{ yyval = list_create(yyvsp[0]); }
-#line 3698 "awkgram.c"
+#line 3713 "awkgram.c"
break;
case 127: /* opt_fcall_exp: %empty */
-#line 1620 "awkgram.y"
+#line 1635 "awkgram.y"
{ yyval = NULL; }
-#line 3704 "awkgram.c"
+#line 3719 "awkgram.c"
break;
case 128: /* opt_fcall_exp: fcall_exp */
-#line 1621 "awkgram.y"
+#line 1636 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3710 "awkgram.c"
+#line 3725 "awkgram.c"
break;
case 129: /* exp: variable assign_operator exp */
-#line 1627 "awkgram.y"
+#line 1642 "awkgram.y"
{
if (do_lint && yyvsp[0]->lasti->opcode == Op_match_rec)
lintwarn_ln(yyvsp[-1]->source_line,
_("regular expression on right of assignment"));
yyval = mk_assignment(yyvsp[-2], yyvsp[0], yyvsp[-1]);
}
-#line 3721 "awkgram.c"
+#line 3736 "awkgram.c"
break;
case 130: /* exp: variable ASSIGN typed_regexp */
-#line 1634 "awkgram.y"
+#line 1649 "awkgram.y"
{
yyval = mk_assignment(yyvsp[-2], list_create(yyvsp[0]), yyvsp[-1]);
}
-#line 3729 "awkgram.c"
+#line 3744 "awkgram.c"
break;
case 131: /* exp: exp LEX_AND exp */
-#line 1638 "awkgram.y"
+#line 1653 "awkgram.y"
{ yyval = mk_boolean(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3735 "awkgram.c"
+#line 3750 "awkgram.c"
break;
case 132: /* exp: exp LEX_OR exp */
-#line 1640 "awkgram.y"
+#line 1655 "awkgram.y"
{ yyval = mk_boolean(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3741 "awkgram.c"
+#line 3756 "awkgram.c"
break;
case 133: /* exp: exp MATCHOP typed_regexp */
-#line 1642 "awkgram.y"
+#line 1657 "awkgram.y"
{
if (yyvsp[-2]->lasti->opcode == Op_match_rec)
warning_ln(yyvsp[-1]->source_line,
@@ -3754,11 +3769,11 @@ regular_print:
bcfree(yyvsp[0]);
yyval = list_append(yyvsp[-2], yyvsp[-1]);
}
-#line 3758 "awkgram.c"
+#line 3773 "awkgram.c"
break;
case 134: /* exp: exp MATCHOP exp */
-#line 1655 "awkgram.y"
+#line 1670 "awkgram.y"
{
if (yyvsp[-2]->lasti->opcode == Op_match_rec)
warning_ln(yyvsp[-1]->source_line,
@@ -3775,11 +3790,11 @@ regular_print:
yyval = list_append(list_merge(yyvsp[-2], yyvsp[0]), yyvsp[-1]);
}
}
-#line 3779 "awkgram.c"
+#line 3794 "awkgram.c"
break;
case 135: /* exp: exp LEX_IN simple_variable */
-#line 1672 "awkgram.y"
+#line 1687 "awkgram.y"
{
if (do_lint_old)
lintwarn_ln(yyvsp[-1]->source_line,
@@ -3789,91 +3804,91 @@ regular_print:
yyvsp[-1]->expr_count = 1;
yyval = list_append(list_merge(yyvsp[-2], yyvsp[0]), yyvsp[-1]);
}
-#line 3793 "awkgram.c"
+#line 3808 "awkgram.c"
break;
case 136: /* exp: exp a_relop exp */
-#line 1682 "awkgram.y"
+#line 1697 "awkgram.y"
{
if (do_lint && yyvsp[0]->lasti->opcode == Op_match_rec)
lintwarn_ln(yyvsp[-1]->source_line,
_("regular expression on right of comparison"));
yyval = list_append(list_merge(yyvsp[-2], yyvsp[0]), yyvsp[-1]);
}
-#line 3804 "awkgram.c"
+#line 3819 "awkgram.c"
break;
case 137: /* exp: exp '?' exp ':' exp */
-#line 1689 "awkgram.y"
+#line 1704 "awkgram.y"
{ yyval = mk_condition(yyvsp[-4], yyvsp[-3], yyvsp[-2], yyvsp[-1], yyvsp[0]); }
-#line 3810 "awkgram.c"
+#line 3825 "awkgram.c"
break;
case 138: /* exp: common_exp */
-#line 1691 "awkgram.y"
+#line 1706 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3816 "awkgram.c"
+#line 3831 "awkgram.c"
break;
case 139: /* assign_operator: ASSIGN */
-#line 1696 "awkgram.y"
+#line 1711 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3822 "awkgram.c"
+#line 3837 "awkgram.c"
break;
case 140: /* assign_operator: ASSIGNOP */
-#line 1698 "awkgram.y"
+#line 1713 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3828 "awkgram.c"
+#line 3843 "awkgram.c"
break;
case 141: /* assign_operator: SLASH_BEFORE_EQUAL ASSIGN */
-#line 1700 "awkgram.y"
+#line 1715 "awkgram.y"
{
yyvsp[0]->opcode = Op_assign_quotient;
yyval = yyvsp[0];
}
-#line 3837 "awkgram.c"
+#line 3852 "awkgram.c"
break;
case 142: /* relop_or_less: RELOP */
-#line 1708 "awkgram.y"
+#line 1723 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3843 "awkgram.c"
+#line 3858 "awkgram.c"
break;
case 143: /* relop_or_less: '<' */
-#line 1710 "awkgram.y"
+#line 1725 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3849 "awkgram.c"
+#line 3864 "awkgram.c"
break;
case 144: /* a_relop: relop_or_less */
-#line 1715 "awkgram.y"
+#line 1730 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3855 "awkgram.c"
+#line 3870 "awkgram.c"
break;
case 145: /* a_relop: '>' */
-#line 1717 "awkgram.y"
+#line 1732 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3861 "awkgram.c"
+#line 3876 "awkgram.c"
break;
case 146: /* common_exp: simp_exp */
-#line 1722 "awkgram.y"
+#line 1737 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3867 "awkgram.c"
+#line 3882 "awkgram.c"
break;
case 147: /* common_exp: simp_exp_nc */
-#line 1724 "awkgram.y"
+#line 1739 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 3873 "awkgram.c"
+#line 3888 "awkgram.c"
break;
case 148: /* common_exp: common_exp simp_exp */
-#line 1726 "awkgram.y"
+#line 1741 "awkgram.y"
{
int count = 2;
bool is_simple_var = false;
@@ -3927,47 +3942,47 @@ regular_print:
max_args = count;
}
}
-#line 3931 "awkgram.c"
+#line 3946 "awkgram.c"
break;
case 150: /* simp_exp: simp_exp '^' simp_exp */
-#line 1785 "awkgram.y"
+#line 1800 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3937 "awkgram.c"
+#line 3952 "awkgram.c"
break;
case 151: /* simp_exp: simp_exp '*' simp_exp */
-#line 1787 "awkgram.y"
+#line 1802 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3943 "awkgram.c"
+#line 3958 "awkgram.c"
break;
case 152: /* simp_exp: simp_exp '/' simp_exp */
-#line 1789 "awkgram.y"
+#line 1804 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3949 "awkgram.c"
+#line 3964 "awkgram.c"
break;
case 153: /* simp_exp: simp_exp '%' simp_exp */
-#line 1791 "awkgram.y"
+#line 1806 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3955 "awkgram.c"
+#line 3970 "awkgram.c"
break;
case 154: /* simp_exp: simp_exp '+' simp_exp */
-#line 1793 "awkgram.y"
+#line 1808 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3961 "awkgram.c"
+#line 3976 "awkgram.c"
break;
case 155: /* simp_exp: simp_exp '-' simp_exp */
-#line 1795 "awkgram.y"
+#line 1810 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 3967 "awkgram.c"
+#line 3982 "awkgram.c"
break;
case 156: /* simp_exp: LEX_GETLINE opt_variable input_redir */
-#line 1797 "awkgram.y"
+#line 1812 "awkgram.y"
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3981,29 +3996,29 @@ regular_print:
_("non-redirected `getline' undefined inside END action"));
yyval = mk_getline(yyvsp[-2], yyvsp[-1], yyvsp[0], redirect_input);
}
-#line 3985 "awkgram.c"
+#line 4000 "awkgram.c"
break;
case 157: /* simp_exp: variable INCREMENT */
-#line 1811 "awkgram.y"
+#line 1826 "awkgram.y"
{
yyvsp[0]->opcode = Op_postincrement;
yyval = mk_assignment(yyvsp[-1], NULL, yyvsp[0]);
}
-#line 3994 "awkgram.c"
+#line 4009 "awkgram.c"
break;
case 158: /* simp_exp: variable DECREMENT */
-#line 1816 "awkgram.y"
+#line 1831 "awkgram.y"
{
yyvsp[0]->opcode = Op_postdecrement;
yyval = mk_assignment(yyvsp[-1], NULL, yyvsp[0]);
}
-#line 4003 "awkgram.c"
+#line 4018 "awkgram.c"
break;
case 159: /* simp_exp: '(' expression_list r_paren LEX_IN simple_variable */
-#line 1821 "awkgram.y"
+#line 1836 "awkgram.y"
{
if (do_lint_old) {
/* first one is warning so that second one comes out if warnings are fatal */
@@ -4024,64 +4039,64 @@ regular_print:
yyval = list_append(list_merge(t, yyvsp[0]), yyvsp[-1]);
}
}
-#line 4028 "awkgram.c"
+#line 4043 "awkgram.c"
break;
case 160: /* simp_exp_nc: common_exp IO_IN LEX_GETLINE opt_variable */
-#line 1847 "awkgram.y"
+#line 1862 "awkgram.y"
{
yyval = mk_getline(yyvsp[-1], yyvsp[0], yyvsp[-3], yyvsp[-2]->redir_type);
bcfree(yyvsp[-2]);
}
-#line 4037 "awkgram.c"
+#line 4052 "awkgram.c"
break;
case 161: /* simp_exp_nc: simp_exp_nc '^' simp_exp */
-#line 1853 "awkgram.y"
+#line 1868 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4043 "awkgram.c"
+#line 4058 "awkgram.c"
break;
case 162: /* simp_exp_nc: simp_exp_nc '*' simp_exp */
-#line 1855 "awkgram.y"
+#line 1870 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4049 "awkgram.c"
+#line 4064 "awkgram.c"
break;
case 163: /* simp_exp_nc: simp_exp_nc '/' simp_exp */
-#line 1857 "awkgram.y"
+#line 1872 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4055 "awkgram.c"
+#line 4070 "awkgram.c"
break;
case 164: /* simp_exp_nc: simp_exp_nc '%' simp_exp */
-#line 1859 "awkgram.y"
+#line 1874 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4061 "awkgram.c"
+#line 4076 "awkgram.c"
break;
case 165: /* simp_exp_nc: simp_exp_nc '+' simp_exp */
-#line 1861 "awkgram.y"
+#line 1876 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4067 "awkgram.c"
+#line 4082 "awkgram.c"
break;
case 166: /* simp_exp_nc: simp_exp_nc '-' simp_exp */
-#line 1863 "awkgram.y"
+#line 1878 "awkgram.y"
{ yyval = mk_binary(yyvsp[-2], yyvsp[0], yyvsp[-1]); }
-#line 4073 "awkgram.c"
+#line 4088 "awkgram.c"
break;
case 167: /* non_post_simp_exp: regexp */
-#line 1868 "awkgram.y"
+#line 1883 "awkgram.y"
{
yyval = list_create(yyvsp[0]);
}
-#line 4081 "awkgram.c"
+#line 4096 "awkgram.c"
break;
case 168: /* non_post_simp_exp: '!' simp_exp */
-#line 1872 "awkgram.y"
+#line 1887 "awkgram.y"
{
if (yyvsp[0]->opcode == Op_match_rec) {
yyvsp[0]->opcode = Op_nomatch;
@@ -4113,11 +4128,11 @@ regular_print:
}
}
}
-#line 4117 "awkgram.c"
+#line 4132 "awkgram.c"
break;
case 169: /* non_post_simp_exp: '(' exp r_paren */
-#line 1904 "awkgram.y"
+#line 1919 "awkgram.y"
{
// Always include. Allows us to lint warn on
// print "foo" > "bar" 1
@@ -4125,31 +4140,31 @@ regular_print:
// print "foo" > ("bar" 1)
yyval = list_append(yyvsp[-1], bcalloc(Op_parens, 1, sourceline));
}
-#line 4129 "awkgram.c"
+#line 4144 "awkgram.c"
break;
case 170: /* non_post_simp_exp: LEX_BUILTIN '(' opt_fcall_expression_list r_paren */
-#line 1912 "awkgram.y"
+#line 1927 "awkgram.y"
{
yyval = snode(yyvsp[-1], yyvsp[-3]);
if (yyval == NULL)
YYABORT;
}
-#line 4139 "awkgram.c"
+#line 4154 "awkgram.c"
break;
case 171: /* non_post_simp_exp: LEX_LENGTH '(' opt_fcall_expression_list r_paren */
-#line 1918 "awkgram.y"
+#line 1933 "awkgram.y"
{
yyval = snode(yyvsp[-1], yyvsp[-3]);
if (yyval == NULL)
YYABORT;
}
-#line 4149 "awkgram.c"
+#line 4164 "awkgram.c"
break;
case 172: /* non_post_simp_exp: LEX_LENGTH */
-#line 1924 "awkgram.y"
+#line 1939 "awkgram.y"
{
static bool warned = false;
@@ -4162,45 +4177,45 @@ regular_print:
if (yyval == NULL)
YYABORT;
}
-#line 4166 "awkgram.c"
+#line 4181 "awkgram.c"
break;
case 175: /* non_post_simp_exp: INCREMENT variable */
-#line 1939 "awkgram.y"
+#line 1954 "awkgram.y"
{
yyvsp[-1]->opcode = Op_preincrement;
yyval = mk_assignment(yyvsp[0], NULL, yyvsp[-1]);
}
-#line 4175 "awkgram.c"
+#line 4190 "awkgram.c"
break;
case 176: /* non_post_simp_exp: DECREMENT variable */
-#line 1944 "awkgram.y"
+#line 1959 "awkgram.y"
{
yyvsp[-1]->opcode = Op_predecrement;
yyval = mk_assignment(yyvsp[0], NULL, yyvsp[-1]);
}
-#line 4184 "awkgram.c"
+#line 4199 "awkgram.c"
break;
case 177: /* non_post_simp_exp: YNUMBER */
-#line 1949 "awkgram.y"
+#line 1964 "awkgram.y"
{
yyval = list_create(yyvsp[0]);
}
-#line 4192 "awkgram.c"
+#line 4207 "awkgram.c"
break;
case 178: /* non_post_simp_exp: YSTRING */
-#line 1953 "awkgram.y"
+#line 1968 "awkgram.y"
{
yyval = list_create(yyvsp[0]);
}
-#line 4200 "awkgram.c"
+#line 4215 "awkgram.c"
break;
case 179: /* non_post_simp_exp: '-' simp_exp */
-#line 1957 "awkgram.y"
+#line 1972 "awkgram.y"
{
if (yyvsp[0]->lasti->opcode == Op_push_i
&& (yyvsp[0]->lasti->memory->flags & STRING) == 0
@@ -4215,11 +4230,11 @@ regular_print:
yyval = list_append(yyvsp[0], yyvsp[-1]);
}
}
-#line 4219 "awkgram.c"
+#line 4234 "awkgram.c"
break;
case 180: /* non_post_simp_exp: '+' simp_exp */
-#line 1972 "awkgram.y"
+#line 1987 "awkgram.y"
{
if (yyvsp[0]->lasti->opcode == Op_push_i
&& (yyvsp[0]->lasti->memory->flags & STRING) == 0
@@ -4237,20 +4252,20 @@ regular_print:
yyval = list_append(yyvsp[0], yyvsp[-1]);
}
}
-#line 4241 "awkgram.c"
+#line 4256 "awkgram.c"
break;
case 181: /* func_call: direct_func_call */
-#line 1993 "awkgram.y"
+#line 2008 "awkgram.y"
{
func_use(yyvsp[0]->lasti->func_name, FUNC_USE);
yyval = yyvsp[0];
}
-#line 4250 "awkgram.c"
+#line 4265 "awkgram.c"
break;
case 182: /* func_call: '@' direct_func_call */
-#line 1998 "awkgram.y"
+#line 2013 "awkgram.y"
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -4284,11 +4299,11 @@ regular_print:
yyval = list_prepend(yyvsp[0], t);
at_seen = false;
}
-#line 4288 "awkgram.c"
+#line 4303 "awkgram.c"
break;
case 183: /* direct_func_call: FUNC_CALL '(' opt_fcall_expression_list r_paren */
-#line 2035 "awkgram.y"
+#line 2050 "awkgram.y"
{
NODE *n;
char *name = yyvsp[-3]->func_name;
@@ -4321,49 +4336,49 @@ regular_print:
yyval = list_append(t, yyvsp[-3]);
}
}
-#line 4325 "awkgram.c"
+#line 4340 "awkgram.c"
break;
case 184: /* opt_variable: %empty */
-#line 2071 "awkgram.y"
+#line 2086 "awkgram.y"
{ yyval = NULL; }
-#line 4331 "awkgram.c"
+#line 4346 "awkgram.c"
break;
case 185: /* opt_variable: variable */
-#line 2073 "awkgram.y"
+#line 2088 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 4337 "awkgram.c"
+#line 4352 "awkgram.c"
break;
case 186: /* delete_subscript_list: %empty */
-#line 2078 "awkgram.y"
+#line 2093 "awkgram.y"
{ yyval = NULL; }
-#line 4343 "awkgram.c"
+#line 4358 "awkgram.c"
break;
case 187: /* delete_subscript_list: delete_subscript SUBSCRIPT */
-#line 2080 "awkgram.y"
+#line 2095 "awkgram.y"
{ yyval = yyvsp[-1]; }
-#line 4349 "awkgram.c"
+#line 4364 "awkgram.c"
break;
case 188: /* delete_subscript: delete_exp_list */
-#line 2085 "awkgram.y"
+#line 2100 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 4355 "awkgram.c"
+#line 4370 "awkgram.c"
break;
case 189: /* delete_subscript: delete_subscript delete_exp_list */
-#line 2087 "awkgram.y"
+#line 2102 "awkgram.y"
{
yyval = list_merge(yyvsp[-1], yyvsp[0]);
}
-#line 4363 "awkgram.c"
+#line 4378 "awkgram.c"
break;
case 190: /* delete_exp_list: bracketed_exp_list */
-#line 2094 "awkgram.y"
+#line 2109 "awkgram.y"
{
INSTRUCTION *ip = yyvsp[0]->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated expressions */
@@ -4377,11 +4392,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
yyval = yyvsp[0];
}
-#line 4381 "awkgram.c"
+#line 4396 "awkgram.c"
break;
case 191: /* bracketed_exp_list: '[' expression_list ']' */
-#line 2111 "awkgram.y"
+#line 2126 "awkgram.y"
{
INSTRUCTION *t = yyvsp[-1];
if (yyvsp[-1] == NULL) {
@@ -4395,41 +4410,41 @@ regular_print:
yyvsp[0]->sub_count = count_expressions(&t, false);
yyval = list_append(t, yyvsp[0]);
}
-#line 4399 "awkgram.c"
+#line 4414 "awkgram.c"
break;
case 192: /* subscript: bracketed_exp_list */
-#line 2128 "awkgram.y"
+#line 2143 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 4405 "awkgram.c"
+#line 4420 "awkgram.c"
break;
case 193: /* subscript: subscript bracketed_exp_list */
-#line 2130 "awkgram.y"
+#line 2145 "awkgram.y"
{
yyval = list_merge(yyvsp[-1], yyvsp[0]);
}
-#line 4413 "awkgram.c"
+#line 4428 "awkgram.c"
break;
case 194: /* subscript_list: subscript SUBSCRIPT */
-#line 2137 "awkgram.y"
+#line 2152 "awkgram.y"
{ yyval = yyvsp[-1]; }
-#line 4419 "awkgram.c"
+#line 4434 "awkgram.c"
break;
case 195: /* simple_variable: NAME */
-#line 2142 "awkgram.y"
+#line 2157 "awkgram.y"
{
yyvsp[0]->opcode = Op_push;
yyvsp[0]->memory = variable(yyvsp[0]->source_line, yyvsp[0]->lextok, Node_var_new);
yyval = list_create(yyvsp[0]);
}
-#line 4429 "awkgram.c"
+#line 4444 "awkgram.c"
break;
case 196: /* simple_variable: NAME subscript_list */
-#line 2148 "awkgram.y"
+#line 2163 "awkgram.y"
{
char *arr = yyvsp[-1]->lextok;
@@ -4437,11 +4452,11 @@ regular_print:
yyvsp[-1]->opcode = Op_push_array;
yyval = list_prepend(yyvsp[0], yyvsp[-1]);
}
-#line 4441 "awkgram.c"
+#line 4456 "awkgram.c"
break;
case 197: /* variable: simple_variable */
-#line 2159 "awkgram.y"
+#line 2174 "awkgram.y"
{
INSTRUCTION *ip = yyvsp[0]->nexti;
if (ip->opcode == Op_push
@@ -4453,85 +4468,85 @@ regular_print:
} else
yyval = yyvsp[0];
}
-#line 4457 "awkgram.c"
+#line 4472 "awkgram.c"
break;
case 198: /* variable: '$' non_post_simp_exp opt_incdec */
-#line 2171 "awkgram.y"
+#line 2186 "awkgram.y"
{
yyval = list_append(yyvsp[-1], yyvsp[-2]);
if (yyvsp[0] != NULL)
mk_assignment(yyvsp[-1], NULL, yyvsp[0]);
}
-#line 4467 "awkgram.c"
+#line 4482 "awkgram.c"
break;
case 199: /* opt_incdec: INCREMENT */
-#line 2180 "awkgram.y"
+#line 2195 "awkgram.y"
{
yyvsp[0]->opcode = Op_postincrement;
}
-#line 4475 "awkgram.c"
+#line 4490 "awkgram.c"
break;
case 200: /* opt_incdec: DECREMENT */
-#line 2184 "awkgram.y"
+#line 2199 "awkgram.y"
{
yyvsp[0]->opcode = Op_postdecrement;
}
-#line 4483 "awkgram.c"
+#line 4498 "awkgram.c"
break;
case 201: /* opt_incdec: %empty */
-#line 2188 "awkgram.y"
+#line 2203 "awkgram.y"
{ yyval = NULL; }
-#line 4489 "awkgram.c"
+#line 4504 "awkgram.c"
break;
case 202: /* l_brace: '{' opt_nls */
-#line 2192 "awkgram.y"
+#line 2207 "awkgram.y"
{ yyval = yyvsp[0]; }
-#line 4495 "awkgram.c"
+#line 4510 "awkgram.c"
break;
case 203: /* r_brace: '}' opt_nls */
-#line 2196 "awkgram.y"
+#line 2211 "awkgram.y"
{ yyval = yyvsp[0]; yyerrok; }
-#line 4501 "awkgram.c"
+#line 4516 "awkgram.c"
break;
case 204: /* r_paren: ')' */
-#line 2200 "awkgram.y"
+#line 2215 "awkgram.y"
{ yyerrok; }
-#line 4507 "awkgram.c"
+#line 4522 "awkgram.c"
break;
case 205: /* opt_semi: %empty */
-#line 2205 "awkgram.y"
+#line 2220 "awkgram.y"
{ yyval = NULL; }
-#line 4513 "awkgram.c"
+#line 4528 "awkgram.c"
break;
case 207: /* semi: ';' */
-#line 2210 "awkgram.y"
+#line 2225 "awkgram.y"
{ yyerrok; }
-#line 4519 "awkgram.c"
+#line 4534 "awkgram.c"
break;
case 208: /* colon: ':' */
-#line 2214 "awkgram.y"
+#line 2229 "awkgram.y"
{ yyval = yyvsp[0]; yyerrok; }
-#line 4525 "awkgram.c"
+#line 4540 "awkgram.c"
break;
case 209: /* comma: ',' opt_nls */
-#line 2218 "awkgram.y"
+#line 2233 "awkgram.y"
{ yyval = yyvsp[0]; yyerrok; }
-#line 4531 "awkgram.c"
+#line 4546 "awkgram.c"
break;
-#line 4535 "awkgram.c"
+#line 4550 "awkgram.c"
default: break;
}
@@ -4724,7 +4739,7 @@ yyreturnlab:
return yyresult;
}
-#line 2220 "awkgram.y"
+#line 2235 "awkgram.y"
struct token {
@@ -6586,6 +6601,9 @@ retry:
yylval = GET_INSTRUCTION(Op_token);
if (want_source) {
yylval->lextok = estrdup(tokstart, tok - tokstart);
+ // See the comment in the production for @namespace.
+ if (want_namespace)
+ change_namespace(yylval->lextok);
return lasttok = FILENAME;
}
@@ -6926,6 +6944,8 @@ retry:
switch (class) {
case LEX_NAMESPACE:
+ want_namespace = true;
+ // fall through
case LEX_INCLUDE:
case LEX_LOAD:
want_source = true;
@@ -9326,7 +9346,7 @@ done:
return i;
}
-/* set_namespace --- change the current namespace */
+/* set_namespace --- update namespace data structures */
static void
set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
@@ -9357,13 +9377,9 @@ set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
return;
}
- if (strcmp(ns->lextok, current_namespace) == 0)
- ; // nothing to do
- else if (strcmp(ns->lextok, awk_namespace) == 0) {
- set_current_namespace(awk_namespace);
- } else {
- set_current_namespace(estrdup(ns->lextok, strlen(ns->lextok)));
- }
+ // Actual changing of namespace is done earlier.
+ // See comments in the production and in yylex().
+
efree(ns->lextok);
// save info and push on front of list of namespaces seen
@@ -9376,11 +9392,35 @@ set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
ns->lextok = NULL;
bcfree(ns);
- namespace_changed = true;
-
return;
}
+/* change_namespace --- change the current namespace */
+
+static void
+change_namespace(const char *new_namespace)
+{
+ /* error messages will come from set_namespace(), above */
+
+ if (! is_valid_identifier(new_namespace))
+ return;
+
+ int mid = check_special(new_namespace);
+
+ if (mid >= 0)
+ return;
+
+ if (strcmp(new_namespace, current_namespace) == 0)
+ ; // nothing to do
+ else if (strcmp(new_namespace, awk_namespace) == 0) {
+ set_current_namespace(awk_namespace);
+ } else {
+ set_current_namespace(estrdup(new_namespace, strlen(new_namespace)));
+ }
+
+ namespace_changed = true;
+}
+
/* qualify_name --- put name into namespace */
static char *
diff --git a/awkgram.y b/awkgram.y
index 0729d353..2ec91545 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -57,6 +57,7 @@ static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t
static bool include_source(INSTRUCTION *file, void **srcfile_p);
static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void set_namespace(INSTRUCTION *ns, INSTRUCTION *comment);
+static void change_namespace(const char *new_namespace);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
@@ -112,6 +113,7 @@ static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
static bool want_source = false;
+static bool want_namespace = false;
static bool want_regexp = false; /* lexical scanning kludge */
static enum {
FUNC_HEADER,
@@ -317,7 +319,20 @@ rule
}
| '@' LEX_NAMESPACE namespace statement_term
{
+ /*
+ * 1/2022:
+ * We have an interesting isssue here. This production isn't
+ * reduced until after the token following the statement_term
+ * is seen. As a result, the change in namespace doesn't take
+ * effect until then. That's fine if the first token is 'function'
+ * or BEGIN or some such, but it's a disaster if it's an identifer;
+ * that identifier will be in the previous namespace.
+ * Therefore, the actual setting of the namespace is done immediately
+ * down in the scanner.
+ */
+
want_source = false;
+ want_namespace = false;
at_seen = false;
// this frees $3 storage in all cases
@@ -4078,6 +4093,9 @@ retry:
yylval = GET_INSTRUCTION(Op_token);
if (want_source) {
yylval->lextok = estrdup(tokstart, tok - tokstart);
+ // See the comment in the production for @namespace.
+ if (want_namespace)
+ change_namespace(yylval->lextok);
return lasttok = FILENAME;
}
@@ -4418,6 +4436,8 @@ retry:
switch (class) {
case LEX_NAMESPACE:
+ want_namespace = true;
+ // fall through
case LEX_INCLUDE:
case LEX_LOAD:
want_source = true;
@@ -6818,7 +6838,7 @@ done:
return i;
}
-/* set_namespace --- change the current namespace */
+/* set_namespace --- update namespace data structures */
static void
set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
@@ -6849,13 +6869,9 @@ set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
return;
}
- if (strcmp(ns->lextok, current_namespace) == 0)
- ; // nothing to do
- else if (strcmp(ns->lextok, awk_namespace) == 0) {
- set_current_namespace(awk_namespace);
- } else {
- set_current_namespace(estrdup(ns->lextok, strlen(ns->lextok)));
- }
+ // Actual changing of namespace is done earlier.
+ // See comments in the production and in yylex().
+
efree(ns->lextok);
// save info and push on front of list of namespaces seen
@@ -6868,11 +6884,35 @@ set_namespace(INSTRUCTION *ns, INSTRUCTION *comment)
ns->lextok = NULL;
bcfree(ns);
- namespace_changed = true;
-
return;
}
+/* change_namespace --- change the current namespace */
+
+static void
+change_namespace(const char *new_namespace)
+{
+ /* error messages will come from set_namespace(), above */
+
+ if (! is_valid_identifier(new_namespace))
+ return;
+
+ int mid = check_special(new_namespace);
+
+ if (mid >= 0)
+ return;
+
+ if (strcmp(new_namespace, current_namespace) == 0)
+ ; // nothing to do
+ else if (strcmp(new_namespace, awk_namespace) == 0) {
+ set_current_namespace(awk_namespace);
+ } else {
+ set_current_namespace(estrdup(new_namespace, strlen(new_namespace)));
+ }
+
+ namespace_changed = true;
+}
+
/* qualify_name --- put name into namespace */
static char *
diff --git a/pc/ChangeLog b/pc/ChangeLog
index d2b2c564..2ca19739 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2022-01-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.tst: Regenerated.
+
2021-12-01 Arnold D. Robbins <arnold@skeeve.com>
* gawkmisc.pc (os_maybe_set_errno): Renamed from
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 97be2756..5569e571 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -202,7 +202,7 @@ GAWK_EXT_TESTS = \
mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \
next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 nsawk1a nsawk1b \
nsawk1c nsawk2a nsawk2b nsbad nsbad_cmd nsforloop nsfuncrecurse \
- nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
+ nsidentifier nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
profile0 profile1 profile2 profile3 profile4 profile5 profile6 \
profile7 profile8 profile9 profile10 profile11 profile12 profile13 \
@@ -3051,6 +3051,11 @@ nsfuncrecurse:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+nsidentifier:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
nsindirect1:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/symbol.c b/symbol.c
index be01369c..300fa871 100644
--- a/symbol.c
+++ b/symbol.c
@@ -604,7 +604,10 @@ load_symbols()
|| r->type == Node_var
|| r->type == Node_var_array
|| r->type == Node_var_new) {
- tmp = make_string(r->vname, strlen(r->vname));
+ if (strncmp(r->vname, "awk::", 5) == 0)
+ tmp = make_string(r->vname + 5, strlen(r->vname) - 5);
+ else
+ tmp = make_string(r->vname, strlen(r->vname));
aptr = assoc_lookup(sym_array, tmp);
unref(tmp);
unref(*aptr);
diff --git a/test/ChangeLog b/test/ChangeLog
index 1fb76bab..7db73f3c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2022-01-05 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (EXTRA_DIST): nsidentifier, new test.
+ * nsidentifier.awk, nsidentifier.ok: New files.
+
2021-12-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
* iolint.awk, iolint.ok: Reorder "cat" pipe/output file test to reduce
diff --git a/test/Makefile.am b/test/Makefile.am
index b74056ec..abd1fc00 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -848,6 +848,8 @@ EXTRA_DIST = \
nsforloop.ok \
nsfuncrecurse.awk \
nsfuncrecurse.ok \
+ nsidentifier.awk \
+ nsidentifier.ok \
nsindirect1.awk \
nsindirect1.ok \
nsindirect2.awk \
@@ -1453,7 +1455,7 @@ GAWK_EXT_TESTS = \
mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \
next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 nsawk1a nsawk1b \
nsawk1c nsawk2a nsawk2b nsbad nsbad_cmd nsforloop nsfuncrecurse \
- nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
+ nsidentifier nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
profile0 profile1 profile2 profile3 profile4 profile5 profile6 \
profile7 profile8 profile9 profile10 profile11 profile12 profile13 \
diff --git a/test/Makefile.in b/test/Makefile.in
index d56e90d1..ab45c3aa 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1114,6 +1114,8 @@ EXTRA_DIST = \
nsforloop.ok \
nsfuncrecurse.awk \
nsfuncrecurse.ok \
+ nsidentifier.awk \
+ nsidentifier.ok \
nsindirect1.awk \
nsindirect1.ok \
nsindirect2.awk \
@@ -1719,7 +1721,7 @@ GAWK_EXT_TESTS = \
mbstr2 mixed1 mktime modifiers muldimposix nastyparm negtime \
next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 nsawk1a nsawk1b \
nsawk1c nsawk2a nsawk2b nsbad nsbad_cmd nsforloop nsfuncrecurse \
- nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
+ nsidentifier nsindirect1 nsindirect2 nsprof1 nsprof2 octdec patsplit posix \
printfbad1 printfbad2 printfbad3 printfbad4 printhuge procinfs \
profile0 profile1 profile2 profile3 profile4 profile5 profile6 \
profile7 profile8 profile9 profile10 profile11 profile12 profile13 \
@@ -4727,6 +4729,11 @@ nsfuncrecurse:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+nsidentifier:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
nsindirect1:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 9e00cd57..4c4cfa62 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1790,6 +1790,11 @@ nsfuncrecurse:
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+nsidentifier:
+ @echo $@
+ @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
nsindirect1:
@echo $@
@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/nsidentifier.awk b/test/nsidentifier.awk
new file mode 100644
index 00000000..0c665289
--- /dev/null
+++ b/test/nsidentifier.awk
@@ -0,0 +1,36 @@
+# Overdocumented Test Case for FUNCTAB
+
+@namespace "ns"
+
+ns1 = 1 # ns::ns1
+ns::ns2 = 2 # ns::ns2
+awk::defined_in_ns3 = 3 # defined_in_ns3
+@namespace "awk"
+awkspace4 = 4 # awkspace4
+awk::awkspace5 = 5 # awkspace5
+
+BEGIN {
+ list = "awk::defined_in_ns3 awk::awkspace5 ns1 ns::ns1 ns::ns2 awkspace4 awkspace5" # list
+ n = split(list, test) # n, test
+ for (i = 1; i <= n; i++) { # i
+ var = test[i] # var
+ sub(/awk::/, "", var) # no 'awk::' in SYMTAB or SYMTAB
+
+ yesno = (test[i] in FUNCTAB) ? "Yes" : "No " # yesno
+ printf("%s %s in FUNCTAB\n", yesno, test[i])
+ yesno = (test[i] in PROCINFO["identifiers"]) ? "Yes" : "No "
+ printf("%s %s in PROCINFO[\"identifiers\"]\n", yesno, test[i])
+
+ yesno = (var in SYMTAB) ? "Yes" : "No "
+ printf("%s %s in SYMTAB\n", yesno, var)
+ yesno = (var in PROCINFO["identifiers"]) ? "Yes" :"No "
+ printf("%s %s in PROCINFO[\"identifiers\"]\n", yesno, var)
+ printf("\n")
+ }
+ print "------------------------------"
+ for (i in PROCINFO["identifiers"])
+ print i | "LC_ALL=C sort"
+ close("LC_ALL=C sort")
+
+ exit 0
+}
diff --git a/test/nsidentifier.ok b/test/nsidentifier.ok
new file mode 100644
index 00000000..5743f94c
--- /dev/null
+++ b/test/nsidentifier.ok
@@ -0,0 +1,118 @@
+No awk::defined_in_ns3 in FUNCTAB
+No awk::defined_in_ns3 in PROCINFO["identifiers"]
+Yes defined_in_ns3 in SYMTAB
+Yes defined_in_ns3 in PROCINFO["identifiers"]
+
+No awk::awkspace5 in FUNCTAB
+No awk::awkspace5 in PROCINFO["identifiers"]
+Yes awkspace5 in SYMTAB
+Yes awkspace5 in PROCINFO["identifiers"]
+
+No ns1 in FUNCTAB
+No ns1 in PROCINFO["identifiers"]
+No ns1 in SYMTAB
+No ns1 in PROCINFO["identifiers"]
+
+No ns::ns1 in FUNCTAB
+Yes ns::ns1 in PROCINFO["identifiers"]
+Yes ns::ns1 in SYMTAB
+Yes ns::ns1 in PROCINFO["identifiers"]
+
+No ns::ns2 in FUNCTAB
+Yes ns::ns2 in PROCINFO["identifiers"]
+Yes ns::ns2 in SYMTAB
+Yes ns::ns2 in PROCINFO["identifiers"]
+
+No awkspace4 in FUNCTAB
+Yes awkspace4 in PROCINFO["identifiers"]
+Yes awkspace4 in SYMTAB
+Yes awkspace4 in PROCINFO["identifiers"]
+
+No awkspace5 in FUNCTAB
+Yes awkspace5 in PROCINFO["identifiers"]
+Yes awkspace5 in SYMTAB
+Yes awkspace5 in PROCINFO["identifiers"]
+
+------------------------------
+ARGC
+ARGIND
+ARGV
+BINMODE
+CONVFMT
+ENVIRON
+ERRNO
+FIELDWIDTHS
+FILENAME
+FNR
+FPAT
+FS
+FUNCTAB
+IGNORECASE
+LINT
+NF
+NR
+OFMT
+OFS
+ORS
+PREC
+PROCINFO
+RLENGTH
+ROUNDMODE
+RS
+RSTART
+RT
+SUBSEP
+SYMTAB
+TEXTDOMAIN
+and
+asort
+asorti
+atan2
+awkspace4
+awkspace5
+bindtextdomain
+close
+compl
+cos
+dcgettext
+dcngettext
+defined_in_ns3
+exp
+fflush
+gensub
+gsub
+i
+index
+int
+isarray
+length
+list
+log
+lshift
+match
+mktime
+n
+ns::ns1
+ns::ns2
+or
+patsplit
+rand
+rshift
+sin
+split
+sprintf
+sqrt
+srand
+strftime
+strtonum
+sub
+substr
+system
+systime
+test
+tolower
+toupper
+typeof
+var
+xor
+yesno