diff options
-rw-r--r-- | ChangeLog | 59 | ||||
-rw-r--r-- | a.awk | 7 | ||||
-rw-r--r-- | awk.h | 8 | ||||
-rw-r--r-- | awkgram.c | 2129 | ||||
-rw-r--r-- | awkgram.y | 125 | ||||
-rw-r--r-- | builtin.c | 56 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 1231 | ||||
-rw-r--r-- | doc/gawk.texi | 125 | ||||
-rw-r--r-- | doc/gawktexi.in | 125 | ||||
-rw-r--r-- | eval.c | 6 | ||||
-rw-r--r-- | hardregex-semantics.awk | 296 | ||||
-rw-r--r-- | hardregex.txt | 24 | ||||
-rw-r--r-- | profile.c | 38 | ||||
-rw-r--r-- | re.c | 15 | ||||
-rw-r--r-- | test/ChangeLog | 1 | ||||
-rw-r--r-- | test/id.ok | 1 | ||||
-rw-r--r-- | x.awk | 9 | ||||
-rw-r--r-- | y.awk | 1 | ||||
-rw-r--r-- | z.awk | 1 | ||||
-rw-r--r-- | z2.awk | 8 | ||||
-rw-r--r-- | z3.awk | 19 |
22 files changed, 2734 insertions, 1555 deletions
@@ -8,6 +8,14 @@ * config.guess, config.sub: Get latest versions. + Make profiling for hard regexes work. + + * profile.c (pp_string_or_hard_regex): Renamed from pp_string. + Add bool param for hard regex and add @ if so. + (pp_string): New function, calls pp_string_or_hard_regex. + (pp_hard_regex): New function, calls pp_string_or_hard_regex. + (pprint): Adjust to print a hard regex correctly. + 2015-05-01 Arnold D. Robbins <arnold@skeeve.com> * awkgram.y: Make sure values are not null in param list. @@ -32,6 +40,11 @@ 2015-04-28 Arnold D. Robbins <arnold@skeeve.com> + * builtin.c (isarray): Add lint warning that isarray() + is deprecated. + +2015-04-28 Arnold D. Robbins <arnold@skeeve.com> + * awkgram.y (yylex): Rework the bracket handling from zero. Thanks to Michal Jaegermann for yet another test case. @@ -118,6 +131,11 @@ * builtin.c (do_sub): Improve some variable names for readability and add / expand some comments. + Unrelated: + + * builtin.c (call_sub, call_match, call_split_func): Allow for + regex to be Node_hardregex. + 2015-04-14 Andrew J. Schorr <aschorr@telemetry-investments.com> Arnold D. Robbins <arnold@skeeve.com> @@ -125,6 +143,7 @@ to malloc, test for final amount after all matches done and need to copy in the final part of the original string. + 2015-04-13 Arnold D. Robbins <arnold@skeeve.com> * regcomp.c (analyze): Prevent malloc(0). @@ -196,6 +215,14 @@ Thanks to Andrew Schorr for finding the problem and supplying initial code; I did it slightly differently. +2015-04-03 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h (force_string): If hard_regex, return string text of the regex. + (force_string, force_number): If hard_regex, return Nnull_string. + * awkgram.y: Fix ~ and !~ with @/.../. + * eval.c (setup_frame): Handle a hard regex. + * re.c (avoid_dfa): Ditto. + 2015-04-02 Andrew J. Schorr <aschorr@telemetry-investments.com> * NEWS: Rename div to intdiv. @@ -260,6 +287,24 @@ * interpret.h (r_interpret): If calling do_sub, do it through call_sub_func(). +2015-03-19 Arnold D. Robbins <arnold@skeeve.com> + + * re.c (re_update): Handle hard regex - for sub/gsub/gensub. + * awkgram.y (grammar): Add support for hard_regex with ~ and !~; + allowed only on the right hand side. + (mk_rexp): Handle a hard regex. + +2015-03-18 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_typeof): Be smarter about checking for uninitialized + values; can now detect and return "untyped" for such values. + * awkgram.y (yylex): Collect @/.../ entirely in the lexer and return + a new terminal (HARD_REGEX). + (regexp): Reverted to just a regular awk regexp constant. + (hard_regexp): New nonterminal, can be used only in direct + assignment and as an argument in function call. New set of nonterminals + for function call expression lists. More work still to do. + 2015-03-18 Arnold D. Robbins <arnold@skeeve.com> * config.guess, config.sub: Updated, from libtool 2.4.6. @@ -301,6 +346,20 @@ a long-standing problem where `-lm' was used twice in the final compilation line. +2015-02-27 Arnold D. Robbins <arnold@skeeve.com> + + Start on making regexp a real type. + + * awk.h (Node_hardregex): New node type. + (do_typeof): Add declaration. + * awkgram.y: Make @/.../ a hard regex. + (tokentab): New entry for typeof() function. + (snode): Try to handle typeof(). + (make_regnode): Handle Node_hardregex. + * builtin.c (do_typeof): New function. + * eval.c (nodetypes): Add Node_hardregex. + * re.c (re_update): Check for hardregex too in assert. + 2015-02-24 Arnold D. Robbins <arnold@skeeve.com> * POSIX.STD: Update copyright year. @@ -0,0 +1,7 @@ +BEGIN { + f = "foo" + p = "o+" + fun = "match" + @fun(f, p) + print RSTART, RLENGTH +} @@ -277,6 +277,7 @@ typedef enum nodevals { Node_val, /* node is a value - type in flags */ Node_regex, /* a regexp, text, compiled, flags, etc */ Node_dynregex, /* a dynamic regexp */ + Node_hardregex, /* like Node_regex, but is a real type */ /* symbol table values */ Node_var, /* scalar variable, lnode is value */ @@ -1384,6 +1385,7 @@ extern NODE *do_dcgettext(int nargs); extern NODE *do_dcngettext(int nargs); extern NODE *do_bindtextdomain(int nargs); extern NODE *do_intdiv(int nargs); +extern NODE *do_typeof(int nargs); extern int strncasecmpmbs(const unsigned char *, const unsigned char *, size_t); /* eval.c */ @@ -1763,6 +1765,9 @@ dupnode(NODE *n) static inline NODE * force_string(NODE *s) { + if (s->type == Node_hardregex) + return s->re_exp; + if ((s->flags & STRCUR) != 0 && (s->stfmt == -1 || s->stfmt == CONVFMTidx) ) @@ -1785,6 +1790,9 @@ unref(NODE *r) static inline NODE * force_number(NODE *n) { + if (n->type == Node_hardregex) + return Nnull_string; + return (n->flags & NUMCUR) != 0 ? n : str2number(n); } @@ -245,51 +245,52 @@ extern int yydebug; FILENAME = 261, YNUMBER = 262, YSTRING = 263, - RELOP = 264, - IO_OUT = 265, - IO_IN = 266, - ASSIGNOP = 267, - ASSIGN = 268, - MATCHOP = 269, - CONCAT_OP = 270, - SUBSCRIPT = 271, - LEX_BEGIN = 272, - LEX_END = 273, - LEX_IF = 274, - LEX_ELSE = 275, - LEX_RETURN = 276, - LEX_DELETE = 277, - LEX_SWITCH = 278, - LEX_CASE = 279, - LEX_DEFAULT = 280, - LEX_WHILE = 281, - LEX_DO = 282, - LEX_FOR = 283, - LEX_BREAK = 284, - LEX_CONTINUE = 285, - LEX_PRINT = 286, - LEX_PRINTF = 287, - LEX_NEXT = 288, - LEX_EXIT = 289, - LEX_FUNCTION = 290, - LEX_BEGINFILE = 291, - LEX_ENDFILE = 292, - LEX_GETLINE = 293, - LEX_NEXTFILE = 294, - LEX_IN = 295, - LEX_AND = 296, - LEX_OR = 297, - INCREMENT = 298, - DECREMENT = 299, - LEX_BUILTIN = 300, - LEX_LENGTH = 301, - LEX_EOF = 302, - LEX_INCLUDE = 303, - LEX_EVAL = 304, - LEX_LOAD = 305, - NEWLINE = 306, - SLASH_BEFORE_EQUAL = 307, - UNARY = 308 + HARD_REGEXP = 264, + RELOP = 265, + IO_OUT = 266, + IO_IN = 267, + ASSIGNOP = 268, + ASSIGN = 269, + MATCHOP = 270, + CONCAT_OP = 271, + SUBSCRIPT = 272, + LEX_BEGIN = 273, + LEX_END = 274, + LEX_IF = 275, + LEX_ELSE = 276, + LEX_RETURN = 277, + LEX_DELETE = 278, + LEX_SWITCH = 279, + LEX_CASE = 280, + LEX_DEFAULT = 281, + LEX_WHILE = 282, + LEX_DO = 283, + LEX_FOR = 284, + LEX_BREAK = 285, + LEX_CONTINUE = 286, + LEX_PRINT = 287, + LEX_PRINTF = 288, + LEX_NEXT = 289, + LEX_EXIT = 290, + LEX_FUNCTION = 291, + LEX_BEGINFILE = 292, + LEX_ENDFILE = 293, + LEX_GETLINE = 294, + LEX_NEXTFILE = 295, + LEX_IN = 296, + LEX_AND = 297, + LEX_OR = 298, + INCREMENT = 299, + DECREMENT = 300, + LEX_BUILTIN = 301, + LEX_LENGTH = 302, + LEX_EOF = 303, + LEX_INCLUDE = 304, + LEX_EVAL = 305, + LEX_LOAD = 306, + NEWLINE = 307, + SLASH_BEFORE_EQUAL = 308, + UNARY = 309 }; #endif /* Tokens. */ @@ -299,51 +300,52 @@ extern int yydebug; #define FILENAME 261 #define YNUMBER 262 #define YSTRING 263 -#define RELOP 264 -#define IO_OUT 265 -#define IO_IN 266 -#define ASSIGNOP 267 -#define ASSIGN 268 -#define MATCHOP 269 -#define CONCAT_OP 270 -#define SUBSCRIPT 271 -#define LEX_BEGIN 272 -#define LEX_END 273 -#define LEX_IF 274 -#define LEX_ELSE 275 -#define LEX_RETURN 276 -#define LEX_DELETE 277 -#define LEX_SWITCH 278 -#define LEX_CASE 279 -#define LEX_DEFAULT 280 -#define LEX_WHILE 281 -#define LEX_DO 282 -#define LEX_FOR 283 -#define LEX_BREAK 284 -#define LEX_CONTINUE 285 -#define LEX_PRINT 286 -#define LEX_PRINTF 287 -#define LEX_NEXT 288 -#define LEX_EXIT 289 -#define LEX_FUNCTION 290 -#define LEX_BEGINFILE 291 -#define LEX_ENDFILE 292 -#define LEX_GETLINE 293 -#define LEX_NEXTFILE 294 -#define LEX_IN 295 -#define LEX_AND 296 -#define LEX_OR 297 -#define INCREMENT 298 -#define DECREMENT 299 -#define LEX_BUILTIN 300 -#define LEX_LENGTH 301 -#define LEX_EOF 302 -#define LEX_INCLUDE 303 -#define LEX_EVAL 304 -#define LEX_LOAD 305 -#define NEWLINE 306 -#define SLASH_BEFORE_EQUAL 307 -#define UNARY 308 +#define HARD_REGEXP 264 +#define RELOP 265 +#define IO_OUT 266 +#define IO_IN 267 +#define ASSIGNOP 268 +#define ASSIGN 269 +#define MATCHOP 270 +#define CONCAT_OP 271 +#define SUBSCRIPT 272 +#define LEX_BEGIN 273 +#define LEX_END 274 +#define LEX_IF 275 +#define LEX_ELSE 276 +#define LEX_RETURN 277 +#define LEX_DELETE 278 +#define LEX_SWITCH 279 +#define LEX_CASE 280 +#define LEX_DEFAULT 281 +#define LEX_WHILE 282 +#define LEX_DO 283 +#define LEX_FOR 284 +#define LEX_BREAK 285 +#define LEX_CONTINUE 286 +#define LEX_PRINT 287 +#define LEX_PRINTF 288 +#define LEX_NEXT 289 +#define LEX_EXIT 290 +#define LEX_FUNCTION 291 +#define LEX_BEGINFILE 292 +#define LEX_ENDFILE 293 +#define LEX_GETLINE 294 +#define LEX_NEXTFILE 295 +#define LEX_IN 296 +#define LEX_AND 297 +#define LEX_OR 298 +#define INCREMENT 299 +#define DECREMENT 300 +#define LEX_BUILTIN 301 +#define LEX_LENGTH 302 +#define LEX_EOF 303 +#define LEX_INCLUDE 304 +#define LEX_EVAL 305 +#define LEX_LOAD 306 +#define NEWLINE 307 +#define SLASH_BEFORE_EQUAL 308 +#define UNARY 309 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED @@ -361,7 +363,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 365 "awkgram.c" /* yacc.c:358 */ +#line 367 "awkgram.c" /* yacc.c:358 */ #ifdef short # undef short @@ -603,21 +605,21 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1098 +#define YYLAST 1236 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 75 +#define YYNTOKENS 76 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 66 +#define YYNNTS 70 /* YYNRULES -- Number of rules. */ -#define YYNRULES 189 +#define YYNRULES 203 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 336 +#define YYNSTATES 350 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 308 +#define YYMAXUTOK 309 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -629,16 +631,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 63, 2, 2, 66, 62, 2, 2, - 67, 68, 60, 58, 55, 59, 2, 61, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 54, 74, - 56, 2, 57, 53, 69, 2, 2, 2, 2, 2, + 2, 2, 2, 64, 2, 2, 67, 63, 2, 2, + 68, 69, 61, 59, 56, 60, 2, 62, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 55, 75, + 57, 2, 58, 54, 70, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 70, 2, 71, 65, 2, 2, 2, 2, 2, + 2, 71, 2, 72, 66, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 72, 2, 73, 2, 2, 2, 2, + 2, 2, 2, 73, 2, 74, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -656,7 +658,7 @@ static const yytype_uint8 yytranslate[] = 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 64 + 45, 46, 47, 48, 49, 50, 51, 52, 53, 65 }; #if YYDEBUG @@ -666,22 +668,24 @@ static const yytype_uint16 yyrline[] = 0, 210, 210, 212, 217, 218, 222, 234, 239, 250, 257, 263, 272, 280, 282, 287, 295, 297, 303, 311, 321, 351, 365, 379, 387, 398, 410, 412, 414, 420, - 428, 429, 433, 433, 469, 468, 502, 504, 509, 515, - 543, 548, 549, 553, 555, 557, 564, 654, 696, 738, - 851, 858, 865, 875, 884, 893, 902, 913, 929, 928, - 952, 964, 964, 1062, 1062, 1095, 1125, 1131, 1132, 1138, - 1139, 1146, 1151, 1163, 1177, 1179, 1187, 1192, 1194, 1202, - 1204, 1213, 1214, 1222, 1227, 1227, 1238, 1242, 1250, 1251, - 1254, 1256, 1261, 1262, 1271, 1272, 1277, 1282, 1291, 1293, - 1295, 1302, 1303, 1309, 1310, 1315, 1317, 1322, 1324, 1332, - 1337, 1346, 1353, 1355, 1357, 1373, 1383, 1390, 1392, 1397, - 1399, 1401, 1409, 1411, 1416, 1418, 1423, 1425, 1427, 1477, - 1479, 1481, 1483, 1485, 1487, 1489, 1491, 1505, 1510, 1515, - 1540, 1546, 1548, 1550, 1552, 1554, 1556, 1561, 1565, 1597, - 1599, 1605, 1611, 1624, 1625, 1626, 1631, 1636, 1640, 1644, - 1659, 1672, 1677, 1714, 1743, 1744, 1750, 1751, 1756, 1758, - 1765, 1782, 1799, 1801, 1808, 1813, 1821, 1831, 1843, 1852, - 1856, 1860, 1864, 1868, 1872, 1875, 1877, 1881, 1885, 1889 + 428, 429, 433, 433, 469, 468, 502, 524, 526, 531, + 537, 565, 570, 571, 575, 577, 579, 586, 676, 718, + 760, 873, 880, 887, 897, 906, 915, 924, 935, 951, + 950, 974, 986, 986, 1084, 1084, 1117, 1147, 1153, 1154, + 1160, 1161, 1168, 1173, 1185, 1199, 1201, 1209, 1214, 1216, + 1224, 1233, 1235, 1244, 1245, 1253, 1258, 1258, 1269, 1273, + 1281, 1282, 1285, 1287, 1292, 1293, 1302, 1303, 1308, 1313, + 1322, 1324, 1326, 1333, 1334, 1340, 1341, 1346, 1348, 1353, + 1355, 1363, 1368, 1377, 1378, 1383, 1385, 1390, 1392, 1400, + 1405, 1413, 1414, 1419, 1426, 1430, 1432, 1434, 1447, 1464, + 1474, 1481, 1483, 1488, 1490, 1492, 1500, 1502, 1507, 1509, + 1514, 1516, 1518, 1568, 1570, 1572, 1574, 1576, 1578, 1580, + 1582, 1596, 1601, 1606, 1631, 1637, 1639, 1641, 1643, 1645, + 1647, 1652, 1656, 1688, 1690, 1696, 1702, 1715, 1716, 1717, + 1722, 1727, 1731, 1735, 1750, 1763, 1768, 1805, 1834, 1835, + 1841, 1842, 1847, 1849, 1856, 1873, 1890, 1892, 1899, 1904, + 1912, 1922, 1934, 1943, 1947, 1951, 1955, 1959, 1963, 1966, + 1968, 1972, 1976, 1980 }; #endif @@ -691,30 +695,32 @@ static const yytype_uint16 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "FUNC_CALL", "NAME", "REGEXP", - "FILENAME", "YNUMBER", "YSTRING", "RELOP", "IO_OUT", "IO_IN", "ASSIGNOP", - "ASSIGN", "MATCHOP", "CONCAT_OP", "SUBSCRIPT", "LEX_BEGIN", "LEX_END", - "LEX_IF", "LEX_ELSE", "LEX_RETURN", "LEX_DELETE", "LEX_SWITCH", - "LEX_CASE", "LEX_DEFAULT", "LEX_WHILE", "LEX_DO", "LEX_FOR", "LEX_BREAK", - "LEX_CONTINUE", "LEX_PRINT", "LEX_PRINTF", "LEX_NEXT", "LEX_EXIT", - "LEX_FUNCTION", "LEX_BEGINFILE", "LEX_ENDFILE", "LEX_GETLINE", - "LEX_NEXTFILE", "LEX_IN", "LEX_AND", "LEX_OR", "INCREMENT", "DECREMENT", - "LEX_BUILTIN", "LEX_LENGTH", "LEX_EOF", "LEX_INCLUDE", "LEX_EVAL", - "LEX_LOAD", "NEWLINE", "SLASH_BEFORE_EQUAL", "'?'", "':'", "','", "'<'", - "'>'", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", - "'('", "')'", "'@'", "'['", "']'", "'{'", "'}'", "';'", "$accept", - "program", "rule", "source", "library", "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", "if_statement", "nls", "opt_nls", "input_redir", - "opt_param_list", "param_list", "opt_exp", "opt_expression_list", - "expression_list", "exp", "assign_operator", "relop_or_less", "a_relop", - "common_exp", "simp_exp", "simp_exp_nc", "non_post_simp_exp", - "func_call", "direct_func_call", "opt_variable", "delete_subscript_list", - "delete_subscript", "delete_exp_list", "bracketed_exp_list", "subscript", - "subscript_list", "simple_variable", "variable", "opt_incdec", "l_brace", - "r_brace", "r_paren", "opt_semi", "semi", "colon", "comma", YY_NULLPTR + "FILENAME", "YNUMBER", "YSTRING", "HARD_REGEXP", "RELOP", "IO_OUT", + "IO_IN", "ASSIGNOP", "ASSIGN", "MATCHOP", "CONCAT_OP", "SUBSCRIPT", + "LEX_BEGIN", "LEX_END", "LEX_IF", "LEX_ELSE", "LEX_RETURN", "LEX_DELETE", + "LEX_SWITCH", "LEX_CASE", "LEX_DEFAULT", "LEX_WHILE", "LEX_DO", + "LEX_FOR", "LEX_BREAK", "LEX_CONTINUE", "LEX_PRINT", "LEX_PRINTF", + "LEX_NEXT", "LEX_EXIT", "LEX_FUNCTION", "LEX_BEGINFILE", "LEX_ENDFILE", + "LEX_GETLINE", "LEX_NEXTFILE", "LEX_IN", "LEX_AND", "LEX_OR", + "INCREMENT", "DECREMENT", "LEX_BUILTIN", "LEX_LENGTH", "LEX_EOF", + "LEX_INCLUDE", "LEX_EVAL", "LEX_LOAD", "NEWLINE", "SLASH_BEFORE_EQUAL", + "'?'", "':'", "','", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", "'%'", + "'!'", "UNARY", "'^'", "'$'", "'('", "')'", "'@'", "'['", "']'", "'{'", + "'}'", "';'", "$accept", "program", "rule", "source", "library", + "pattern", "action", "func_name", "lex_builtin", "function_prologue", + "$@1", "regexp", "$@2", "hard_regexp", "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", + "if_statement", "nls", "opt_nls", "input_redir", "opt_param_list", + "param_list", "opt_exp", "opt_expression_list", "expression_list", + "opt_fcall_expression_list", "fcall_expression_list", "fcall_exp", "exp", + "assign_operator", "relop_or_less", "a_relop", "common_exp", "simp_exp", + "simp_exp_nc", "non_post_simp_exp", "func_call", "direct_func_call", + "opt_variable", "delete_subscript_list", "delete_subscript", + "delete_exp_list", "bracketed_exp_list", "subscript", "subscript_list", + "simple_variable", "variable", "opt_incdec", "l_brace", "r_brace", + "r_paren", "opt_semi", "semi", "colon", "comma", YY_NULLPTR }; #endif @@ -728,60 +734,61 @@ static const yytype_uint16 yytoknum[] = 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 63, 58, 44, 60, 62, 43, 45, - 42, 47, 37, 33, 308, 94, 36, 40, 41, 64, - 91, 93, 123, 125, 59 + 305, 306, 307, 308, 63, 58, 44, 60, 62, 43, + 45, 42, 47, 37, 33, 309, 94, 36, 40, 41, + 64, 91, 93, 123, 125, 59 }; # endif -#define YYPACT_NINF -271 +#define YYPACT_NINF -275 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-271))) + (!!((Yystate) == (-275))) -#define YYTABLE_NINF -105 +#define YYTABLE_NINF -115 #define yytable_value_is_error(Yytable_value) \ - (!!((Yytable_value) == (-105))) + (!!((Yytable_value) == (-115))) /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { - -271, 359, -271, -271, -35, 3, -271, -271, -271, -271, - 241, -271, -271, 42, 42, 42, 9, 50, -271, -271, - -271, 1002, 1002, -271, 1002, 287, 804, 31, -271, 83, - 5, -271, -271, 72, 219, 975, 426, 456, -271, -271, - -271, -271, 162, 772, 804, -271, 14, -271, -271, -271, - -271, -271, 77, 66, -271, 80, -271, -271, -271, 772, - 772, 168, 93, -6, 93, 93, 1002, 10, -271, -271, - 27, 333, 44, 124, -271, 114, -271, -271, -271, 72, - -271, 114, -271, 173, -271, -271, 1002, 169, 1002, 1002, - 1002, 114, -271, -271, -271, 1002, 142, 426, 1002, 1002, - 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, - -271, -271, -271, -271, 172, 1002, 119, 158, 741, 15, - -271, -271, -271, -271, 1002, -271, 119, 119, 333, -271, - -271, -271, 1002, 114, -271, 151, 850, -271, -271, 4, - -10, -271, 17, -10, 72, -271, 579, -271, -271, 62, - -271, 249, 373, 1041, 1002, 104, 42, -13, -13, 93, - 93, 93, 93, -13, -13, 93, 93, 93, 93, -271, - 741, -271, -271, 25, 426, -271, -271, 741, -271, 169, - -271, 741, -271, -271, -271, -271, -271, 125, -271, 23, - 127, 133, 114, 134, -10, -10, -271, -271, -10, 1002, - -10, 114, -271, -271, -10, -271, -271, 741, -271, 130, - 114, 1002, 741, -271, -271, -271, 119, 61, -271, 1002, - 1002, -271, 189, 1002, 1002, 693, 883, -271, -271, -271, - -10, 741, -271, -271, -271, 625, 579, 114, -271, -271, - 741, 114, -271, 35, 333, -10, 3, 148, 333, 333, - 194, -19, -271, 130, -271, 804, 226, -271, -271, -271, - -271, -271, -271, 114, -271, -271, 41, -271, -271, -271, - 114, 114, 175, 169, 114, 27, -271, -271, 693, -271, - -271, 5, 693, 1002, 119, 726, 151, 1002, 220, -271, - -271, 333, 114, 155, 114, 975, 114, 126, 114, 693, - 114, 929, 693, -271, 384, 192, -271, 176, -271, -271, - 929, 119, -271, -271, -271, 243, 245, -271, 192, -271, - 114, -271, 119, 114, -271, -271, 114, -271, 114, 693, - -271, 431, 693, -271, 505, -271 + -275, 376, -275, -275, -12, -9, -275, -275, -275, -275, + 171, -275, -275, 44, 44, 44, 5, 40, -275, -275, + -275, 1139, 1139, -275, 1139, 1166, 869, 27, -275, -18, + 2, -275, -275, 89, 884, 1065, 192, 214, -275, -275, + -275, -275, 248, 795, 869, -275, 10, -275, -275, -275, + -275, -275, 116, 82, -275, 115, -275, -275, -275, 795, + 795, 166, 107, 104, 107, 107, 1139, 117, -275, -275, + 15, 349, 23, 45, -275, 125, -275, -275, -275, 89, + -275, 125, -275, 178, -275, -275, 1092, 172, 1139, 1139, + 1139, 125, -275, -275, -275, 1139, 146, 192, 1139, 1139, + 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, 1139, + -275, 181, -275, -275, 173, 1139, -275, -275, -275, 128, + 73, -275, 1107, 14, 1107, -275, -275, -275, -275, 1139, + -275, 128, 128, 349, -275, -275, -275, 1139, 125, -275, + 152, 916, -275, -275, 16, 92, -275, 20, 92, 89, + -275, 599, -275, -275, -275, 148, -275, 124, 22, 1048, + 1139, 199, 44, 265, 265, 107, 107, 107, 107, 265, + 265, 107, 107, 107, 107, -275, -275, 1107, -275, 1092, + 842, -275, 43, 192, -275, -275, 1107, -275, 172, -275, + 1107, -275, -275, -275, -275, -275, 133, -275, 41, 144, + 145, 125, 147, 92, 92, -275, -275, 92, 1139, 92, + 125, -275, -275, 92, -275, -275, 1107, -275, 151, 125, + 1139, 1107, -275, -275, -275, -275, -275, -275, 128, 76, + -275, 1139, 1139, -275, 224, 1139, 1139, 715, 949, -275, + -275, -275, 92, 1107, -275, -275, -275, 646, 599, 125, + -275, -275, 1107, 125, -275, 49, 349, 92, -9, 160, + 349, 349, 206, 113, -275, 151, -275, 869, 225, -275, + 169, -275, -275, -275, -275, -275, 125, -275, -275, 11, + -275, -275, -275, 125, 125, 179, 172, 125, 15, -275, + -275, 715, -275, -275, 2, 715, 1139, 128, 762, 152, + 1139, 219, -275, -275, 349, 125, 275, 125, 1065, 125, + 112, 125, 715, 125, 997, 715, -275, 261, 205, -275, + 191, -275, -275, 997, 128, -275, -275, -275, 271, 272, + -275, -275, 205, -275, 125, -275, 128, 125, -275, -275, + 125, -275, 125, 715, -275, 449, 715, -275, 524, -275 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -789,64 +796,65 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 0, 1, 6, 0, 175, 157, 158, 21, 22, - 0, 23, 24, 164, 0, 0, 0, 152, 5, 88, - 37, 0, 0, 36, 0, 0, 0, 0, 3, 0, - 0, 147, 34, 4, 19, 118, 126, 127, 129, 153, - 161, 177, 154, 0, 0, 172, 0, 176, 27, 26, - 30, 31, 0, 0, 28, 92, 165, 155, 156, 0, - 0, 0, 160, 154, 159, 148, 0, 181, 154, 107, - 0, 105, 0, 0, 162, 90, 187, 7, 8, 41, - 38, 90, 9, 0, 89, 122, 0, 0, 0, 0, - 0, 90, 123, 125, 124, 0, 0, 128, 0, 0, + 2, 0, 1, 6, 0, 189, 171, 172, 21, 22, + 0, 23, 24, 178, 0, 0, 0, 166, 5, 90, + 38, 0, 0, 37, 0, 0, 0, 0, 3, 0, + 0, 161, 34, 4, 19, 132, 140, 141, 143, 167, + 175, 191, 168, 0, 0, 186, 0, 190, 27, 26, + 30, 31, 0, 0, 28, 94, 179, 169, 170, 0, + 0, 0, 174, 168, 173, 162, 0, 195, 168, 109, + 0, 107, 0, 0, 176, 92, 201, 7, 8, 42, + 39, 92, 9, 0, 91, 136, 0, 0, 0, 0, + 0, 92, 137, 139, 138, 0, 0, 142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 120, 119, 137, 138, 0, 0, 0, 0, 105, 0, - 174, 173, 29, 32, 0, 136, 0, 0, 0, 179, - 180, 178, 108, 90, 184, 0, 0, 149, 14, 0, - 0, 17, 0, 0, 91, 182, 0, 42, 35, 114, - 115, 112, 113, 0, 0, 116, 164, 134, 135, 131, - 132, 133, 130, 145, 146, 142, 143, 144, 141, 121, - 111, 163, 171, 0, 93, 150, 151, 109, 189, 0, - 110, 106, 13, 10, 16, 11, 40, 0, 58, 0, - 0, 0, 90, 0, 0, 0, 79, 80, 0, 101, - 0, 90, 39, 52, 0, 61, 45, 66, 38, 185, - 90, 0, 20, 140, 98, 96, 0, 0, 139, 0, - 101, 63, 0, 0, 0, 0, 67, 53, 54, 55, - 0, 102, 56, 183, 60, 0, 0, 90, 186, 43, - 117, 90, 99, 0, 0, 0, 166, 0, 0, 0, - 0, 175, 68, 0, 57, 0, 83, 81, 44, 25, - 33, 100, 97, 90, 59, 64, 0, 168, 170, 65, - 90, 90, 0, 0, 90, 0, 84, 62, 0, 167, - 169, 0, 0, 0, 0, 0, 82, 0, 86, 69, - 47, 0, 90, 0, 90, 85, 90, 0, 90, 0, - 90, 67, 0, 71, 0, 0, 70, 0, 48, 49, - 67, 0, 87, 74, 77, 0, 0, 78, 0, 188, - 90, 46, 0, 90, 76, 75, 90, 38, 90, 0, - 38, 0, 0, 51, 0, 50 + 134, 133, 151, 152, 0, 0, 117, 36, 122, 0, + 0, 115, 121, 0, 107, 188, 187, 29, 32, 0, + 150, 0, 0, 0, 193, 194, 192, 110, 92, 198, + 0, 0, 163, 14, 0, 0, 17, 0, 0, 93, + 196, 0, 43, 35, 127, 128, 129, 125, 126, 0, + 0, 130, 178, 148, 149, 145, 146, 147, 144, 159, + 160, 156, 157, 158, 155, 124, 135, 123, 177, 118, + 0, 185, 0, 95, 164, 165, 111, 203, 0, 112, + 108, 13, 10, 16, 11, 41, 0, 59, 0, 0, + 0, 92, 0, 0, 0, 81, 82, 0, 103, 0, + 92, 40, 53, 0, 62, 46, 67, 39, 199, 92, + 0, 20, 154, 119, 120, 116, 100, 98, 0, 0, + 153, 0, 103, 64, 0, 0, 0, 0, 68, 54, + 55, 56, 0, 104, 57, 197, 61, 0, 0, 92, + 200, 44, 131, 92, 101, 0, 0, 0, 180, 0, + 0, 0, 0, 189, 69, 0, 58, 0, 85, 83, + 0, 45, 25, 33, 102, 99, 92, 60, 65, 0, + 182, 184, 66, 92, 92, 0, 0, 92, 0, 86, + 63, 0, 181, 183, 0, 0, 0, 0, 0, 84, + 0, 88, 70, 48, 0, 92, 0, 92, 87, 92, + 0, 92, 0, 92, 68, 0, 72, 0, 0, 71, + 0, 49, 50, 68, 0, 89, 75, 78, 0, 0, + 79, 80, 0, 202, 92, 47, 0, 92, 77, 76, + 92, 39, 92, 0, 39, 0, 0, 52, 0, 51 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -271, -271, -271, -271, -271, -271, 218, -271, -271, -271, - -271, -40, -271, -271, -206, 113, -150, -271, -271, -218, - -271, -271, -270, -271, -271, -271, -271, -271, -271, -271, - -271, 43, 29, -271, -271, -271, 47, -45, -20, -1, - -271, -271, -271, -18, 39, -271, 246, -271, 8, 112, - -271, -271, 11, -39, -271, -271, -70, -2, -271, -26, - -227, -60, -271, -28, -38, 64 + -275, -275, -275, -275, -275, -275, 252, -275, -275, -275, + -275, -33, -275, -80, -275, -213, 100, -144, -275, -275, + -231, -275, -275, -274, -275, -275, -275, -275, -275, -275, + -275, -275, 7, 62, -275, -275, -275, 54, -275, -43, + 1, -275, -23, -1, -275, -275, -275, -13, 17, -275, + 263, -275, 8, 127, -275, -275, 21, -36, -275, -275, + -78, -2, -275, -27, -230, -65, -275, -15, -38, -94 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 28, 140, 143, 29, 77, 53, 54, 30, - 173, 31, 83, 32, 146, 78, 202, 203, 220, 204, - 235, 246, 253, 297, 306, 318, 205, 256, 277, 287, - 206, 144, 145, 125, 216, 217, 230, 116, 117, 207, - 115, 94, 95, 35, 36, 37, 38, 39, 40, 55, - 265, 266, 267, 45, 46, 47, 41, 42, 131, 208, - 209, 137, 237, 210, 320, 136 + -1, 1, 28, 145, 148, 29, 77, 53, 54, 30, + 182, 31, 83, 118, 32, 151, 78, 211, 212, 232, + 213, 247, 258, 265, 310, 319, 332, 214, 268, 290, + 300, 215, 149, 150, 130, 228, 229, 242, 269, 70, + 119, 120, 121, 216, 115, 94, 95, 35, 36, 37, + 38, 39, 40, 55, 278, 279, 280, 45, 46, 47, + 41, 42, 136, 217, 218, 142, 249, 219, 334, 141 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -854,294 +862,325 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 34, 81, 236, 80, 80, 182, 70, 121, 252, 258, - 135, 56, 57, 58, 126, 127, 132, 150, 184, 63, - 63, 273, 63, 68, 119, 71, 214, 221, 132, 215, - 120, 311, 43, 63, 4, 74, 261, 112, 113, 262, - 322, 19, 118, 118, 33, 138, 5, 100, 101, 102, - 139, 44, 103, 129, 130, -12, 171, 279, 118, 118, - 62, 64, 242, 65, 76, 128, 175, 176, -15, 74, - 133, 85, 79, 44, 97, 250, 59, 75, -12, 72, - 321, 73, 133, 252, 44, 149, 172, 151, 152, 153, - 222, -15, 252, -94, 155, 134, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 25, 218, - 147, 44, 81, -105, 170, 81, 133, 60, 92, 93, - 154, 331, 63, 84, 334, 141, 122, 303, 288, -95, - 142, 177, 290, 123, 19, 181, 124, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 309, - 304, 305, 312, 212, 56, 75, 241, 76, 103, 132, - -105, -105, 178, 174, 85, 19, 81, 81, -104, 86, - 81, 4, 81, 5, 110, 111, 81, 19, 148, 333, - 156, 238, 335, 79, 263, 169, 79, 134, 270, 271, - 257, 179, 219, 247, 223, 87, 88, 89, 231, -90, - 224, 226, 81, 284, 76, 112, 113, 268, 90, -104, - 240, 92, 93, 133, 114, 286, 269, 81, 244, 231, - 272, 225, 248, 249, 292, 274, -104, 268, 85, 76, - 233, 298, -104, 86, 118, 275, 276, 79, 79, 239, - 296, 79, 283, 79, 48, 49, 319, 79, 82, 201, - 324, 323, 325, 183, 71, 289, 185, 294, 85, 87, - 88, 89, 328, 86, 317, 300, 259, 245, 213, 295, - 260, 67, 90, 79, 91, 92, 93, 280, 0, 0, - 326, 243, 291, 0, 293, 63, 50, 51, 79, 87, - 4, 5, 278, 63, 6, 7, 0, 0, 0, 281, - 282, 0, 0, 285, 0, 92, 93, 227, 228, 0, - 52, 229, 0, 232, 0, 0, 0, 234, 0, 0, - 0, 299, 0, 301, 0, 302, 307, 308, 0, 310, - 14, 15, 16, 17, 97, 0, 0, 0, 0, 20, - 0, 0, 85, 254, 0, 21, 22, 86, 23, 327, - 24, 0, 329, 25, 66, 330, 61, 332, 264, 2, - 3, 0, 4, 5, 0, 0, 6, 7, 0, 0, - 0, 0, 0, 87, 88, 89, 8, 9, 0, 0, - 0, 0, 85, 0, 0, 0, 90, 86, 0, 92, - 93, 313, 314, 0, 10, 11, 12, 13, 0, 0, - 0, 134, 14, 15, 16, 17, 18, 0, 0, 0, - 19, 20, 0, 87, 88, 0, 0, 21, 22, 0, - 23, 0, 24, 0, 0, 25, 26, 0, 27, 92, - 93, -18, 186, -18, 4, 5, 20, 0, 6, 7, - 0, 0, 315, 316, 0, 23, 0, 0, 0, 0, - 187, 0, 188, 189, 190, -73, -73, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 0, 0, 0, 13, - 200, 0, 0, 0, 14, 15, 16, 17, 0, 0, - 0, 0, -73, 20, 98, 99, 100, 101, 102, 21, - 22, 103, 23, 0, 24, 0, 0, 25, 26, 0, - 61, 0, 0, 75, -73, 76, 186, 0, 4, 5, - 0, 0, 6, 7, 104, 105, 106, 107, 108, 0, - 0, 109, 0, 0, 187, 0, 188, 189, 190, -72, - -72, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 0, 0, 0, 13, 200, 0, 0, 0, 14, 15, - 16, 17, 0, 0, 0, 0, -72, 20, 0, 0, + 34, 123, 80, 80, 248, 140, 154, 264, 33, 156, + 126, 56, 57, 58, 81, 137, 137, 191, 271, 63, + 63, 193, 63, 68, 143, 71, 180, 125, 292, 144, + 4, 175, 85, 63, 19, 74, 79, 86, 62, 64, + 324, 65, 122, 124, 226, 233, 146, 227, 5, 336, + 274, 147, 97, 275, 178, 75, 43, 76, 122, 122, + 131, 132, 44, 87, 88, 133, 184, 185, -12, 74, + 138, 138, -15, 59, 179, 75, 72, 254, 73, 92, + 93, 44, 44, 264, 139, 155, 181, 157, 158, 159, + 335, -12, 264, 262, 161, -15, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 60, 234, + 230, 25, -96, 316, 177, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 174, 63, 345, 138, + 81, 348, 138, 81, 85, 255, 186, 317, 318, 86, + 190, 84, -114, 152, 19, -97, 183, 301, 112, 113, + 128, 303, 79, 160, 286, 79, 223, 225, 85, 221, + 56, 134, 135, 253, 19, 87, 127, 76, 322, 4, + 137, 325, 129, 103, 48, 49, 5, 19, 122, 122, + -106, 92, 93, 153, 44, 162, -92, 176, 81, 81, + 117, 276, 81, 188, 81, 283, 284, 139, 81, 347, + 187, 231, 349, 250, 270, 92, 93, 243, 297, -115, + 79, 79, 235, 236, 79, 238, 79, 50, 51, 252, + 79, -106, 281, 299, 288, 138, 76, 81, 259, 282, + 256, 243, 305, 285, 260, 261, 289, 331, -106, 311, + 309, 52, 81, 281, -106, 192, 124, 296, 194, 79, + 287, 98, 99, 100, 101, 102, -115, -115, 103, 337, + 333, 110, 111, 237, 79, 210, 71, 302, 326, 327, + 117, 342, 245, 104, 105, 106, 107, 108, 338, 339, + 109, 251, 82, 307, 330, 85, 257, 308, 67, 222, + 86, 313, 112, 113, 340, 304, 0, 306, 63, 0, + 293, 114, 0, 239, 240, 0, 63, 241, 0, 244, + 0, 272, 0, 246, 20, 273, 87, 88, 89, 0, + 328, 329, 0, 23, 0, 97, 100, 101, 102, 90, + 0, 103, 92, 93, 0, 0, 0, 0, 291, 0, + 0, 0, 266, 0, 0, 294, 295, 0, 0, 298, + 76, 0, 0, 0, 0, 0, 0, 277, 0, 85, + 0, 0, 0, 0, 86, 0, 0, 312, 0, 314, + 0, 315, 320, 321, 0, 323, 2, 3, 0, 4, + 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, + 87, 88, 89, 0, 8, 9, 341, 0, 0, 343, + 0, 0, 344, 90, 346, 0, 92, 93, 0, 0, + 0, 0, 10, 11, 12, 13, 0, 0, 139, 0, + 14, 15, 16, 17, 18, 0, 0, 0, 19, 20, + 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 26, 0, 27, 0, 0, -18, + 195, -18, 4, 5, 0, 0, 6, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, + 0, 197, 198, 199, -74, -74, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 0, 0, 0, 13, 209, + 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, + 0, -74, 20, 0, 0, 0, 0, 0, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 0, 61, + 0, 0, 75, -74, 76, 195, 0, 4, 5, 0, + 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 196, 0, 197, 198, 199, -73, + -73, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 0, 0, 0, 13, 209, 0, 0, 0, 14, 15, + 16, 17, 0, 0, 0, 0, -73, 20, 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, - 0, 25, 26, 0, 61, 0, 0, 75, -72, 76, - 186, 0, 4, 5, 0, 0, 6, 7, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 187, 0, - 188, 189, 190, 0, 0, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 0, 0, 0, 13, 200, 0, - 0, 0, 14, 15, 16, 17, 69, 0, 4, 5, - 0, 20, 6, 7, 0, -103, 0, 21, 22, 0, - 23, 0, 24, 0, 0, 25, 26, 0, 61, 0, - 0, 75, 201, 76, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 13, 0, 0, 0, 0, 14, 15, - 16, 17, 0, 0, 0, 0, -103, 20, 0, 0, - 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, - 0, 25, 255, -103, 61, 0, 4, 5, 0, -103, - 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 187, 0, 188, 189, 190, 0, 0, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 0, 4, - 5, 13, 200, 6, 7, 0, 14, 15, 16, 17, + 0, 25, 26, 0, 61, 0, 0, 75, -73, 76, + 195, 0, 4, 5, 0, 0, 6, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 196, + 0, 197, 198, 199, 0, 0, 200, 201, 202, 203, + 204, 205, 206, 207, 208, 0, 0, 0, 13, 209, + 0, 0, 0, 14, 15, 16, 17, 69, 0, 4, + 5, 0, 20, 6, 7, 0, 0, -105, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 0, 61, + 0, 0, 75, 210, 76, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, + 14, 15, 16, 17, 0, 0, 0, 0, -105, 20, + 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 267, -105, 61, 0, 4, 5, + 0, -105, 6, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 196, 0, 197, 198, 199, + 0, 0, 200, 201, 202, 203, 204, 205, 206, 207, + 208, 0, 0, 0, 13, 209, 0, 0, 0, 14, + 15, 16, 17, 0, 0, 4, 5, 0, 20, 6, + 7, 0, 0, 0, 21, 22, 0, 23, 0, 24, + 0, 0, 25, 26, 0, 61, 0, 0, 75, 0, + 76, 0, 0, 0, 0, 0, 116, 0, 4, 5, + 0, 13, 6, 7, 117, 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, - 85, 21, 22, 0, 23, 86, 24, 0, 0, 25, - 26, 0, 61, 0, 13, 75, 0, 76, 0, 14, - 15, 16, 17, 69, 0, 4, 5, 0, 20, 6, - 7, 87, 88, 89, 21, 22, 0, 23, 0, 24, - 0, 0, 25, 26, 90, 61, 0, 92, 93, 0, - 76, 0, 0, 0, 0, 69, 0, 4, 5, 0, - 13, 6, 7, 0, 0, 14, 15, 16, 17, 0, - 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, - 21, 22, 0, 23, 0, 24, 0, 0, 25, 26, - -103, 61, 13, 0, 0, 0, 0, 14, 15, 16, - 17, 180, 0, 4, 5, 0, 20, 6, 7, 0, - 0, 0, 21, 22, 0, 23, 0, 24, 0, 0, - 25, 26, 0, 61, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4, 251, 13, 0, - 6, 7, 0, 14, 15, 16, 17, 0, 0, 0, - 0, 0, 20, 0, 0, 189, 0, 0, 21, 22, - 0, 23, 0, 24, 196, 197, 25, 26, 0, 61, - 0, 13, 0, 0, 0, 0, 14, 15, 16, 17, - 0, 0, 4, 5, 0, 20, 6, 7, 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, 0, 25, - 26, 189, 61, 0, 0, 0, 0, 0, 0, 0, - 196, 197, 0, 0, 0, 0, 0, 13, 0, 0, - 0, 0, 14, 15, 16, 17, 0, 0, 4, 5, - 0, 20, 6, 7, 0, 0, 96, 21, 22, 0, - 23, 0, 24, 0, 0, 25, 26, 0, 61, 0, - 0, 0, 0, 0, 0, 4, 5, 0, 0, 6, - 7, 0, 0, 13, 0, 0, 0, 0, 14, 15, - 16, 17, 0, 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, - 85, 0, 0, 0, 20, 86, 0, 0, 0, 0, - 21, 22, 0, 23, 0, 24, 0, 0, 25, 26, - 0, 61, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 87, 88, 89, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 90, 211, 0, 92, 93 + 26, 0, 61, 0, 13, 0, 0, 76, 0, 14, + 15, 16, 17, 224, 0, 4, 5, 0, 20, 6, + 7, 117, 0, 0, 21, 22, 0, 23, 0, 24, + 0, 0, 25, 26, -113, 61, 0, 0, 0, 0, + 69, 0, 4, 5, 0, 0, 6, 7, 0, 0, + 0, 13, 0, 0, 0, 0, 14, 15, 16, 17, + 0, 0, 0, 0, 85, 20, 0, 0, 0, 86, + 0, 21, 22, 0, 23, 0, 24, 0, 13, 25, + 26, 0, 61, 14, 15, 16, 17, 189, 0, 4, + 5, 0, 20, 6, 7, 87, 88, 89, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 90, 61, + 91, 92, 93, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4, 263, 0, 13, 6, 7, 0, 0, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 20, + 0, 0, 198, 0, 0, 21, 22, 0, 23, 0, + 24, 205, 206, 25, 26, 0, 61, 0, 13, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, + 4, 5, 20, 0, 6, 7, 0, 0, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 0, 61, + 198, 0, 0, 0, 0, 0, 0, 0, 0, 205, + 206, 0, 0, 0, 0, 0, 13, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, 0, 0, + 20, 0, 0, 0, 0, 0, 21, 22, 85, 23, + 0, 24, 0, 86, 25, 26, 0, 61, 4, 5, + 0, 0, 6, 7, 0, 0, 0, 96, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, + 88, 89, 0, 0, 0, 4, 5, 0, 0, 6, + 7, 117, 90, 220, 13, 92, 93, 0, 0, 14, + 15, 16, 17, 0, 0, 0, 0, 85, 20, 0, + 0, 0, 86, 0, 21, 22, 0, 23, 0, 24, + 0, 13, 25, 26, 0, 61, 14, 15, 16, 17, + 0, 0, 4, 5, 0, 20, 6, 7, 87, 88, + 89, 21, 22, 0, 23, 0, 24, 0, 0, 25, + 26, 90, 61, 0, 92, 93, 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, 0, 20, 0, 0, 0, 0, 0, 21, 22, + 0, 23, 0, 24, 0, 0, 25, 26, 0, 61, + 14, 15, 16, 17, 0, 0, 0, 0, 0, 20, + 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 66, 0, 61 }; static const yytype_int16 yycheck[] = { - 1, 29, 208, 29, 30, 1, 26, 46, 226, 236, - 70, 13, 14, 15, 59, 60, 1, 87, 1, 21, - 22, 40, 24, 25, 44, 26, 1, 4, 1, 4, - 16, 301, 67, 35, 3, 27, 1, 43, 44, 4, - 310, 51, 43, 44, 1, 1, 4, 60, 61, 62, - 6, 70, 65, 43, 44, 51, 116, 16, 59, 60, - 21, 22, 1, 24, 74, 66, 126, 127, 51, 61, - 55, 9, 29, 70, 35, 225, 67, 72, 74, 48, - 307, 50, 55, 301, 70, 86, 71, 88, 89, 90, - 67, 74, 310, 68, 95, 68, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 66, 179, - 81, 70, 140, 9, 115, 143, 55, 67, 56, 57, - 91, 327, 124, 51, 330, 1, 49, 1, 278, 68, - 6, 132, 282, 67, 51, 136, 56, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 299, - 24, 25, 302, 154, 156, 72, 216, 74, 65, 1, - 56, 57, 133, 124, 9, 51, 194, 195, 10, 14, - 198, 3, 200, 4, 12, 13, 204, 51, 5, 329, - 38, 209, 332, 140, 244, 13, 143, 68, 248, 249, - 235, 40, 67, 4, 67, 40, 41, 42, 199, 73, - 67, 67, 230, 273, 74, 43, 44, 246, 53, 51, - 211, 56, 57, 55, 52, 275, 68, 245, 219, 220, - 26, 192, 223, 224, 284, 253, 68, 266, 9, 74, - 201, 291, 74, 14, 235, 255, 10, 194, 195, 210, - 20, 198, 67, 200, 3, 4, 54, 204, 30, 73, - 7, 311, 7, 140, 255, 281, 143, 285, 9, 40, - 41, 42, 322, 14, 304, 293, 237, 220, 156, 287, - 241, 25, 53, 230, 55, 56, 57, 266, -1, -1, - 318, 217, 283, -1, 285, 287, 45, 46, 245, 40, - 3, 4, 263, 295, 7, 8, -1, -1, -1, 270, - 271, -1, -1, 274, -1, 56, 57, 194, 195, -1, - 69, 198, -1, 200, -1, -1, -1, 204, -1, -1, - -1, 292, -1, 294, -1, 296, 297, 298, -1, 300, - 43, 44, 45, 46, 295, -1, -1, -1, -1, 52, - -1, -1, 9, 230, -1, 58, 59, 14, 61, 320, - 63, -1, 323, 66, 67, 326, 69, 328, 245, 0, + 1, 44, 29, 30, 217, 70, 86, 238, 1, 87, + 46, 13, 14, 15, 29, 1, 1, 1, 248, 21, + 22, 1, 24, 25, 1, 26, 120, 17, 17, 6, + 3, 111, 10, 35, 52, 27, 29, 15, 21, 22, + 314, 24, 43, 44, 1, 4, 1, 4, 4, 323, + 1, 6, 35, 4, 119, 73, 68, 75, 59, 60, + 59, 60, 71, 41, 42, 66, 131, 132, 52, 61, + 56, 56, 52, 68, 1, 73, 49, 1, 51, 57, + 58, 71, 71, 314, 69, 86, 72, 88, 89, 90, + 320, 75, 323, 237, 95, 75, 98, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 68, 68, + 188, 67, 69, 1, 115, 98, 99, 100, 101, 102, + 103, 104, 105, 106, 107, 108, 109, 129, 341, 56, + 145, 344, 56, 148, 10, 229, 137, 25, 26, 15, + 141, 52, 69, 81, 52, 69, 129, 291, 44, 45, + 68, 295, 145, 91, 41, 148, 179, 180, 10, 160, + 162, 44, 45, 228, 52, 41, 50, 75, 312, 3, + 1, 315, 57, 66, 3, 4, 4, 52, 179, 180, + 11, 57, 58, 5, 71, 39, 74, 14, 203, 204, + 9, 256, 207, 41, 209, 260, 261, 69, 213, 343, + 138, 68, 346, 218, 247, 57, 58, 208, 286, 10, + 203, 204, 68, 68, 207, 68, 209, 46, 47, 220, + 213, 52, 258, 288, 267, 56, 75, 242, 4, 69, + 231, 232, 297, 27, 235, 236, 11, 317, 69, 304, + 21, 70, 257, 279, 75, 145, 247, 68, 148, 242, + 265, 59, 60, 61, 62, 63, 57, 58, 66, 324, + 55, 13, 14, 201, 257, 74, 267, 294, 7, 8, + 9, 336, 210, 59, 60, 61, 62, 63, 7, 7, + 66, 219, 30, 298, 317, 10, 232, 300, 25, 162, + 15, 306, 44, 45, 332, 296, -1, 298, 300, -1, + 279, 53, -1, 203, 204, -1, 308, 207, -1, 209, + -1, 249, -1, 213, 53, 253, 41, 42, 43, -1, + 59, 60, -1, 62, -1, 308, 61, 62, 63, 54, + -1, 66, 57, 58, -1, -1, -1, -1, 276, -1, + -1, -1, 242, -1, -1, 283, 284, -1, -1, 287, + 75, -1, -1, -1, -1, -1, -1, 257, -1, 10, + -1, -1, -1, -1, 15, -1, -1, 305, -1, 307, + -1, 309, 310, 311, -1, 313, 0, 1, -1, 3, + 4, -1, -1, 7, 8, -1, -1, -1, -1, -1, + 41, 42, 43, -1, 18, 19, 334, -1, -1, 337, + -1, -1, 340, 54, 342, -1, 57, 58, -1, -1, + -1, -1, 36, 37, 38, 39, -1, -1, 69, -1, + 44, 45, 46, 47, 48, -1, -1, -1, 52, 53, + -1, -1, -1, -1, -1, 59, 60, -1, 62, -1, + 64, -1, -1, 67, 68, -1, 70, -1, -1, 73, + 1, 75, 3, 4, -1, -1, 7, 8, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, + -1, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, -1, -1, -1, 39, 40, + -1, -1, -1, 44, 45, 46, 47, -1, -1, -1, + -1, 52, 53, -1, -1, -1, -1, -1, 59, 60, + -1, 62, -1, 64, -1, -1, 67, 68, -1, 70, + -1, -1, 73, 74, 75, 1, -1, 3, 4, -1, + -1, 7, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 20, -1, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + -1, -1, -1, 39, 40, -1, -1, -1, 44, 45, + 46, 47, -1, -1, -1, -1, 52, 53, -1, -1, + -1, -1, -1, 59, 60, -1, 62, -1, 64, -1, + -1, 67, 68, -1, 70, -1, -1, 73, 74, 75, 1, -1, 3, 4, -1, -1, 7, 8, -1, -1, - -1, -1, -1, 40, 41, 42, 17, 18, -1, -1, - -1, -1, 9, -1, -1, -1, 53, 14, -1, 56, - 57, 7, 8, -1, 35, 36, 37, 38, -1, -1, - -1, 68, 43, 44, 45, 46, 47, -1, -1, -1, - 51, 52, -1, 40, 41, -1, -1, 58, 59, -1, - 61, -1, 63, -1, -1, 66, 67, -1, 69, 56, - 57, 72, 1, 74, 3, 4, 52, -1, 7, 8, - -1, -1, 58, 59, -1, 61, -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, -1, 51, 52, 58, 59, 60, 61, 62, 58, - 59, 65, 61, -1, 63, -1, -1, 66, 67, -1, - 69, -1, -1, 72, 73, 74, 1, -1, 3, 4, - -1, -1, 7, 8, 58, 59, 60, 61, 62, -1, - -1, 65, -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, -1, 51, 52, -1, -1, - -1, -1, -1, 58, 59, -1, 61, -1, 63, -1, - -1, 66, 67, -1, 69, -1, -1, 72, 73, 74, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, + -1, 22, 23, 24, -1, -1, 27, 28, 29, 30, + 31, 32, 33, 34, 35, -1, -1, -1, 39, 40, + -1, -1, -1, 44, 45, 46, 47, 1, -1, 3, + 4, -1, 53, 7, 8, -1, -1, 11, 59, 60, + -1, 62, -1, 64, -1, -1, 67, 68, -1, 70, + -1, -1, 73, 74, 75, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, + 44, 45, 46, 47, -1, -1, -1, -1, 52, 53, + -1, -1, -1, -1, -1, 59, 60, -1, 62, -1, + 64, -1, -1, 67, 68, 69, 70, -1, 3, 4, + -1, 75, 7, 8, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 20, -1, 22, 23, 24, + -1, -1, 27, 28, 29, 30, 31, 32, 33, 34, + 35, -1, -1, -1, 39, 40, -1, -1, -1, 44, + 45, 46, 47, -1, -1, 3, 4, -1, 53, 7, + 8, -1, -1, -1, 59, 60, -1, 62, -1, 64, + -1, -1, 67, 68, -1, 70, -1, -1, 73, -1, + 75, -1, -1, -1, -1, -1, 1, -1, 3, 4, + -1, 39, 7, 8, 9, -1, 44, 45, 46, 47, + -1, -1, -1, -1, -1, 53, -1, -1, -1, -1, + -1, 59, 60, -1, 62, -1, 64, -1, -1, 67, + 68, -1, 70, -1, 39, -1, -1, 75, -1, 44, + 45, 46, 47, 1, -1, 3, 4, -1, 53, 7, + 8, 9, -1, -1, 59, 60, -1, 62, -1, 64, + -1, -1, 67, 68, 69, 70, -1, -1, -1, -1, 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, - -1, 52, 7, 8, -1, 10, -1, 58, 59, -1, - 61, -1, 63, -1, -1, 66, 67, -1, 69, -1, - -1, 72, 73, 74, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 38, -1, -1, -1, -1, 43, 44, - 45, 46, -1, -1, -1, -1, 51, 52, -1, -1, - -1, -1, -1, 58, 59, -1, 61, -1, 63, -1, - -1, 66, 67, 68, 69, -1, 3, 4, -1, 74, - 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, 3, - 4, 38, 39, 7, 8, -1, 43, 44, 45, 46, - -1, -1, -1, -1, -1, 52, -1, -1, -1, -1, - 9, 58, 59, -1, 61, 14, 63, -1, -1, 66, - 67, -1, 69, -1, 38, 72, -1, 74, -1, 43, - 44, 45, 46, 1, -1, 3, 4, -1, 52, 7, - 8, 40, 41, 42, 58, 59, -1, 61, -1, 63, - -1, -1, 66, 67, 53, 69, -1, 56, 57, -1, - 74, -1, -1, -1, -1, 1, -1, 3, 4, -1, - 38, 7, 8, -1, -1, 43, 44, 45, 46, -1, - -1, -1, -1, -1, 52, -1, -1, -1, -1, -1, - 58, 59, -1, 61, -1, 63, -1, -1, 66, 67, - 68, 69, 38, -1, -1, -1, -1, 43, 44, 45, - 46, 1, -1, 3, 4, -1, 52, 7, 8, -1, - -1, -1, 58, 59, -1, 61, -1, 63, -1, -1, - 66, 67, -1, 69, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 3, 4, 38, -1, - 7, 8, -1, 43, 44, 45, 46, -1, -1, -1, - -1, -1, 52, -1, -1, 22, -1, -1, 58, 59, - -1, 61, -1, 63, 31, 32, 66, 67, -1, 69, - -1, 38, -1, -1, -1, -1, 43, 44, 45, 46, - -1, -1, 3, 4, -1, 52, 7, 8, -1, -1, - -1, 58, 59, -1, 61, -1, 63, -1, -1, 66, - 67, 22, 69, -1, -1, -1, -1, -1, -1, -1, - 31, 32, -1, -1, -1, -1, -1, 38, -1, -1, - -1, -1, 43, 44, 45, 46, -1, -1, 3, 4, - -1, 52, 7, 8, -1, -1, 11, 58, 59, -1, - 61, -1, 63, -1, -1, 66, 67, -1, 69, -1, - -1, -1, -1, -1, -1, 3, 4, -1, -1, 7, - 8, -1, -1, 38, -1, -1, -1, -1, 43, 44, - 45, 46, -1, -1, -1, -1, -1, 52, -1, -1, - -1, -1, -1, 58, 59, -1, 61, -1, 63, -1, - 38, 66, 67, -1, 69, 43, 44, 45, 46, -1, - 9, -1, -1, -1, 52, 14, -1, -1, -1, -1, - 58, 59, -1, 61, -1, 63, -1, -1, 66, 67, - -1, 69, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 40, 41, 42, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 53, 54, -1, 56, 57 + -1, 39, -1, -1, -1, -1, 44, 45, 46, 47, + -1, -1, -1, -1, 10, 53, -1, -1, -1, 15, + -1, 59, 60, -1, 62, -1, 64, -1, 39, 67, + 68, -1, 70, 44, 45, 46, 47, 1, -1, 3, + 4, -1, 53, 7, 8, 41, 42, 43, 59, 60, + -1, 62, -1, 64, -1, -1, 67, 68, 54, 70, + 56, 57, 58, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 3, 4, -1, 39, 7, 8, -1, -1, + 44, 45, 46, 47, -1, -1, -1, -1, -1, 53, + -1, -1, 23, -1, -1, 59, 60, -1, 62, -1, + 64, 32, 33, 67, 68, -1, 70, -1, 39, -1, + -1, -1, -1, 44, 45, 46, 47, -1, -1, -1, + 3, 4, 53, -1, 7, 8, -1, -1, 59, 60, + -1, 62, -1, 64, -1, -1, 67, 68, -1, 70, + 23, -1, -1, -1, -1, -1, -1, -1, -1, 32, + 33, -1, -1, -1, -1, -1, 39, -1, -1, -1, + -1, 44, 45, 46, 47, -1, -1, -1, -1, -1, + 53, -1, -1, -1, -1, -1, 59, 60, 10, 62, + -1, 64, -1, 15, 67, 68, -1, 70, 3, 4, + -1, -1, 7, 8, -1, -1, -1, 12, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, + 42, 43, -1, -1, -1, 3, 4, -1, -1, 7, + 8, 9, 54, 55, 39, 57, 58, -1, -1, 44, + 45, 46, 47, -1, -1, -1, -1, 10, 53, -1, + -1, -1, 15, -1, 59, 60, -1, 62, -1, 64, + -1, 39, 67, 68, -1, 70, 44, 45, 46, 47, + -1, -1, 3, 4, -1, 53, 7, 8, 41, 42, + 43, 59, 60, -1, 62, -1, 64, -1, -1, 67, + 68, 54, 70, -1, 57, 58, -1, -1, -1, 3, + 4, -1, -1, 7, 8, -1, -1, -1, 39, -1, + -1, -1, -1, 44, 45, 46, 47, -1, -1, -1, + -1, -1, 53, -1, -1, -1, -1, -1, 59, 60, + -1, 62, -1, 64, -1, -1, 67, 68, -1, 70, + 44, 45, 46, 47, -1, -1, -1, -1, -1, 53, + -1, -1, -1, -1, -1, 59, 60, -1, 62, -1, + 64, -1, -1, 67, 68, -1, 70 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 76, 0, 1, 3, 4, 7, 8, 17, 18, - 35, 36, 37, 38, 43, 44, 45, 46, 47, 51, - 52, 58, 59, 61, 63, 66, 67, 69, 77, 80, - 84, 86, 88, 106, 114, 118, 119, 120, 121, 122, - 123, 131, 132, 67, 70, 128, 129, 130, 3, 4, - 45, 46, 69, 82, 83, 124, 132, 132, 132, 67, - 67, 69, 119, 132, 119, 119, 67, 121, 132, 1, - 113, 114, 48, 50, 123, 72, 74, 81, 90, 106, - 134, 138, 81, 87, 51, 9, 14, 40, 41, 42, - 53, 55, 56, 57, 116, 117, 11, 119, 58, 59, - 60, 61, 62, 65, 58, 59, 60, 61, 62, 65, - 12, 13, 43, 44, 52, 115, 112, 113, 114, 113, - 16, 128, 49, 67, 56, 108, 112, 112, 114, 43, - 44, 133, 1, 55, 68, 136, 140, 136, 1, 6, - 78, 1, 6, 79, 106, 107, 89, 107, 5, 114, - 131, 114, 114, 114, 107, 114, 38, 119, 119, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 13, - 114, 136, 71, 85, 119, 136, 136, 114, 107, 40, - 1, 114, 1, 90, 1, 90, 1, 19, 21, 22, - 23, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 39, 73, 91, 92, 94, 101, 105, 114, 134, 135, - 138, 54, 114, 124, 1, 4, 109, 110, 131, 67, - 93, 4, 67, 67, 67, 107, 67, 90, 90, 90, - 111, 114, 90, 107, 90, 95, 89, 137, 138, 107, - 114, 136, 1, 140, 114, 111, 96, 4, 114, 114, - 91, 4, 94, 97, 90, 67, 102, 112, 135, 107, - 107, 1, 4, 136, 90, 125, 126, 127, 128, 68, - 136, 136, 26, 40, 138, 113, 10, 103, 107, 16, - 127, 107, 107, 67, 131, 107, 136, 104, 91, 134, - 91, 114, 136, 114, 138, 118, 20, 98, 136, 107, - 138, 107, 107, 1, 24, 25, 99, 107, 107, 91, - 107, 97, 91, 7, 8, 58, 59, 86, 100, 54, - 139, 135, 97, 136, 7, 7, 139, 107, 136, 107, - 107, 89, 107, 91, 89, 91 + 0, 77, 0, 1, 3, 4, 7, 8, 18, 19, + 36, 37, 38, 39, 44, 45, 46, 47, 48, 52, + 53, 59, 60, 62, 64, 67, 68, 70, 78, 81, + 85, 87, 90, 108, 119, 123, 124, 125, 126, 127, + 128, 136, 137, 68, 71, 133, 134, 135, 3, 4, + 46, 47, 70, 83, 84, 129, 137, 137, 137, 68, + 68, 70, 124, 137, 124, 124, 68, 126, 137, 1, + 115, 119, 49, 51, 128, 73, 75, 82, 92, 108, + 139, 143, 82, 88, 52, 10, 15, 41, 42, 43, + 54, 56, 57, 58, 121, 122, 12, 124, 59, 60, + 61, 62, 63, 66, 59, 60, 61, 62, 63, 66, + 13, 14, 44, 45, 53, 120, 1, 9, 89, 116, + 117, 118, 119, 115, 119, 17, 133, 50, 68, 57, + 110, 116, 116, 119, 44, 45, 138, 1, 56, 69, + 141, 145, 141, 1, 6, 79, 1, 6, 80, 108, + 109, 91, 109, 5, 89, 119, 136, 119, 119, 119, + 109, 119, 39, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 89, 14, 119, 141, 1, + 145, 72, 86, 124, 141, 141, 119, 109, 41, 1, + 119, 1, 92, 1, 92, 1, 20, 22, 23, 24, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 40, + 74, 93, 94, 96, 103, 107, 119, 139, 140, 143, + 55, 119, 129, 118, 1, 118, 1, 4, 111, 112, + 136, 68, 95, 4, 68, 68, 68, 109, 68, 92, + 92, 92, 113, 119, 92, 109, 92, 97, 91, 142, + 143, 109, 119, 141, 1, 145, 119, 113, 98, 4, + 119, 119, 93, 4, 96, 99, 92, 68, 104, 114, + 115, 140, 109, 109, 1, 4, 141, 92, 130, 131, + 132, 133, 69, 141, 141, 27, 41, 143, 115, 11, + 105, 109, 17, 132, 109, 109, 68, 136, 109, 141, + 106, 93, 139, 93, 119, 141, 119, 143, 123, 21, + 100, 141, 109, 143, 109, 109, 1, 25, 26, 101, + 109, 109, 93, 109, 99, 93, 7, 8, 59, 60, + 87, 89, 102, 55, 144, 140, 99, 141, 7, 7, + 144, 109, 141, 109, 109, 91, 109, 93, 91, 93 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 75, 76, 76, 76, 76, 76, 77, 77, 77, - 77, 77, 78, 78, 78, 79, 79, 79, 80, 80, - 80, 80, 80, 80, 80, 81, 82, 82, 82, 82, - 83, 83, 85, 84, 87, 86, 88, 88, 89, 89, - 89, 90, 90, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 92, 92, 92, 92, 92, 93, 92, - 92, 95, 94, 96, 94, 94, 94, 97, 97, 98, - 98, 98, 99, 99, 100, 100, 100, 100, 100, 101, - 101, 102, 102, 103, 104, 103, 105, 105, 106, 106, - 107, 107, 108, 108, 109, 109, 110, 110, 110, 110, - 110, 111, 111, 112, 112, 113, 113, 113, 113, 113, - 113, 114, 114, 114, 114, 114, 114, 114, 114, 115, - 115, 115, 116, 116, 117, 117, 118, 118, 118, 119, - 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, - 120, 120, 120, 120, 120, 120, 120, 121, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, - 121, 122, 122, 123, 124, 124, 125, 125, 126, 126, - 127, 128, 129, 129, 130, 131, 131, 132, 132, 133, - 133, 133, 134, 135, 136, 137, 137, 138, 139, 140 + 0, 76, 77, 77, 77, 77, 77, 78, 78, 78, + 78, 78, 79, 79, 79, 80, 80, 80, 81, 81, + 81, 81, 81, 81, 81, 82, 83, 83, 83, 83, + 84, 84, 86, 85, 88, 87, 89, 90, 90, 91, + 91, 91, 92, 92, 93, 93, 93, 93, 93, 93, + 93, 93, 93, 93, 94, 94, 94, 94, 94, 95, + 94, 94, 97, 96, 98, 96, 96, 96, 99, 99, + 100, 100, 100, 101, 101, 102, 102, 102, 102, 102, + 102, 103, 103, 104, 104, 105, 106, 105, 107, 107, + 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, + 112, 112, 112, 113, 113, 114, 114, 115, 115, 115, + 115, 115, 115, 116, 116, 117, 117, 117, 117, 117, + 117, 118, 118, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 120, 120, 120, 121, 121, 122, 122, + 123, 123, 123, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 125, 125, 125, 125, 125, 125, + 125, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 127, 127, 128, 129, 129, + 130, 130, 131, 131, 132, 133, 134, 134, 135, 136, + 136, 137, 137, 138, 138, 138, 139, 140, 141, 142, + 142, 143, 144, 145 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -1150,22 +1189,24 @@ static const yytype_uint8 yyr2[] = 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 4, 4, 1, 2, 1, 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, 1, 0, 7, 0, 3, 1, 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, 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, 0, 1, 1, 3, 1, 2, 3, + 3, 1, 1, 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 }; @@ -1847,7 +1888,7 @@ yyreduce: rule = 0; yyerrok; } -#line 1851 "awkgram.c" /* yacc.c:1646 */ +#line 1892 "awkgram.c" /* yacc.c:1646 */ break; case 5: @@ -1855,7 +1896,7 @@ yyreduce: { next_sourcefile(); } -#line 1859 "awkgram.c" /* yacc.c:1646 */ +#line 1900 "awkgram.c" /* yacc.c:1646 */ break; case 6: @@ -1868,7 +1909,7 @@ yyreduce: */ /* yyerrok; */ } -#line 1872 "awkgram.c" /* yacc.c:1646 */ +#line 1913 "awkgram.c" /* yacc.c:1646 */ break; case 7: @@ -1877,7 +1918,7 @@ yyreduce: (void) append_rule((yyvsp[-1]), (yyvsp[0])); first_rule = false; } -#line 1881 "awkgram.c" /* yacc.c:1646 */ +#line 1922 "awkgram.c" /* yacc.c:1646 */ break; case 8: @@ -1892,7 +1933,7 @@ yyreduce: } else /* pattern rule with non-empty pattern */ (void) append_rule((yyvsp[-1]), NULL); } -#line 1896 "awkgram.c" /* yacc.c:1646 */ +#line 1937 "awkgram.c" /* yacc.c:1646 */ break; case 9: @@ -1903,7 +1944,7 @@ yyreduce: want_param_names = DONT_CHECK; yyerrok; } -#line 1907 "awkgram.c" /* yacc.c:1646 */ +#line 1948 "awkgram.c" /* yacc.c:1646 */ break; case 10: @@ -1913,7 +1954,7 @@ yyreduce: at_seen = false; yyerrok; } -#line 1917 "awkgram.c" /* yacc.c:1646 */ +#line 1958 "awkgram.c" /* yacc.c:1646 */ break; case 11: @@ -1923,7 +1964,7 @@ yyreduce: at_seen = false; yyerrok; } -#line 1927 "awkgram.c" /* yacc.c:1646 */ +#line 1968 "awkgram.c" /* yacc.c:1646 */ break; case 12: @@ -1935,19 +1976,19 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1939 "awkgram.c" /* yacc.c:1646 */ +#line 1980 "awkgram.c" /* yacc.c:1646 */ break; case 13: #line 281 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1945 "awkgram.c" /* yacc.c:1646 */ +#line 1986 "awkgram.c" /* yacc.c:1646 */ break; case 14: #line 283 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1951 "awkgram.c" /* yacc.c:1646 */ +#line 1992 "awkgram.c" /* yacc.c:1646 */ break; case 15: @@ -1959,19 +2000,19 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1963 "awkgram.c" /* yacc.c:1646 */ +#line 2004 "awkgram.c" /* yacc.c:1646 */ break; case 16: #line 296 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1969 "awkgram.c" /* yacc.c:1646 */ +#line 2010 "awkgram.c" /* yacc.c:1646 */ break; case 17: #line 298 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1975 "awkgram.c" /* yacc.c:1646 */ +#line 2016 "awkgram.c" /* yacc.c:1646 */ break; case 18: @@ -1984,7 +2025,7 @@ yyreduce: } else (yyval) = NULL; } -#line 1988 "awkgram.c" /* yacc.c:1646 */ +#line 2029 "awkgram.c" /* yacc.c:1646 */ break; case 19: @@ -1997,7 +2038,7 @@ yyreduce: } else (yyval) = (yyvsp[0]); } -#line 2001 "awkgram.c" /* yacc.c:1646 */ +#line 2042 "awkgram.c" /* yacc.c:1646 */ break; case 20: @@ -2031,7 +2072,7 @@ yyreduce: (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp); rule = Rule; } -#line 2035 "awkgram.c" /* yacc.c:1646 */ +#line 2076 "awkgram.c" /* yacc.c:1646 */ break; case 21: @@ -2049,7 +2090,7 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2053 "awkgram.c" /* yacc.c:1646 */ +#line 2094 "awkgram.c" /* yacc.c:1646 */ break; case 22: @@ -2067,7 +2108,7 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2071 "awkgram.c" /* yacc.c:1646 */ +#line 2112 "awkgram.c" /* yacc.c:1646 */ break; case 23: @@ -2079,7 +2120,7 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2083 "awkgram.c" /* yacc.c:1646 */ +#line 2124 "awkgram.c" /* yacc.c:1646 */ break; case 24: @@ -2091,7 +2132,7 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2095 "awkgram.c" /* yacc.c:1646 */ +#line 2136 "awkgram.c" /* yacc.c:1646 */ break; case 25: @@ -2104,19 +2145,19 @@ yyreduce: ip = (yyvsp[-3]); (yyval) = ip; } -#line 2108 "awkgram.c" /* yacc.c:1646 */ +#line 2149 "awkgram.c" /* yacc.c:1646 */ break; case 26: #line 411 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2114 "awkgram.c" /* yacc.c:1646 */ +#line 2155 "awkgram.c" /* yacc.c:1646 */ break; case 27: #line 413 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2120 "awkgram.c" /* yacc.c:1646 */ +#line 2161 "awkgram.c" /* yacc.c:1646 */ break; case 28: @@ -2126,7 +2167,7 @@ yyreduce: tokstart); YYABORT; } -#line 2130 "awkgram.c" /* yacc.c:1646 */ +#line 2171 "awkgram.c" /* yacc.c:1646 */ break; case 29: @@ -2135,13 +2176,13 @@ yyreduce: (yyval) = (yyvsp[0]); at_seen = false; } -#line 2139 "awkgram.c" /* yacc.c:1646 */ +#line 2180 "awkgram.c" /* yacc.c:1646 */ break; case 32: #line 433 "awkgram.y" /* yacc.c:1646 */ { want_param_names = FUNC_HEADER; } -#line 2145 "awkgram.c" /* yacc.c:1646 */ +#line 2186 "awkgram.c" /* yacc.c:1646 */ break; case 33: @@ -2173,13 +2214,13 @@ yyreduce: (yyval) = (yyvsp[-6]); want_param_names = FUNC_BODY; } -#line 2177 "awkgram.c" /* yacc.c:1646 */ +#line 2218 "awkgram.c" /* yacc.c:1646 */ break; case 34: #line 469 "awkgram.y" /* yacc.c:1646 */ { want_regexp = true; } -#line 2183 "awkgram.c" /* yacc.c:1646 */ +#line 2224 "awkgram.c" /* yacc.c:1646 */ break; case 35: @@ -2212,28 +2253,52 @@ yyreduce: (yyval)->opcode = Op_match_rec; (yyval)->memory = n; } -#line 2216 "awkgram.c" /* yacc.c:1646 */ +#line 2257 "awkgram.c" /* yacc.c:1646 */ break; case 36: #line 503 "awkgram.y" /* yacc.c:1646 */ + { + NODE *n, *exp; + char *re; + size_t len; + + re = (yyvsp[0])->lextok; + (yyvsp[0])->lextok = NULL; + len = strlen(re); + + exp = make_str_node(re, len, ALREADY_MALLOCED); + n = make_regnode(Node_hardregex, exp); + if (n == NULL) { + unref(exp); + YYABORT; + } + (yyval) = (yyvsp[0]); + (yyval)->opcode = Op_push_re; + (yyval)->memory = n; + } +#line 2281 "awkgram.c" /* yacc.c:1646 */ + break; + + case 37: +#line 525 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[0])); } -#line 2222 "awkgram.c" /* yacc.c:1646 */ +#line 2287 "awkgram.c" /* yacc.c:1646 */ break; - case 38: -#line 509 "awkgram.y" /* yacc.c:1646 */ + case 39: +#line 531 "awkgram.y" /* yacc.c:1646 */ { if (comment != NULL) { (yyval) = list_create(comment); comment = NULL; } else (yyval) = NULL; } -#line 2233 "awkgram.c" /* yacc.c:1646 */ +#line 2298 "awkgram.c" /* yacc.c:1646 */ break; - case 39: -#line 516 "awkgram.y" /* yacc.c:1646 */ + case 40: +#line 538 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0]) == NULL) { if (comment == NULL) @@ -2261,40 +2326,40 @@ yyreduce: } yyerrok; } -#line 2265 "awkgram.c" /* yacc.c:1646 */ +#line 2330 "awkgram.c" /* yacc.c:1646 */ break; - case 40: -#line 544 "awkgram.y" /* yacc.c:1646 */ + case 41: +#line 566 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2271 "awkgram.c" /* yacc.c:1646 */ +#line 2336 "awkgram.c" /* yacc.c:1646 */ break; - case 43: -#line 554 "awkgram.y" /* yacc.c:1646 */ + case 44: +#line 576 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2277 "awkgram.c" /* yacc.c:1646 */ +#line 2342 "awkgram.c" /* yacc.c:1646 */ break; - case 44: -#line 556 "awkgram.y" /* yacc.c:1646 */ + case 45: +#line 578 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2283 "awkgram.c" /* yacc.c:1646 */ +#line 2348 "awkgram.c" /* yacc.c:1646 */ break; - case 45: -#line 558 "awkgram.y" /* yacc.c:1646 */ + case 46: +#line 580 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2294 "awkgram.c" /* yacc.c:1646 */ +#line 2359 "awkgram.c" /* yacc.c:1646 */ break; - case 46: -#line 565 "awkgram.y" /* yacc.c:1646 */ + case 47: +#line 587 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2384,11 +2449,11 @@ yyreduce: break_allowed--; fix_break_continue(ip, tbreak, NULL); } -#line 2388 "awkgram.c" /* yacc.c:1646 */ +#line 2453 "awkgram.c" /* yacc.c:1646 */ break; - case 47: -#line 655 "awkgram.y" /* yacc.c:1646 */ + case 48: +#line 677 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2430,11 +2495,11 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); } -#line 2434 "awkgram.c" /* yacc.c:1646 */ +#line 2499 "awkgram.c" /* yacc.c:1646 */ break; - case 48: -#line 697 "awkgram.y" /* yacc.c:1646 */ + case 49: +#line 719 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2476,11 +2541,11 @@ yyreduce: } /* else $1 and $4 are NULLs */ } -#line 2480 "awkgram.c" /* yacc.c:1646 */ +#line 2545 "awkgram.c" /* yacc.c:1646 */ break; - case 49: -#line 739 "awkgram.y" /* yacc.c:1646 */ + case 50: +#line 761 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; char *var_name = (yyvsp[-5])->lextok; @@ -2593,44 +2658,44 @@ regular_loop: break_allowed--; continue_allowed--; } -#line 2597 "awkgram.c" /* yacc.c:1646 */ +#line 2662 "awkgram.c" /* yacc.c:1646 */ break; - case 50: -#line 852 "awkgram.y" /* yacc.c:1646 */ + case 51: +#line 874 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2608 "awkgram.c" /* yacc.c:1646 */ +#line 2673 "awkgram.c" /* yacc.c:1646 */ break; - case 51: -#line 859 "awkgram.y" /* yacc.c:1646 */ + case 52: +#line 881 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2619 "awkgram.c" /* yacc.c:1646 */ +#line 2684 "awkgram.c" /* yacc.c:1646 */ break; - case 52: -#line 866 "awkgram.y" /* yacc.c:1646 */ + case 53: +#line 888 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2630 "awkgram.c" /* yacc.c:1646 */ +#line 2695 "awkgram.c" /* yacc.c:1646 */ break; - case 53: -#line 876 "awkgram.y" /* yacc.c:1646 */ + case 54: +#line 898 "awkgram.y" /* yacc.c:1646 */ { if (! break_allowed) error_ln((yyvsp[-1])->source_line, @@ -2639,11 +2704,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2643 "awkgram.c" /* yacc.c:1646 */ +#line 2708 "awkgram.c" /* yacc.c:1646 */ break; - case 54: -#line 885 "awkgram.y" /* yacc.c:1646 */ + case 55: +#line 907 "awkgram.y" /* yacc.c:1646 */ { if (! continue_allowed) error_ln((yyvsp[-1])->source_line, @@ -2652,11 +2717,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2656 "awkgram.c" /* yacc.c:1646 */ +#line 2721 "awkgram.c" /* yacc.c:1646 */ break; - case 55: -#line 894 "awkgram.y" /* yacc.c:1646 */ + case 56: +#line 916 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2665,11 +2730,11 @@ regular_loop: (yyvsp[-1])->target_jmp = ip_rec; (yyval) = list_create((yyvsp[-1])); } -#line 2669 "awkgram.c" /* yacc.c:1646 */ +#line 2734 "awkgram.c" /* yacc.c:1646 */ break; - case 56: -#line 903 "awkgram.y" /* yacc.c:1646 */ + case 57: +#line 925 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2680,11 +2745,11 @@ regular_loop: (yyvsp[-1])->target_endfile = ip_endfile; (yyval) = list_create((yyvsp[-1])); } -#line 2684 "awkgram.c" /* yacc.c:1646 */ +#line 2749 "awkgram.c" /* yacc.c:1646 */ break; - case 57: -#line 914 "awkgram.y" /* yacc.c:1646 */ + case 58: +#line 936 "awkgram.y" /* yacc.c:1646 */ { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2699,20 +2764,20 @@ regular_loop: } else (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); } -#line 2703 "awkgram.c" /* yacc.c:1646 */ +#line 2768 "awkgram.c" /* yacc.c:1646 */ break; - case 58: -#line 929 "awkgram.y" /* yacc.c:1646 */ + case 59: +#line 951 "awkgram.y" /* yacc.c:1646 */ { if (! in_function) yyerror(_("`return' used outside function context")); } -#line 2712 "awkgram.c" /* yacc.c:1646 */ +#line 2777 "awkgram.c" /* yacc.c:1646 */ break; - case 59: -#line 932 "awkgram.y" /* yacc.c:1646 */ + case 60: +#line 954 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) { (yyval) = list_create((yyvsp[-3])); @@ -2733,17 +2798,17 @@ regular_loop: (yyval) = list_append((yyvsp[-1]), (yyvsp[-3])); } } -#line 2737 "awkgram.c" /* yacc.c:1646 */ +#line 2802 "awkgram.c" /* yacc.c:1646 */ break; - case 61: -#line 964 "awkgram.y" /* yacc.c:1646 */ + case 62: +#line 986 "awkgram.y" /* yacc.c:1646 */ { in_print = true; in_parens = 0; } -#line 2743 "awkgram.c" /* yacc.c:1646 */ +#line 2808 "awkgram.c" /* yacc.c:1646 */ break; - case 62: -#line 965 "awkgram.y" /* yacc.c:1646 */ + case 63: +#line 987 "awkgram.y" /* yacc.c:1646 */ { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2840,17 +2905,17 @@ regular_print: } } } -#line 2844 "awkgram.c" /* yacc.c:1646 */ +#line 2909 "awkgram.c" /* yacc.c:1646 */ break; - case 63: -#line 1062 "awkgram.y" /* yacc.c:1646 */ + case 64: +#line 1084 "awkgram.y" /* yacc.c:1646 */ { sub_counter = 0; } -#line 2850 "awkgram.c" /* yacc.c:1646 */ +#line 2915 "awkgram.c" /* yacc.c:1646 */ break; - case 64: -#line 1063 "awkgram.y" /* yacc.c:1646 */ + case 65: +#line 1085 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-2])->lextok; @@ -2883,11 +2948,11 @@ regular_print: (yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3])); } } -#line 2887 "awkgram.c" /* yacc.c:1646 */ +#line 2952 "awkgram.c" /* yacc.c:1646 */ break; - case 65: -#line 1100 "awkgram.y" /* yacc.c:1646 */ + case 66: +#line 1122 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; char *arr = (yyvsp[-1])->lextok; @@ -2913,52 +2978,52 @@ regular_print: fatal(_("`delete' is not allowed with FUNCTAB")); } } -#line 2917 "awkgram.c" /* yacc.c:1646 */ +#line 2982 "awkgram.c" /* yacc.c:1646 */ break; - case 66: -#line 1126 "awkgram.y" /* yacc.c:1646 */ + case 67: +#line 1148 "awkgram.y" /* yacc.c:1646 */ { (yyval) = optimize_assignment((yyvsp[0])); } -#line 2923 "awkgram.c" /* yacc.c:1646 */ +#line 2988 "awkgram.c" /* yacc.c:1646 */ break; - case 67: -#line 1131 "awkgram.y" /* yacc.c:1646 */ + case 68: +#line 1153 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2929 "awkgram.c" /* yacc.c:1646 */ +#line 2994 "awkgram.c" /* yacc.c:1646 */ break; - case 68: -#line 1133 "awkgram.y" /* yacc.c:1646 */ + case 69: +#line 1155 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2935 "awkgram.c" /* yacc.c:1646 */ +#line 3000 "awkgram.c" /* yacc.c:1646 */ break; - case 69: -#line 1138 "awkgram.y" /* yacc.c:1646 */ + case 70: +#line 1160 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2941 "awkgram.c" /* yacc.c:1646 */ +#line 3006 "awkgram.c" /* yacc.c:1646 */ break; - case 70: -#line 1140 "awkgram.y" /* yacc.c:1646 */ + case 71: +#line 1162 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) (yyval) = list_create((yyvsp[0])); else (yyval) = list_prepend((yyvsp[-1]), (yyvsp[0])); } -#line 2952 "awkgram.c" /* yacc.c:1646 */ +#line 3017 "awkgram.c" /* yacc.c:1646 */ break; - case 71: -#line 1147 "awkgram.y" /* yacc.c:1646 */ + case 72: +#line 1169 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2958 "awkgram.c" /* yacc.c:1646 */ +#line 3023 "awkgram.c" /* yacc.c:1646 */ break; - case 72: -#line 1152 "awkgram.y" /* yacc.c:1646 */ + case 73: +#line 1174 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2970,11 +3035,11 @@ regular_print: bcfree((yyvsp[-2])); (yyval) = (yyvsp[-4]); } -#line 2974 "awkgram.c" /* yacc.c:1646 */ +#line 3039 "awkgram.c" /* yacc.c:1646 */ break; - case 73: -#line 1164 "awkgram.y" /* yacc.c:1646 */ + case 74: +#line 1186 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2985,17 +3050,17 @@ regular_print: (yyvsp[-3])->case_stmt = casestmt; (yyval) = (yyvsp[-3]); } -#line 2989 "awkgram.c" /* yacc.c:1646 */ +#line 3054 "awkgram.c" /* yacc.c:1646 */ break; - case 74: -#line 1178 "awkgram.y" /* yacc.c:1646 */ + case 75: +#line 1200 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2995 "awkgram.c" /* yacc.c:1646 */ +#line 3060 "awkgram.c" /* yacc.c:1646 */ break; - case 75: -#line 1180 "awkgram.y" /* yacc.c:1646 */ + case 76: +#line 1202 "awkgram.y" /* yacc.c:1646 */ { NODE *n = (yyvsp[0])->memory; (void) force_number(n); @@ -3003,71 +3068,84 @@ regular_print: bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3007 "awkgram.c" /* yacc.c:1646 */ +#line 3072 "awkgram.c" /* yacc.c:1646 */ break; - case 76: -#line 1188 "awkgram.y" /* yacc.c:1646 */ + case 77: +#line 1210 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3016 "awkgram.c" /* yacc.c:1646 */ +#line 3081 "awkgram.c" /* yacc.c:1646 */ break; - case 77: -#line 1193 "awkgram.y" /* yacc.c:1646 */ + case 78: +#line 1215 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3022 "awkgram.c" /* yacc.c:1646 */ +#line 3087 "awkgram.c" /* yacc.c:1646 */ break; - case 78: -#line 1195 "awkgram.y" /* yacc.c:1646 */ + case 79: +#line 1217 "awkgram.y" /* yacc.c:1646 */ { + if ((yyvsp[0])->memory->type == Node_regex) + (yyvsp[0])->opcode = Op_push_re; + else + (yyvsp[0])->opcode = Op_push; + (yyval) = (yyvsp[0]); + } +#line 3099 "awkgram.c" /* yacc.c:1646 */ + break; + + case 80: +#line 1225 "awkgram.y" /* yacc.c:1646 */ + { + assert((yyvsp[0])->memory->type == Node_hardregex); (yyvsp[0])->opcode = Op_push_re; (yyval) = (yyvsp[0]); } -#line 3031 "awkgram.c" /* yacc.c:1646 */ +#line 3109 "awkgram.c" /* yacc.c:1646 */ break; - case 79: -#line 1203 "awkgram.y" /* yacc.c:1646 */ + case 81: +#line 1234 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3037 "awkgram.c" /* yacc.c:1646 */ +#line 3115 "awkgram.c" /* yacc.c:1646 */ break; - case 80: -#line 1205 "awkgram.y" /* yacc.c:1646 */ + case 82: +#line 1236 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3043 "awkgram.c" /* yacc.c:1646 */ +#line 3121 "awkgram.c" /* yacc.c:1646 */ break; - case 82: -#line 1215 "awkgram.y" /* yacc.c:1646 */ + case 84: +#line 1246 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3051 "awkgram.c" /* yacc.c:1646 */ +#line 3129 "awkgram.c" /* yacc.c:1646 */ break; - case 83: -#line 1222 "awkgram.y" /* yacc.c:1646 */ + case 85: +#line 1253 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; (yyval) = NULL; } -#line 3061 "awkgram.c" /* yacc.c:1646 */ +#line 3139 "awkgram.c" /* yacc.c:1646 */ break; - case 84: -#line 1227 "awkgram.y" /* yacc.c:1646 */ + case 86: +#line 1258 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; } -#line 3067 "awkgram.c" /* yacc.c:1646 */ +#line 3145 "awkgram.c" /* yacc.c:1646 */ break; - case 85: -#line 1228 "awkgram.y" /* yacc.c:1646 */ + case 87: +#line 1259 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->redir_type == redirect_twoway && (yyvsp[0])->lasti->opcode == Op_K_getline_redir @@ -3075,63 +3153,63 @@ regular_print: yyerror(_("multistage two-way pipelines don't work")); (yyval) = list_prepend((yyvsp[0]), (yyvsp[-2])); } -#line 3079 "awkgram.c" /* yacc.c:1646 */ +#line 3157 "awkgram.c" /* yacc.c:1646 */ break; - case 86: -#line 1239 "awkgram.y" /* yacc.c:1646 */ + case 88: +#line 1270 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL); } -#line 3087 "awkgram.c" /* yacc.c:1646 */ +#line 3165 "awkgram.c" /* yacc.c:1646 */ break; - case 87: -#line 1244 "awkgram.y" /* yacc.c:1646 */ + case 89: +#line 1275 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0])); } -#line 3095 "awkgram.c" /* yacc.c:1646 */ +#line 3173 "awkgram.c" /* yacc.c:1646 */ break; - case 92: -#line 1261 "awkgram.y" /* yacc.c:1646 */ + case 94: +#line 1292 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3101 "awkgram.c" /* yacc.c:1646 */ +#line 3179 "awkgram.c" /* yacc.c:1646 */ break; - case 93: -#line 1263 "awkgram.y" /* yacc.c:1646 */ + case 95: +#line 1294 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3110 "awkgram.c" /* yacc.c:1646 */ +#line 3188 "awkgram.c" /* yacc.c:1646 */ break; - case 94: -#line 1271 "awkgram.y" /* yacc.c:1646 */ + case 96: +#line 1302 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3116 "awkgram.c" /* yacc.c:1646 */ +#line 3194 "awkgram.c" /* yacc.c:1646 */ break; - case 95: -#line 1273 "awkgram.y" /* yacc.c:1646 */ + case 97: +#line 1304 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3122 "awkgram.c" /* yacc.c:1646 */ +#line 3200 "awkgram.c" /* yacc.c:1646 */ break; - case 96: -#line 1278 "awkgram.y" /* yacc.c:1646 */ + case 98: +#line 1309 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = 0; (yyval) = list_create((yyvsp[0])); } -#line 3131 "awkgram.c" /* yacc.c:1646 */ +#line 3209 "awkgram.c" /* yacc.c:1646 */ break; - case 97: -#line 1283 "awkgram.y" /* yacc.c:1646 */ + case 99: +#line 1314 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2]) != NULL && (yyvsp[0]) != NULL) { (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1; @@ -3140,74 +3218,74 @@ regular_print: } else (yyval) = NULL; } -#line 3144 "awkgram.c" /* yacc.c:1646 */ +#line 3222 "awkgram.c" /* yacc.c:1646 */ break; - case 98: -#line 1292 "awkgram.y" /* yacc.c:1646 */ + case 100: +#line 1323 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3150 "awkgram.c" /* yacc.c:1646 */ +#line 3228 "awkgram.c" /* yacc.c:1646 */ break; - case 99: -#line 1294 "awkgram.y" /* yacc.c:1646 */ + case 101: +#line 1325 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3156 "awkgram.c" /* yacc.c:1646 */ +#line 3234 "awkgram.c" /* yacc.c:1646 */ break; - case 100: -#line 1296 "awkgram.y" /* yacc.c:1646 */ + case 102: +#line 1327 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); } -#line 3162 "awkgram.c" /* yacc.c:1646 */ +#line 3240 "awkgram.c" /* yacc.c:1646 */ break; - case 101: -#line 1302 "awkgram.y" /* yacc.c:1646 */ + case 103: +#line 1333 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3168 "awkgram.c" /* yacc.c:1646 */ +#line 3246 "awkgram.c" /* yacc.c:1646 */ break; - case 102: -#line 1304 "awkgram.y" /* yacc.c:1646 */ + case 104: +#line 1335 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3174 "awkgram.c" /* yacc.c:1646 */ +#line 3252 "awkgram.c" /* yacc.c:1646 */ break; - case 103: -#line 1309 "awkgram.y" /* yacc.c:1646 */ + case 105: +#line 1340 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3180 "awkgram.c" /* yacc.c:1646 */ +#line 3258 "awkgram.c" /* yacc.c:1646 */ break; - case 104: -#line 1311 "awkgram.y" /* yacc.c:1646 */ + case 106: +#line 1342 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3186 "awkgram.c" /* yacc.c:1646 */ +#line 3264 "awkgram.c" /* yacc.c:1646 */ break; - case 105: -#line 1316 "awkgram.y" /* yacc.c:1646 */ + case 107: +#line 1347 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } -#line 3192 "awkgram.c" /* yacc.c:1646 */ +#line 3270 "awkgram.c" /* yacc.c:1646 */ break; - case 106: -#line 1318 "awkgram.y" /* yacc.c:1646 */ + case 108: +#line 1349 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3201 "awkgram.c" /* yacc.c:1646 */ +#line 3279 "awkgram.c" /* yacc.c:1646 */ break; - case 107: -#line 1323 "awkgram.y" /* yacc.c:1646 */ + case 109: +#line 1354 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3207 "awkgram.c" /* yacc.c:1646 */ +#line 3285 "awkgram.c" /* yacc.c:1646 */ break; - case 108: -#line 1325 "awkgram.y" /* yacc.c:1646 */ + case 110: +#line 1356 "awkgram.y" /* yacc.c:1646 */ { /* * Returning the expression list instead of NULL lets @@ -3215,58 +3293,159 @@ regular_print: */ (yyval) = (yyvsp[-1]); } -#line 3219 "awkgram.c" /* yacc.c:1646 */ +#line 3297 "awkgram.c" /* yacc.c:1646 */ break; - case 109: -#line 1333 "awkgram.y" /* yacc.c:1646 */ + case 111: +#line 1364 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); } -#line 3228 "awkgram.c" /* yacc.c:1646 */ +#line 3306 "awkgram.c" /* yacc.c:1646 */ break; - case 110: -#line 1338 "awkgram.y" /* yacc.c:1646 */ + case 112: +#line 1369 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = (yyvsp[-2]); } -#line 3237 "awkgram.c" /* yacc.c:1646 */ +#line 3315 "awkgram.c" /* yacc.c:1646 */ break; - case 111: -#line 1347 "awkgram.y" /* yacc.c:1646 */ + case 113: +#line 1377 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = NULL; } +#line 3321 "awkgram.c" /* yacc.c:1646 */ + break; + + case 114: +#line 1379 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = (yyvsp[0]); } +#line 3327 "awkgram.c" /* yacc.c:1646 */ + break; + + case 115: +#line 1384 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } +#line 3333 "awkgram.c" /* yacc.c:1646 */ + break; + + case 116: +#line 1386 "awkgram.y" /* yacc.c:1646 */ + { + (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); + yyerrok; + } +#line 3342 "awkgram.c" /* yacc.c:1646 */ + break; + + case 117: +#line 1391 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = NULL; } +#line 3348 "awkgram.c" /* yacc.c:1646 */ + break; + + case 118: +#line 1393 "awkgram.y" /* yacc.c:1646 */ + { + /* + * Returning the expression list instead of NULL lets + * snode get a list of arguments that it can count. + */ + (yyval) = (yyvsp[-1]); + } +#line 3360 "awkgram.c" /* yacc.c:1646 */ + break; + + case 119: +#line 1401 "awkgram.y" /* yacc.c:1646 */ + { + /* Ditto */ + (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); + } +#line 3369 "awkgram.c" /* yacc.c:1646 */ + break; + + case 120: +#line 1406 "awkgram.y" /* yacc.c:1646 */ + { + /* Ditto */ + (yyval) = (yyvsp[-2]); + } +#line 3378 "awkgram.c" /* yacc.c:1646 */ + break; + + case 121: +#line 1413 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = (yyvsp[0]); } +#line 3384 "awkgram.c" /* yacc.c:1646 */ + break; + + case 122: +#line 1414 "awkgram.y" /* yacc.c:1646 */ + { (yyval) = list_create((yyvsp[0])); } +#line 3390 "awkgram.c" /* yacc.c:1646 */ + break; + + case 123: +#line 1420 "awkgram.y" /* yacc.c:1646 */ { 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 3248 "awkgram.c" /* yacc.c:1646 */ +#line 3401 "awkgram.c" /* yacc.c:1646 */ break; - case 112: -#line 1354 "awkgram.y" /* yacc.c:1646 */ + case 124: +#line 1427 "awkgram.y" /* yacc.c:1646 */ + { + (yyval) = mk_assignment((yyvsp[-2]), list_create((yyvsp[0])), (yyvsp[-1])); + } +#line 3409 "awkgram.c" /* yacc.c:1646 */ + break; + + case 125: +#line 1431 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3254 "awkgram.c" /* yacc.c:1646 */ +#line 3415 "awkgram.c" /* yacc.c:1646 */ break; - case 113: -#line 1356 "awkgram.y" /* yacc.c:1646 */ + case 126: +#line 1433 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3260 "awkgram.c" /* yacc.c:1646 */ +#line 3421 "awkgram.c" /* yacc.c:1646 */ break; - case 114: -#line 1358 "awkgram.y" /* yacc.c:1646 */ + case 127: +#line 1435 "awkgram.y" /* yacc.c:1646 */ + { + if ((yyvsp[-2])->lasti->opcode == Op_match_rec) + warning_ln((yyvsp[-1])->source_line, + _("regular expression on left of `~' or `!~' operator")); + + assert((yyvsp[0])->opcode == Op_push_re + && (yyvsp[0])->memory->type == Node_hardregex); + /* RHS is @/.../ */ + (yyvsp[-1])->memory = (yyvsp[0])->memory; + bcfree((yyvsp[0])); + (yyval) = list_append((yyvsp[-2]), (yyvsp[-1])); + } +#line 3438 "awkgram.c" /* yacc.c:1646 */ + break; + + case 128: +#line 1448 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[-1])->source_line, _("regular expression on left of `~' or `!~' operator")); if ((yyvsp[0])->lasti == (yyvsp[0])->nexti && (yyvsp[0])->nexti->opcode == Op_match_rec) { + /* RHS is /.../ */ (yyvsp[-1])->memory = (yyvsp[0])->nexti->memory; bcfree((yyvsp[0])->nexti); /* Op_match_rec */ bcfree((yyvsp[0])); /* Op_list */ @@ -3276,11 +3455,11 @@ regular_print: (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } } -#line 3280 "awkgram.c" /* yacc.c:1646 */ +#line 3459 "awkgram.c" /* yacc.c:1646 */ break; - case 115: -#line 1374 "awkgram.y" /* yacc.c:1646 */ + case 129: +#line 1465 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) warning_ln((yyvsp[-1])->source_line, @@ -3290,91 +3469,91 @@ regular_print: (yyvsp[-1])->expr_count = 1; (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3294 "awkgram.c" /* yacc.c:1646 */ +#line 3473 "awkgram.c" /* yacc.c:1646 */ break; - case 116: -#line 1384 "awkgram.y" /* yacc.c:1646 */ + case 130: +#line 1475 "awkgram.y" /* yacc.c:1646 */ { 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 3305 "awkgram.c" /* yacc.c:1646 */ +#line 3484 "awkgram.c" /* yacc.c:1646 */ break; - case 117: -#line 1391 "awkgram.y" /* yacc.c:1646 */ + case 131: +#line 1482 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); } -#line 3311 "awkgram.c" /* yacc.c:1646 */ +#line 3490 "awkgram.c" /* yacc.c:1646 */ break; - case 118: -#line 1393 "awkgram.y" /* yacc.c:1646 */ + case 132: +#line 1484 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3317 "awkgram.c" /* yacc.c:1646 */ +#line 3496 "awkgram.c" /* yacc.c:1646 */ break; - case 119: -#line 1398 "awkgram.y" /* yacc.c:1646 */ + case 133: +#line 1489 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3323 "awkgram.c" /* yacc.c:1646 */ +#line 3502 "awkgram.c" /* yacc.c:1646 */ break; - case 120: -#line 1400 "awkgram.y" /* yacc.c:1646 */ + case 134: +#line 1491 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3329 "awkgram.c" /* yacc.c:1646 */ +#line 3508 "awkgram.c" /* yacc.c:1646 */ break; - case 121: -#line 1402 "awkgram.y" /* yacc.c:1646 */ + case 135: +#line 1493 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_assign_quotient; (yyval) = (yyvsp[0]); } -#line 3338 "awkgram.c" /* yacc.c:1646 */ +#line 3517 "awkgram.c" /* yacc.c:1646 */ break; - case 122: -#line 1410 "awkgram.y" /* yacc.c:1646 */ + case 136: +#line 1501 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3344 "awkgram.c" /* yacc.c:1646 */ +#line 3523 "awkgram.c" /* yacc.c:1646 */ break; - case 123: -#line 1412 "awkgram.y" /* yacc.c:1646 */ + case 137: +#line 1503 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3350 "awkgram.c" /* yacc.c:1646 */ +#line 3529 "awkgram.c" /* yacc.c:1646 */ break; - case 124: -#line 1417 "awkgram.y" /* yacc.c:1646 */ + case 138: +#line 1508 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3356 "awkgram.c" /* yacc.c:1646 */ +#line 3535 "awkgram.c" /* yacc.c:1646 */ break; - case 125: -#line 1419 "awkgram.y" /* yacc.c:1646 */ + case 139: +#line 1510 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3362 "awkgram.c" /* yacc.c:1646 */ +#line 3541 "awkgram.c" /* yacc.c:1646 */ break; - case 126: -#line 1424 "awkgram.y" /* yacc.c:1646 */ + case 140: +#line 1515 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3368 "awkgram.c" /* yacc.c:1646 */ +#line 3547 "awkgram.c" /* yacc.c:1646 */ break; - case 127: -#line 1426 "awkgram.y" /* yacc.c:1646 */ + case 141: +#line 1517 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3374 "awkgram.c" /* yacc.c:1646 */ +#line 3553 "awkgram.c" /* yacc.c:1646 */ break; - case 128: -#line 1428 "awkgram.y" /* yacc.c:1646 */ + case 142: +#line 1519 "awkgram.y" /* yacc.c:1646 */ { int count = 2; bool is_simple_var = false; @@ -3421,47 +3600,47 @@ regular_print: max_args = count; } } -#line 3425 "awkgram.c" /* yacc.c:1646 */ +#line 3604 "awkgram.c" /* yacc.c:1646 */ break; - case 130: -#line 1480 "awkgram.y" /* yacc.c:1646 */ + case 144: +#line 1571 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3431 "awkgram.c" /* yacc.c:1646 */ +#line 3610 "awkgram.c" /* yacc.c:1646 */ break; - case 131: -#line 1482 "awkgram.y" /* yacc.c:1646 */ + case 145: +#line 1573 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3437 "awkgram.c" /* yacc.c:1646 */ +#line 3616 "awkgram.c" /* yacc.c:1646 */ break; - case 132: -#line 1484 "awkgram.y" /* yacc.c:1646 */ + case 146: +#line 1575 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3443 "awkgram.c" /* yacc.c:1646 */ +#line 3622 "awkgram.c" /* yacc.c:1646 */ break; - case 133: -#line 1486 "awkgram.y" /* yacc.c:1646 */ + case 147: +#line 1577 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3449 "awkgram.c" /* yacc.c:1646 */ +#line 3628 "awkgram.c" /* yacc.c:1646 */ break; - case 134: -#line 1488 "awkgram.y" /* yacc.c:1646 */ + case 148: +#line 1579 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3455 "awkgram.c" /* yacc.c:1646 */ +#line 3634 "awkgram.c" /* yacc.c:1646 */ break; - case 135: -#line 1490 "awkgram.y" /* yacc.c:1646 */ + case 149: +#line 1581 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3461 "awkgram.c" /* yacc.c:1646 */ +#line 3640 "awkgram.c" /* yacc.c:1646 */ break; - case 136: -#line 1492 "awkgram.y" /* yacc.c:1646 */ + case 150: +#line 1583 "awkgram.y" /* yacc.c:1646 */ { /* * In BEGINFILE/ENDFILE, allow `getline [var] < file' @@ -3475,29 +3654,29 @@ regular_print: _("non-redirected `getline' undefined inside END action")); (yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input); } -#line 3479 "awkgram.c" /* yacc.c:1646 */ +#line 3658 "awkgram.c" /* yacc.c:1646 */ break; - case 137: -#line 1506 "awkgram.y" /* yacc.c:1646 */ + case 151: +#line 1597 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3488 "awkgram.c" /* yacc.c:1646 */ +#line 3667 "awkgram.c" /* yacc.c:1646 */ break; - case 138: -#line 1511 "awkgram.y" /* yacc.c:1646 */ + case 152: +#line 1602 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3497 "awkgram.c" /* yacc.c:1646 */ +#line 3676 "awkgram.c" /* yacc.c:1646 */ break; - case 139: -#line 1516 "awkgram.y" /* yacc.c:1646 */ + case 153: +#line 1607 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) { warning_ln((yyvsp[-1])->source_line, @@ -3517,64 +3696,64 @@ regular_print: (yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1])); } } -#line 3521 "awkgram.c" /* yacc.c:1646 */ +#line 3700 "awkgram.c" /* yacc.c:1646 */ break; - case 140: -#line 1541 "awkgram.y" /* yacc.c:1646 */ + case 154: +#line 1632 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type); bcfree((yyvsp[-2])); } -#line 3530 "awkgram.c" /* yacc.c:1646 */ +#line 3709 "awkgram.c" /* yacc.c:1646 */ break; - case 141: -#line 1547 "awkgram.y" /* yacc.c:1646 */ + case 155: +#line 1638 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3536 "awkgram.c" /* yacc.c:1646 */ +#line 3715 "awkgram.c" /* yacc.c:1646 */ break; - case 142: -#line 1549 "awkgram.y" /* yacc.c:1646 */ + case 156: +#line 1640 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3542 "awkgram.c" /* yacc.c:1646 */ +#line 3721 "awkgram.c" /* yacc.c:1646 */ break; - case 143: -#line 1551 "awkgram.y" /* yacc.c:1646 */ + case 157: +#line 1642 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3548 "awkgram.c" /* yacc.c:1646 */ +#line 3727 "awkgram.c" /* yacc.c:1646 */ break; - case 144: -#line 1553 "awkgram.y" /* yacc.c:1646 */ + case 158: +#line 1644 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3554 "awkgram.c" /* yacc.c:1646 */ +#line 3733 "awkgram.c" /* yacc.c:1646 */ break; - case 145: -#line 1555 "awkgram.y" /* yacc.c:1646 */ + case 159: +#line 1646 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3560 "awkgram.c" /* yacc.c:1646 */ +#line 3739 "awkgram.c" /* yacc.c:1646 */ break; - case 146: -#line 1557 "awkgram.y" /* yacc.c:1646 */ + case 160: +#line 1648 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3566 "awkgram.c" /* yacc.c:1646 */ +#line 3745 "awkgram.c" /* yacc.c:1646 */ break; - case 147: -#line 1562 "awkgram.y" /* yacc.c:1646 */ + case 161: +#line 1653 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3574 "awkgram.c" /* yacc.c:1646 */ +#line 3753 "awkgram.c" /* yacc.c:1646 */ break; - case 148: -#line 1566 "awkgram.y" /* yacc.c:1646 */ + case 162: +#line 1657 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->opcode == Op_match_rec) { (yyvsp[0])->opcode = Op_nomatch; @@ -3606,37 +3785,37 @@ regular_print: } } } -#line 3610 "awkgram.c" /* yacc.c:1646 */ +#line 3789 "awkgram.c" /* yacc.c:1646 */ break; - case 149: -#line 1598 "awkgram.y" /* yacc.c:1646 */ + case 163: +#line 1689 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3616 "awkgram.c" /* yacc.c:1646 */ +#line 3795 "awkgram.c" /* yacc.c:1646 */ break; - case 150: -#line 1600 "awkgram.y" /* yacc.c:1646 */ + case 164: +#line 1691 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3626 "awkgram.c" /* yacc.c:1646 */ +#line 3805 "awkgram.c" /* yacc.c:1646 */ break; - case 151: -#line 1606 "awkgram.y" /* yacc.c:1646 */ + case 165: +#line 1697 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3636 "awkgram.c" /* yacc.c:1646 */ +#line 3815 "awkgram.c" /* yacc.c:1646 */ break; - case 152: -#line 1612 "awkgram.y" /* yacc.c:1646 */ + case 166: +#line 1703 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3649,45 +3828,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3653 "awkgram.c" /* yacc.c:1646 */ +#line 3832 "awkgram.c" /* yacc.c:1646 */ break; - case 155: -#line 1627 "awkgram.y" /* yacc.c:1646 */ + case 169: +#line 1718 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3662 "awkgram.c" /* yacc.c:1646 */ +#line 3841 "awkgram.c" /* yacc.c:1646 */ break; - case 156: -#line 1632 "awkgram.y" /* yacc.c:1646 */ + case 170: +#line 1723 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3671 "awkgram.c" /* yacc.c:1646 */ +#line 3850 "awkgram.c" /* yacc.c:1646 */ break; - case 157: -#line 1637 "awkgram.y" /* yacc.c:1646 */ + case 171: +#line 1728 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3679 "awkgram.c" /* yacc.c:1646 */ +#line 3858 "awkgram.c" /* yacc.c:1646 */ break; - case 158: -#line 1641 "awkgram.y" /* yacc.c:1646 */ + case 172: +#line 1732 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3687 "awkgram.c" /* yacc.c:1646 */ +#line 3866 "awkgram.c" /* yacc.c:1646 */ break; - case 159: -#line 1645 "awkgram.y" /* yacc.c:1646 */ + case 173: +#line 1736 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3702,11 +3881,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3706 "awkgram.c" /* yacc.c:1646 */ +#line 3885 "awkgram.c" /* yacc.c:1646 */ break; - case 160: -#line 1660 "awkgram.y" /* yacc.c:1646 */ + case 174: +#line 1751 "awkgram.y" /* yacc.c:1646 */ { /* * was: $$ = $2 @@ -3716,20 +3895,20 @@ regular_print: (yyvsp[-1])->memory = make_number(0.0); (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } -#line 3720 "awkgram.c" /* yacc.c:1646 */ +#line 3899 "awkgram.c" /* yacc.c:1646 */ break; - case 161: -#line 1673 "awkgram.y" /* yacc.c:1646 */ + case 175: +#line 1764 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3729 "awkgram.c" /* yacc.c:1646 */ +#line 3908 "awkgram.c" /* yacc.c:1646 */ break; - case 162: -#line 1678 "awkgram.y" /* yacc.c:1646 */ + case 176: +#line 1769 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -3763,11 +3942,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); at_seen = false; } -#line 3767 "awkgram.c" /* yacc.c:1646 */ +#line 3946 "awkgram.c" /* yacc.c:1646 */ break; - case 163: -#line 1715 "awkgram.y" /* yacc.c:1646 */ + case 177: +#line 1806 "awkgram.y" /* yacc.c:1646 */ { NODE *n; @@ -3792,49 +3971,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 3796 "awkgram.c" /* yacc.c:1646 */ +#line 3975 "awkgram.c" /* yacc.c:1646 */ break; - case 164: -#line 1743 "awkgram.y" /* yacc.c:1646 */ + case 178: +#line 1834 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3802 "awkgram.c" /* yacc.c:1646 */ +#line 3981 "awkgram.c" /* yacc.c:1646 */ break; - case 165: -#line 1745 "awkgram.y" /* yacc.c:1646 */ + case 179: +#line 1836 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3808 "awkgram.c" /* yacc.c:1646 */ +#line 3987 "awkgram.c" /* yacc.c:1646 */ break; - case 166: -#line 1750 "awkgram.y" /* yacc.c:1646 */ + case 180: +#line 1841 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3814 "awkgram.c" /* yacc.c:1646 */ +#line 3993 "awkgram.c" /* yacc.c:1646 */ break; - case 167: -#line 1752 "awkgram.y" /* yacc.c:1646 */ + case 181: +#line 1843 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3820 "awkgram.c" /* yacc.c:1646 */ +#line 3999 "awkgram.c" /* yacc.c:1646 */ break; - case 168: -#line 1757 "awkgram.y" /* yacc.c:1646 */ + case 182: +#line 1848 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3826 "awkgram.c" /* yacc.c:1646 */ +#line 4005 "awkgram.c" /* yacc.c:1646 */ break; - case 169: -#line 1759 "awkgram.y" /* yacc.c:1646 */ + case 183: +#line 1850 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3834 "awkgram.c" /* yacc.c:1646 */ +#line 4013 "awkgram.c" /* yacc.c:1646 */ break; - case 170: -#line 1766 "awkgram.y" /* yacc.c:1646 */ + case 184: +#line 1857 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3848,11 +4027,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 3852 "awkgram.c" /* yacc.c:1646 */ +#line 4031 "awkgram.c" /* yacc.c:1646 */ break; - case 171: -#line 1783 "awkgram.y" /* yacc.c:1646 */ + case 185: +#line 1874 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -3866,31 +4045,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 3870 "awkgram.c" /* yacc.c:1646 */ +#line 4049 "awkgram.c" /* yacc.c:1646 */ break; - case 172: -#line 1800 "awkgram.y" /* yacc.c:1646 */ + case 186: +#line 1891 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3876 "awkgram.c" /* yacc.c:1646 */ +#line 4055 "awkgram.c" /* yacc.c:1646 */ break; - case 173: -#line 1802 "awkgram.y" /* yacc.c:1646 */ + case 187: +#line 1893 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3884 "awkgram.c" /* yacc.c:1646 */ +#line 4063 "awkgram.c" /* yacc.c:1646 */ break; - case 174: -#line 1809 "awkgram.y" /* yacc.c:1646 */ + case 188: +#line 1900 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3890 "awkgram.c" /* yacc.c:1646 */ +#line 4069 "awkgram.c" /* yacc.c:1646 */ break; - case 175: -#line 1814 "awkgram.y" /* yacc.c:1646 */ + case 189: +#line 1905 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -3898,22 +4077,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 3902 "awkgram.c" /* yacc.c:1646 */ +#line 4081 "awkgram.c" /* yacc.c:1646 */ break; - case 176: -#line 1822 "awkgram.y" /* yacc.c:1646 */ + case 190: +#line 1913 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-1])->lextok; (yyvsp[-1])->memory = variable((yyvsp[-1])->source_line, arr, Node_var_new); (yyvsp[-1])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[0]), (yyvsp[-1])); } -#line 3913 "awkgram.c" /* yacc.c:1646 */ +#line 4092 "awkgram.c" /* yacc.c:1646 */ break; - case 177: -#line 1832 "awkgram.y" /* yacc.c:1646 */ + case 191: +#line 1923 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -3925,73 +4104,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 3929 "awkgram.c" /* yacc.c:1646 */ +#line 4108 "awkgram.c" /* yacc.c:1646 */ break; - case 178: -#line 1844 "awkgram.y" /* yacc.c:1646 */ + case 192: +#line 1935 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3939 "awkgram.c" /* yacc.c:1646 */ +#line 4118 "awkgram.c" /* yacc.c:1646 */ break; - case 179: -#line 1853 "awkgram.y" /* yacc.c:1646 */ + case 193: +#line 1944 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 3947 "awkgram.c" /* yacc.c:1646 */ +#line 4126 "awkgram.c" /* yacc.c:1646 */ break; - case 180: -#line 1857 "awkgram.y" /* yacc.c:1646 */ + case 194: +#line 1948 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 3955 "awkgram.c" /* yacc.c:1646 */ +#line 4134 "awkgram.c" /* yacc.c:1646 */ break; - case 181: -#line 1860 "awkgram.y" /* yacc.c:1646 */ + case 195: +#line 1951 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3961 "awkgram.c" /* yacc.c:1646 */ +#line 4140 "awkgram.c" /* yacc.c:1646 */ break; - case 183: -#line 1868 "awkgram.y" /* yacc.c:1646 */ + case 197: +#line 1959 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3967 "awkgram.c" /* yacc.c:1646 */ +#line 4146 "awkgram.c" /* yacc.c:1646 */ break; - case 184: -#line 1872 "awkgram.y" /* yacc.c:1646 */ + case 198: +#line 1963 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3973 "awkgram.c" /* yacc.c:1646 */ +#line 4152 "awkgram.c" /* yacc.c:1646 */ break; - case 187: -#line 1881 "awkgram.y" /* yacc.c:1646 */ + case 201: +#line 1972 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3979 "awkgram.c" /* yacc.c:1646 */ +#line 4158 "awkgram.c" /* yacc.c:1646 */ break; - case 188: -#line 1885 "awkgram.y" /* yacc.c:1646 */ + case 202: +#line 1976 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 3985 "awkgram.c" /* yacc.c:1646 */ +#line 4164 "awkgram.c" /* yacc.c:1646 */ break; - case 189: -#line 1889 "awkgram.y" /* yacc.c:1646 */ + case 203: +#line 1980 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3991 "awkgram.c" /* yacc.c:1646 */ +#line 4170 "awkgram.c" /* yacc.c:1646 */ break; -#line 3995 "awkgram.c" /* yacc.c:1646 */ +#line 4174 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4219,7 +4398,7 @@ yyreturn: #endif return yyresult; } -#line 1891 "awkgram.y" /* yacc.c:1906 */ +#line 1982 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -4345,6 +4524,7 @@ static const struct token tokentab[] = { {"systime", Op_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime, 0}, {"tolower", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower, 0}, {"toupper", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper, 0}, +{"typeof", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_typeof, 0}, {"while", Op_K_while, LEX_WHILE, BREAK|CONTINUE, 0, 0}, {"xor", Op_builtin, LEX_BUILTIN, GAWKX, do_xor, MPF(xor)}, }; @@ -5515,6 +5695,7 @@ yylex(void) bool inhex = false; bool intlstr = false; AWKNUM d; + bool collecting_hard_regexp = false; #define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline) @@ -5549,6 +5730,7 @@ yylex(void) lexeme = lexptr; thisline = NULL; +collect_regexp: if (want_regexp) { int in_brack = 0; /* count brackets, [[:alnum:]] allowed */ int b_index = -1; @@ -5635,7 +5817,13 @@ end_regexp: peek); } } - return lasttok = REGEXP; + if (collecting_hard_regexp) { + collecting_hard_regexp = false; + lasttok = HARD_REGEXP; + } else + lasttok = REGEXP; + + return lasttok; case '\n': pushback(); yyerror(_("unterminated regexp")); @@ -5693,6 +5881,13 @@ retry: return lasttok = NEWLINE; case '@': + c = nextc(true); + if (c == '/') { + want_regexp = true; + collecting_hard_regexp = true; + goto collect_regexp; + } + pushback(); at_seen = true; return lasttok = '@'; @@ -6502,7 +6697,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ } - } else if (r->builtin == do_isarray) { + } else if (r->builtin == do_isarray || r->builtin == do_typeof) { arg = subn->nexti; if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ @@ -7084,7 +7279,7 @@ make_regnode(int type, NODE *exp) n->type = type; n->re_cnt = 1; - if (type == Node_regex) { + if (type == Node_regex || type == Node_hardregex) { n->re_reg = make_regexp(exp->stptr, exp->stlen, false, true, false); if (n->re_reg == NULL) { freenode(n); @@ -7107,6 +7302,8 @@ mk_rexp(INSTRUCTION *list) ip = list->nexti; if (ip == list->lasti && ip->opcode == Op_match_rec) ip->opcode = Op_push_re; + else if (ip == list->lasti && ip->opcode == Op_push_re) + ; /* do nothing --- @/.../ */ else { ip = instruction(Op_push_re); ip->memory = make_regnode(Node_dynregex, NULL); @@ -169,7 +169,7 @@ extern double fmod(double x, double y); %} %token FUNC_CALL NAME REGEXP FILENAME -%token YNUMBER YSTRING +%token YNUMBER YSTRING HARD_REGEXP %token RELOP IO_OUT IO_IN %token ASSIGNOP ASSIGN MATCHOP CONCAT_OP %token SUBSCRIPT @@ -197,7 +197,7 @@ extern double fmod(double x, double y); %left MATCHOP %nonassoc RELOP '<' '>' IO_IN IO_OUT %left CONCAT_OP -%left YSTRING YNUMBER +%left YSTRING YNUMBER HARD_REGEXP %left '+' '-' %left '*' '/' '%' %right '!' UNARY @@ -498,6 +498,28 @@ regexp } ; +hard_regexp + : HARD_REGEXP + { + NODE *n, *exp; + char *re; + size_t len; + + re = $1->lextok; + $1->lextok = NULL; + len = strlen(re); + + exp = make_str_node(re, len, ALREADY_MALLOCED); + n = make_regnode(Node_hardregex, exp); + if (n == NULL) { + unref(exp); + YYABORT; + } + $$ = $1; + $$->opcode = Op_push_re; + $$->memory = n; + } + a_slash : '/' { bcfree($1); } @@ -1193,6 +1215,15 @@ case_value { $$ = $1; } | regexp { + if ($1->memory->type == Node_regex) + $1->opcode = Op_push_re; + else + $1->opcode = Op_push; + $$ = $1; + } + | hard_regexp + { + assert($1->memory->type == Node_hardregex); $1->opcode = Op_push_re; $$ = $1; } @@ -1341,6 +1372,48 @@ expression_list } ; +opt_fcall_expression_list + : /* empty */ + { $$ = NULL; } + | fcall_expression_list + { $$ = $1; } + ; + +fcall_expression_list + : fcall_exp + { $$ = mk_expression_list(NULL, $1); } + | fcall_expression_list comma fcall_exp + { + $$ = mk_expression_list($1, $3); + yyerrok; + } + | error + { $$ = NULL; } + | fcall_expression_list error + { + /* + * Returning the expression list instead of NULL lets + * snode get a list of arguments that it can count. + */ + $$ = $1; + } + | fcall_expression_list error fcall_exp + { + /* Ditto */ + $$ = mk_expression_list($1, $3); + } + | fcall_expression_list comma error + { + /* Ditto */ + $$ = $1; + } + ; + +fcall_exp + : exp { $$ = $1; } + | hard_regexp { $$ = list_create($1); } + ; + /* Expressions, not including the comma operator. */ exp : variable assign_operator exp %prec ASSIGNOP @@ -1350,10 +1423,27 @@ exp _("regular expression on right of assignment")); $$ = mk_assignment($1, $3, $2); } + | variable ASSIGN hard_regexp %prec ASSIGNOP + { + $$ = mk_assignment($1, list_create($3), $2); + } | exp LEX_AND exp { $$ = mk_boolean($1, $3, $2); } | exp LEX_OR exp { $$ = mk_boolean($1, $3, $2); } + | exp MATCHOP hard_regexp + { + if ($1->lasti->opcode == Op_match_rec) + warning_ln($2->source_line, + _("regular expression on left of `~' or `!~' operator")); + + assert($3->opcode == Op_push_re + && $3->memory->type == Node_hardregex); + /* RHS is @/.../ */ + $2->memory = $3->memory; + bcfree($3); + $$ = list_append($1, $2); + } | exp MATCHOP exp { if ($1->lasti->opcode == Op_match_rec) @@ -1361,6 +1451,7 @@ exp _("regular expression on left of `~' or `!~' operator")); if ($3->lasti == $3->nexti && $3->nexti->opcode == Op_match_rec) { + /* RHS is /.../ */ $2->memory = $3->nexti->memory; bcfree($3->nexti); /* Op_match_rec */ bcfree($3); /* Op_list */ @@ -1596,13 +1687,13 @@ non_post_simp_exp } | '(' exp r_paren { $$ = $2; } - | LEX_BUILTIN '(' opt_expression_list r_paren + | LEX_BUILTIN '(' opt_fcall_expression_list r_paren { $$ = snode($3, $1); if ($$ == NULL) YYABORT; } - | LEX_LENGTH '(' opt_expression_list r_paren + | LEX_LENGTH '(' opt_fcall_expression_list r_paren { $$ = snode($3, $1); if ($$ == NULL) @@ -1711,7 +1802,7 @@ func_call ; direct_func_call - : FUNC_CALL '(' opt_expression_list r_paren + : FUNC_CALL '(' opt_fcall_expression_list r_paren { NODE *n; @@ -2013,6 +2104,7 @@ static const struct token tokentab[] = { {"systime", Op_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime, 0}, {"tolower", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower, 0}, {"toupper", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper, 0}, +{"typeof", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_typeof, 0}, {"while", Op_K_while, LEX_WHILE, BREAK|CONTINUE, 0, 0}, {"xor", Op_builtin, LEX_BUILTIN, GAWKX, do_xor, MPF(xor)}, }; @@ -3183,6 +3275,7 @@ yylex(void) bool inhex = false; bool intlstr = false; AWKNUM d; + bool collecting_hard_regexp = false; #define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline) @@ -3217,6 +3310,7 @@ yylex(void) lexeme = lexptr; thisline = NULL; +collect_regexp: if (want_regexp) { int in_brack = 0; /* count brackets, [[:alnum:]] allowed */ int b_index = -1; @@ -3303,7 +3397,13 @@ end_regexp: peek); } } - return lasttok = REGEXP; + if (collecting_hard_regexp) { + collecting_hard_regexp = false; + lasttok = HARD_REGEXP; + } else + lasttok = REGEXP; + + return lasttok; case '\n': pushback(); yyerror(_("unterminated regexp")); @@ -3361,6 +3461,13 @@ retry: return lasttok = NEWLINE; case '@': + c = nextc(true); + if (c == '/') { + want_regexp = true; + collecting_hard_regexp = true; + goto collect_regexp; + } + pushback(); at_seen = true; return lasttok = '@'; @@ -4170,7 +4277,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ } - } else if (r->builtin == do_isarray) { + } else if (r->builtin == do_isarray || r->builtin == do_typeof) { arg = subn->nexti; if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ @@ -4752,7 +4859,7 @@ make_regnode(int type, NODE *exp) n->type = type; n->re_cnt = 1; - if (type == Node_regex) { + if (type == Node_regex || type == Node_hardregex) { n->re_reg = make_regexp(exp->stptr, exp->stlen, false, true, false); if (n->re_reg == NULL) { freenode(n); @@ -4775,6 +4882,8 @@ mk_rexp(INSTRUCTION *list) ip = list->nexti; if (ip == list->lasti && ip->opcode == Op_match_rec) ip->opcode = Op_push_re; + else if (ip == list->lasti && ip->opcode == Op_push_re) + ; /* do nothing --- @/.../ */ else { ip = instruction(Op_push_re); ip->memory = make_regnode(Node_dynregex, NULL); @@ -481,6 +481,12 @@ do_isarray(int nargs) { NODE *tmp; int ret = 1; + static bool warned = false; + + if (do_lint && ! warned) { + warned = true; + lintwarn(_("isarray is deprecated. Use typeof() instead")); + } tmp = POP(); if (tmp->type != Node_var_array) { @@ -3139,7 +3145,8 @@ call_sub(const char *name, int nargs) * push replace * push $0 */ - regex = make_regnode(Node_regex, regex); + if (regex->type != Node_hardregex) + regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); lhs = r_get_field(zero, (Func_ptr *) 0, true); @@ -3163,7 +3170,8 @@ call_sub(const char *name, int nargs) * nargs++ * } */ - regex = make_regnode(Node_regex, regex); + if (regex->type != Node_hardregex) + regex = make_regnode(Node_regex, regex); PUSH(regex); PUSH(replace); PUSH(glob_flag); @@ -3200,7 +3208,8 @@ call_match(int nargs) /* Don't need to pop the string just to push it back ... */ - regex = make_regnode(Node_regex, regex); + if (regex->type != Node_hardregex) + regex = make_regnode(Node_regex, regex); PUSH(regex); if (array) @@ -3228,7 +3237,8 @@ call_split_func(const char *name, int nargs) if (nargs >= 3) { regex = POP_STRING(); - regex = make_regnode(Node_regex, regex); + if (regex->type != Node_hardregex) + regex = make_regnode(Node_regex, regex); } else { if (name[0] == 's') { regex = make_regnode(Node_regex, FS_node->var_value); @@ -3855,6 +3865,44 @@ do_intdiv(int nargs) return make_number((AWKNUM) 0.0); } +/* do_typeof --- return a string with the type of the arg */ + +NODE * +do_typeof(int nargs) +{ + NODE *arg; + char *res = "unknown"; + int null_str_flags = (STRCUR|STRING|NUMCUR|NUMBER); + + arg = POP(); + switch (arg->type) { + case Node_var_array: + res = "array"; + break; + case Node_hardregex: + res = "regexp"; + break; + case Node_val: + case Node_var: + if ((arg->flags & null_str_flags) == null_str_flags) + res = "untyped"; + else if ((arg->flags & STRING) != 0) + res = "scalar_s"; + else if ((arg->flags & NUMBER) != 0) + res = "scalar_n"; + break; + case Node_var_new: + res = "untyped"; + break; + default: + fatal(_("typeof: unknown argument type `%s'"), + nodetype2str(arg->type)); + break; + } + + DEREF(arg); + return make_string(res, strlen(res)); +} /* mbc_byte_count --- return number of bytes for corresponding numchars multibyte characters */ diff --git a/doc/ChangeLog b/doc/ChangeLog index f38b795a..5a444252 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-05-03 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Add initial documentation for strongly typed + regexps and for `typeof'. + 2015-04-29 Arnold D. Robbins <arnold@skeeve.com> * 4.1.2: Release tar ball made. diff --git a/doc/gawk.info b/doc/gawk.info index c7fd5c36..ee547e65 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -175,6 +175,7 @@ entitled "GNU Free Documentation License". * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -3327,6 +3328,7 @@ you specify more complicated classes of strings. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @@ -4031,7 +4033,7 @@ No options default. -File: gawk.info, Node: Case-sensitivity, Next: Regexp Summary, Prev: GNU Regexp Operators, Up: Regexp +File: gawk.info, Node: Case-sensitivity, Next: Strong Regexp Constants, Prev: GNU Regexp Operators, Up: Regexp 3.8 Case Sensitivity in Matching ================================ @@ -4105,10 +4107,73 @@ obscure and we don't recommend it. means that `gawk' does the right thing. -File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp +File: gawk.info, Node: Strong Regexp Constants, Next: Regexp Summary, Prev: Case-sensitivity, Up: Regexp -3.9 Summary -=========== +3.9 Strongly Typed Regexp Constants +=================================== + +This minor node describes a `gawk'-specific feature. + + Regexp constants (`/.../') hold a strange position in the `awk' +language. In most contexts, they act like an expression: `$0 ~ /.../'. +In other contexts, they denote only a regexp to be matched. In no case +are they really a "first class citizen" of the language. That is, you +cannot define a scalar variable whose type is "regexp" in the same +sense that you can define a variable to be a number or a string: + + num = 42 Numeric variable + str = "hi" String variable + re = /foo/ Wrong! re is the result of $0 ~ /foo/ + + For a number of more advanced use cases (described later on in this +Info file), it would be nice to have regexp constants that are +"strongly typed"; in other words, that denote a regexp useful for +matching, and not an expression. + + `gawk' provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an `@' sign: + + re = @/foo/ Regexp variable + + Strongly typed regexp constants _cannot_ be used eveywhere that a +regular regexp constant can, because this would make the language even +more confusing. Instead, you may use them only in certain contexts: + + * On the righthand side of the `~' and `!~' operators: `some_var ~ + @/foo/' (*note Regexp Usage::). + + * In the `case' part of a `switch' statement (*note Switch + Statement::). + + * As an argument to one of the built-in functions that accept regexp + constants: `gensub()', `gsub()', `match()', `patsplit()', + `split()', and `sub()' (*note String Functions::). + + * As a parameter in a call to a user-defined function. (*note + User-defined::). + + * On the righthand side of an assignment to a variable: `some_var = + @/foo/'. In this case, the type of `some_var' is regexp. + Additionally, `some_var' can be used with `~' and `!~', passed to + one of the built-in functions listed above, or passed as a + parameter to a user-defined function. + + You may use the `typeof()' built-in function (*note Type Functions::) +to determine if a variable or function parameter is a regexp variable. + + The true power of this feature comes from the ability to create +variables that have regexp type. Such variables can be passed on to +user-defined functions, without the confusing aspects of computed +regular expressions created from strings or string constants. They may +also be passed through indirect function calls (*note Indirect Calls::) +onto the built-in functions that accept regexp constants. + + +File: gawk.info, Node: Regexp Summary, Prev: Strong Regexp Constants, Up: Regexp + +3.10 Summary +============ * Regular expressions describe sets of strings to be matched. In `awk', regular expression constants are written enclosed between @@ -4141,6 +4206,9 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp sensitivity of regexp matching. In other `awk' versions, use `tolower()' or `toupper()'. + * Strongly typed regexp constants (`@/.../') enable certain advanced + use cases to be described later on in the Info file. + File: gawk.info, Node: Reading Files, Next: Printing, Prev: Regexp, Up: Top @@ -13499,14 +13567,33 @@ File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Fu 9.1.7 Getting Type Information ------------------------------ -`gawk' provides a single function that lets you distinguish an array -from a scalar variable. This is necessary for writing code that -traverses every element of an array of arrays (*note Arrays of -Arrays::). +`gawk' provides two functions that lets you distinguish the type of a +variable. This is necessary for writing code that traverses every +element of an array of arrays (*note Arrays of Arrays::), and in other +contexts. `isarray(X)' Return a true value if X is an array. Otherwise, return false. +`typeof(X)' + Return one of the following strings, depending upon the type of X: + + `"array"' + X is an array. + + `"regexp"' + X is a strongly typed regexp (*note Strong Regexp + Constants::). + + `"scalar_n"' + X is a number. + + `"scalar_s"' + X is a string. + + `"untyped"' + X has not yet been given a type. + `isarray()' is meant for use in two circumstances. The first is when traversing a multidimensional array: you can test if an element is itself an array or not. The second is inside the body of a @@ -13520,6 +13607,14 @@ test if a parameter is an array or not. variable that has not been previously used to `isarray()', `gawk' ends up turning it into a scalar. + The `typeof()' function is general; it allows you to determine if a +variable or function parameter is a scalar, an array, or a strongly +typed regexp. + + `isarray()' is deprecated; you should use `typeof()' instead. You +should replace any existing uses of `isarray(var)' in your code with +`typeof(var) == "array"'. + File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in @@ -34728,6 +34823,8 @@ Index * trunc-mod operation: Arithmetic Ops. (line 66) * truth values: Truth Values. (line 6) * type conversion: Strings And Numbers. (line 21) +* type, of variable: Type Functions. (line 14) +* typeof: Type Functions. (line 14) * u debugger command (alias for until): Debugger Execution Control. (line 83) * unassigned array elements: Reference to Elements. @@ -34774,6 +34871,7 @@ Index * values, numeric: Basic Data Typing. (line 13) * values, string: Basic Data Typing. (line 13) * variable assignments and input files: Other Arguments. (line 26) +* variable type: Type Functions. (line 14) * variable typing: Typing and Comparison. (line 9) * variables <1>: Basic Data Typing. (line 6) @@ -34897,563 +34995,564 @@ Index Tag Table: Node: Top1204 -Node: Foreword342451 -Node: Foreword446895 -Node: Preface48426 -Ref: Preface-Footnote-151297 -Ref: Preface-Footnote-251404 -Ref: Preface-Footnote-351637 -Node: History51779 -Node: Names54130 -Ref: Names-Footnote-155224 -Node: This Manual55370 -Ref: This Manual-Footnote-161870 -Node: Conventions61970 -Node: Manual History64307 -Ref: Manual History-Footnote-167300 -Ref: Manual History-Footnote-267341 -Node: How To Contribute67415 -Node: Acknowledgments68544 -Node: Getting Started73410 -Node: Running gawk75849 -Node: One-shot77039 -Node: Read Terminal78303 -Node: Long80334 -Node: Executable Scripts81847 -Ref: Executable Scripts-Footnote-184636 -Node: Comments84739 -Node: Quoting87221 -Node: DOS Quoting92739 -Node: Sample Data Files93414 -Node: Very Simple96009 -Node: Two Rules100908 -Node: More Complex102794 -Node: Statements/Lines105656 -Ref: Statements/Lines-Footnote-1110111 -Node: Other Features110376 -Node: When111312 -Ref: When-Footnote-1113066 -Node: Intro Summary113131 -Node: Invoking Gawk114015 -Node: Command Line115529 -Node: Options116327 -Ref: Options-Footnote-1132122 -Ref: Options-Footnote-2132351 -Node: Other Arguments132376 -Node: Naming Standard Input135324 -Node: Environment Variables136417 -Node: AWKPATH Variable136975 -Ref: AWKPATH Variable-Footnote-1140382 -Ref: AWKPATH Variable-Footnote-2140427 -Node: AWKLIBPATH Variable140687 -Node: Other Environment Variables141943 -Node: Exit Status145574 -Node: Include Files146250 -Node: Loading Shared Libraries149839 -Node: Obsolete151266 -Node: Undocumented151958 -Node: Invoking Summary152225 -Node: Regexp153888 -Node: Regexp Usage155342 -Node: Escape Sequences157379 -Node: Regexp Operators163608 -Ref: Regexp Operators-Footnote-1171018 -Ref: Regexp Operators-Footnote-2171165 -Node: Bracket Expressions171263 -Ref: table-char-classes173278 -Node: Leftmost Longest176220 -Node: Computed Regexps177522 -Node: GNU Regexp Operators180951 -Node: Case-sensitivity184623 -Ref: Case-sensitivity-Footnote-1187508 -Ref: Case-sensitivity-Footnote-2187743 -Node: Regexp Summary187851 -Node: Reading Files189318 -Node: Records191480 -Node: awk split records192213 -Node: gawk split records197142 -Ref: gawk split records-Footnote-1201681 -Node: Fields201718 -Ref: Fields-Footnote-1204496 -Node: Nonconstant Fields204582 -Ref: Nonconstant Fields-Footnote-1206820 -Node: Changing Fields207023 -Node: Field Separators212954 -Node: Default Field Splitting215658 -Node: Regexp Field Splitting216775 -Node: Single Character Fields220125 -Node: Command Line Field Separator221184 -Node: Full Line Fields224401 -Ref: Full Line Fields-Footnote-1225922 -Ref: Full Line Fields-Footnote-2225968 -Node: Field Splitting Summary226069 -Node: Constant Size228143 -Node: Splitting By Content232722 -Ref: Splitting By Content-Footnote-1236687 -Node: Multiple Line236850 -Ref: Multiple Line-Footnote-1242731 -Node: Getline242910 -Node: Plain Getline245380 -Node: Getline/Variable248020 -Node: Getline/File249169 -Node: Getline/Variable/File250554 -Ref: Getline/Variable/File-Footnote-1252157 -Node: Getline/Pipe252244 -Node: Getline/Variable/Pipe254922 -Node: Getline/Coprocess256053 -Node: Getline/Variable/Coprocess257317 -Node: Getline Notes258056 -Node: Getline Summary260850 -Ref: table-getline-variants261262 -Node: Read Timeout262091 -Ref: Read Timeout-Footnote-1265994 -Node: Retrying Input266052 -Node: Command-line directories267251 -Node: Input Summary268158 -Node: Input Exercises271543 -Node: Printing272271 -Node: Print274106 -Node: Print Examples275563 -Node: Output Separators278342 -Node: OFMT280360 -Node: Printf281715 -Node: Basic Printf282500 -Node: Control Letters284072 -Node: Format Modifiers288057 -Node: Printf Examples294063 -Node: Redirection296549 -Node: Special FD303387 -Ref: Special FD-Footnote-1306553 -Node: Special Files306627 -Node: Other Inherited Files307244 -Node: Special Network308244 -Node: Special Caveats309106 -Node: Close Files And Pipes310055 -Ref: Close Files And Pipes-Footnote-1317240 -Ref: Close Files And Pipes-Footnote-2317388 -Node: Nonfatal317538 -Node: Output Summary319863 -Node: Output Exercises321084 -Node: Expressions321764 -Node: Values322953 -Node: Constants323630 -Node: Scalar Constants324321 -Ref: Scalar Constants-Footnote-1325183 -Node: Nondecimal-numbers325433 -Node: Regexp Constants328443 -Node: Using Constant Regexps328969 -Node: Variables332132 -Node: Using Variables332789 -Node: Assignment Options334700 -Node: Conversion336575 -Node: Strings And Numbers337099 -Ref: Strings And Numbers-Footnote-1340164 -Node: Locale influences conversions340273 -Ref: table-locale-affects343019 -Node: All Operators343611 -Node: Arithmetic Ops344240 -Node: Concatenation346745 -Ref: Concatenation-Footnote-1349564 -Node: Assignment Ops349671 -Ref: table-assign-ops354650 -Node: Increment Ops355960 -Node: Truth Values and Conditions359391 -Node: Truth Values360474 -Node: Typing and Comparison361523 -Node: Variable Typing362339 -Node: Comparison Operators366006 -Ref: table-relational-ops366416 -Node: POSIX String Comparison369911 -Ref: POSIX String Comparison-Footnote-1370983 -Node: Boolean Ops371122 -Ref: Boolean Ops-Footnote-1375600 -Node: Conditional Exp375691 -Node: Function Calls377429 -Node: Precedence381309 -Node: Locales384969 -Node: Expressions Summary386601 -Node: Patterns and Actions389172 -Node: Pattern Overview390292 -Node: Regexp Patterns391971 -Node: Expression Patterns392514 -Node: Ranges396294 -Node: BEGIN/END399401 -Node: Using BEGIN/END400162 -Ref: Using BEGIN/END-Footnote-1402898 -Node: I/O And BEGIN/END403004 -Node: BEGINFILE/ENDFILE405319 -Node: Empty408225 -Node: Using Shell Variables408542 -Node: Action Overview410815 -Node: Statements413141 -Node: If Statement414989 -Node: While Statement416484 -Node: Do Statement418512 -Node: For Statement419660 -Node: Switch Statement422818 -Node: Break Statement425200 -Node: Continue Statement427293 -Node: Next Statement429120 -Node: Nextfile Statement431501 -Node: Exit Statement434129 -Node: Built-in Variables436540 -Node: User-modified437673 -Ref: User-modified-Footnote-1445307 -Node: Auto-set445369 -Ref: Auto-set-Footnote-1459601 -Ref: Auto-set-Footnote-2459806 -Node: ARGC and ARGV459862 -Node: Pattern Action Summary464080 -Node: Arrays466513 -Node: Array Basics467842 -Node: Array Intro468686 -Ref: figure-array-elements470623 -Ref: Array Intro-Footnote-1473246 -Node: Reference to Elements473374 -Node: Assigning Elements475836 -Node: Array Example476327 -Node: Scanning an Array478086 -Node: Controlling Scanning481109 -Ref: Controlling Scanning-Footnote-1486503 -Node: Numeric Array Subscripts486819 -Node: Uninitialized Subscripts489004 -Node: Delete490621 -Ref: Delete-Footnote-1493370 -Node: Multidimensional493427 -Node: Multiscanning496524 -Node: Arrays of Arrays498113 -Node: Arrays Summary502867 -Node: Functions504958 -Node: Built-in505997 -Node: Calling Built-in507075 -Node: Numeric Functions509070 -Ref: Numeric Functions-Footnote-1513903 -Ref: Numeric Functions-Footnote-2514260 -Ref: Numeric Functions-Footnote-3514308 -Node: String Functions514580 -Ref: String Functions-Footnote-1538081 -Ref: String Functions-Footnote-2538210 -Ref: String Functions-Footnote-3538458 -Node: Gory Details538545 -Ref: table-sub-escapes540326 -Ref: table-sub-proposed541841 -Ref: table-posix-sub543203 -Ref: table-gensub-escapes544740 -Ref: Gory Details-Footnote-1545573 -Node: I/O Functions545724 -Ref: I/O Functions-Footnote-1552960 -Node: Time Functions553107 -Ref: Time Functions-Footnote-1563616 -Ref: Time Functions-Footnote-2563684 -Ref: Time Functions-Footnote-3563842 -Ref: Time Functions-Footnote-4563953 -Ref: Time Functions-Footnote-5564065 -Ref: Time Functions-Footnote-6564292 -Node: Bitwise Functions564558 -Ref: table-bitwise-ops565120 -Ref: Bitwise Functions-Footnote-1569448 -Node: Type Functions569620 -Node: I18N Functions570772 -Node: User-defined572419 -Node: Definition Syntax573224 -Ref: Definition Syntax-Footnote-1578883 -Node: Function Example578954 -Ref: Function Example-Footnote-1581875 -Node: Function Caveats581897 -Node: Calling A Function582415 -Node: Variable Scope583373 -Node: Pass By Value/Reference586366 -Node: Return Statement589863 -Node: Dynamic Typing592842 -Node: Indirect Calls593771 -Ref: Indirect Calls-Footnote-1604014 -Node: Functions Summary604142 -Node: Library Functions606844 -Ref: Library Functions-Footnote-1610452 -Ref: Library Functions-Footnote-2610595 -Node: Library Names610766 -Ref: Library Names-Footnote-1614224 -Ref: Library Names-Footnote-2614447 -Node: General Functions614533 -Node: Strtonum Function615636 -Node: Assert Function618658 -Node: Round Function621982 -Node: Cliff Random Function623523 -Node: Ordinal Functions624539 -Ref: Ordinal Functions-Footnote-1627602 -Ref: Ordinal Functions-Footnote-2627854 -Node: Join Function628065 -Ref: Join Function-Footnote-1629835 -Node: Getlocaltime Function630035 -Node: Readfile Function633779 -Node: Shell Quoting635751 -Node: Data File Management637152 -Node: Filetrans Function637784 -Node: Rewind Function641880 -Node: File Checking643266 -Ref: File Checking-Footnote-1644599 -Node: Empty Files644800 -Node: Ignoring Assigns646779 -Node: Getopt Function648329 -Ref: Getopt Function-Footnote-1659793 -Node: Passwd Functions659993 -Ref: Passwd Functions-Footnote-1668833 -Node: Group Functions668921 -Ref: Group Functions-Footnote-1676818 -Node: Walking Arrays677023 -Node: Library Functions Summary680029 -Node: Library Exercises681431 -Node: Sample Programs682711 -Node: Running Examples683481 -Node: Clones684209 -Node: Cut Program685433 -Node: Egrep Program695153 -Ref: Egrep Program-Footnote-1702656 -Node: Id Program702766 -Node: Split Program706442 -Ref: Split Program-Footnote-1709896 -Node: Tee Program710024 -Node: Uniq Program712813 -Node: Wc Program720232 -Ref: Wc Program-Footnote-1724482 -Node: Miscellaneous Programs724576 -Node: Dupword Program725789 -Node: Alarm Program727820 -Node: Translate Program732625 -Ref: Translate Program-Footnote-1737188 -Node: Labels Program737458 -Ref: Labels Program-Footnote-1740809 -Node: Word Sorting740893 -Node: History Sorting744963 -Node: Extract Program746798 -Node: Simple Sed754322 -Node: Igawk Program757392 -Ref: Igawk Program-Footnote-1771718 -Ref: Igawk Program-Footnote-2771919 -Ref: Igawk Program-Footnote-3772041 -Node: Anagram Program772156 -Node: Signature Program775217 -Node: Programs Summary776464 -Node: Programs Exercises777685 -Ref: Programs Exercises-Footnote-1781816 -Node: Advanced Features781907 -Node: Nondecimal Data783889 -Node: Array Sorting785479 -Node: Controlling Array Traversal786179 -Ref: Controlling Array Traversal-Footnote-1794545 -Node: Array Sorting Functions794663 -Ref: Array Sorting Functions-Footnote-1798549 -Node: Two-way I/O798745 -Ref: Two-way I/O-Footnote-1803690 -Ref: Two-way I/O-Footnote-2803876 -Node: TCP/IP Networking803958 -Node: Profiling806830 -Node: Advanced Features Summary815101 -Node: Internationalization817034 -Node: I18N and L10N818514 -Node: Explaining gettext819200 -Ref: Explaining gettext-Footnote-1824225 -Ref: Explaining gettext-Footnote-2824409 -Node: Programmer i18n824574 -Ref: Programmer i18n-Footnote-1829450 -Node: Translator i18n829499 -Node: String Extraction830293 -Ref: String Extraction-Footnote-1831424 -Node: Printf Ordering831510 -Ref: Printf Ordering-Footnote-1834296 -Node: I18N Portability834360 -Ref: I18N Portability-Footnote-1836816 -Node: I18N Example836879 -Ref: I18N Example-Footnote-1839682 -Node: Gawk I18N839754 -Node: I18N Summary840398 -Node: Debugger841738 -Node: Debugging842760 -Node: Debugging Concepts843201 -Node: Debugging Terms845011 -Node: Awk Debugging847583 -Node: Sample Debugging Session848489 -Node: Debugger Invocation849023 -Node: Finding The Bug850408 -Node: List of Debugger Commands856887 -Node: Breakpoint Control858219 -Node: Debugger Execution Control861896 -Node: Viewing And Changing Data865255 -Node: Execution Stack868631 -Node: Debugger Info870266 -Node: Miscellaneous Debugger Commands874311 -Node: Readline Support879312 -Node: Limitations880206 -Node: Debugging Summary882321 -Node: Arbitrary Precision Arithmetic883495 -Node: Computer Arithmetic884911 -Ref: table-numeric-ranges888488 -Ref: Computer Arithmetic-Footnote-1889012 -Node: Math Definitions889069 -Ref: table-ieee-formats892364 -Ref: Math Definitions-Footnote-1892968 -Node: MPFR features893073 -Node: FP Math Caution894744 -Ref: FP Math Caution-Footnote-1895794 -Node: Inexactness of computations896163 -Node: Inexact representation897122 -Node: Comparing FP Values898480 -Node: Errors accumulate899562 -Node: Getting Accuracy900994 -Node: Try To Round903698 -Node: Setting precision904597 -Ref: table-predefined-precision-strings905281 -Node: Setting the rounding mode907110 -Ref: table-gawk-rounding-modes907474 -Ref: Setting the rounding mode-Footnote-1910926 -Node: Arbitrary Precision Integers911105 -Ref: Arbitrary Precision Integers-Footnote-1916021 -Node: POSIX Floating Point Problems916170 -Ref: POSIX Floating Point Problems-Footnote-1920049 -Node: Floating point summary920087 -Node: Dynamic Extensions922274 -Node: Extension Intro923826 -Node: Plugin License925091 -Node: Extension Mechanism Outline925888 -Ref: figure-load-extension926316 -Ref: figure-register-new-function927796 -Ref: figure-call-new-function928800 -Node: Extension API Description930787 -Node: Extension API Functions Introduction932321 -Node: General Data Types937190 -Ref: General Data Types-Footnote-1943090 -Node: Memory Allocation Functions943389 -Ref: Memory Allocation Functions-Footnote-1946228 -Node: Constructor Functions946327 -Node: Registration Functions948066 -Node: Extension Functions948751 -Node: Exit Callback Functions951048 -Node: Extension Version String952296 -Node: Input Parsers952959 -Node: Output Wrappers962834 -Node: Two-way processors967347 -Node: Printing Messages969610 -Ref: Printing Messages-Footnote-1970686 -Node: Updating `ERRNO'970838 -Node: Requesting Values971578 -Ref: table-value-types-returned972305 -Node: Accessing Parameters973262 -Node: Symbol Table Access974496 -Node: Symbol table by name975010 -Node: Symbol table by cookie977030 -Ref: Symbol table by cookie-Footnote-1981175 -Node: Cached values981238 -Ref: Cached values-Footnote-1984734 -Node: Array Manipulation984825 -Ref: Array Manipulation-Footnote-1985915 -Node: Array Data Types985952 -Ref: Array Data Types-Footnote-1988607 -Node: Array Functions988699 -Node: Flattening Arrays992558 -Node: Creating Arrays999460 -Node: Redirection API1004231 -Node: Extension API Variables1007056 -Node: Extension Versioning1007689 -Node: Extension API Informational Variables1009580 -Node: Extension API Boilerplate1010645 -Node: Finding Extensions1014454 -Node: Extension Example1015014 -Node: Internal File Description1015786 -Node: Internal File Ops1019853 -Ref: Internal File Ops-Footnote-11031604 -Node: Using Internal File Ops1031744 -Ref: Using Internal File Ops-Footnote-11034127 -Node: Extension Samples1034400 -Node: Extension Sample File Functions1035928 -Node: Extension Sample Fnmatch1043609 -Node: Extension Sample Fork1045097 -Node: Extension Sample Inplace1046312 -Node: Extension Sample Ord1048398 -Node: Extension Sample Readdir1049234 -Ref: table-readdir-file-types1050111 -Node: Extension Sample Revout1050922 -Node: Extension Sample Rev2way1051511 -Node: Extension Sample Read write array1052251 -Node: Extension Sample Readfile1054191 -Node: Extension Sample Time1055286 -Node: Extension Sample API Tests1056634 -Node: gawkextlib1057125 -Node: Extension summary1059572 -Node: Extension Exercises1063261 -Node: Language History1064757 -Node: V7/SVR3.11066413 -Node: SVR41068566 -Node: POSIX1070000 -Node: BTL1071381 -Node: POSIX/GNU1072112 -Node: Feature History1077951 -Node: Common Extensions1091941 -Node: Ranges and Locales1093313 -Ref: Ranges and Locales-Footnote-11097932 -Ref: Ranges and Locales-Footnote-21097959 -Ref: Ranges and Locales-Footnote-31098194 -Node: Contributors1098415 -Node: History summary1103955 -Node: Installation1105334 -Node: Gawk Distribution1106280 -Node: Getting1106764 -Node: Extracting1107587 -Node: Distribution contents1109224 -Node: Unix Installation1115326 -Node: Quick Installation1116009 -Node: Shell Startup Files1118420 -Node: Additional Configuration Options1119499 -Node: Configuration Philosophy1121303 -Node: Non-Unix Installation1123672 -Node: PC Installation1124130 -Node: PC Binary Installation1125450 -Node: PC Compiling1127298 -Ref: PC Compiling-Footnote-11130319 -Node: PC Testing1130428 -Node: PC Using1131604 -Node: Cygwin1135719 -Node: MSYS1136489 -Node: VMS Installation1136990 -Node: VMS Compilation1137782 -Ref: VMS Compilation-Footnote-11139011 -Node: VMS Dynamic Extensions1139069 -Node: VMS Installation Details1140753 -Node: VMS Running1143004 -Node: VMS GNV1145844 -Node: VMS Old Gawk1146579 -Node: Bugs1147049 -Node: Other Versions1150938 -Node: Installation summary1157372 -Node: Notes1158431 -Node: Compatibility Mode1159296 -Node: Additions1160078 -Node: Accessing The Source1161003 -Node: Adding Code1162438 -Node: New Ports1168595 -Node: Derived Files1173077 -Ref: Derived Files-Footnote-11178552 -Ref: Derived Files-Footnote-21178586 -Ref: Derived Files-Footnote-31179182 -Node: Future Extensions1179296 -Node: Implementation Limitations1179902 -Node: Extension Design1181150 -Node: Old Extension Problems1182304 -Ref: Old Extension Problems-Footnote-11183821 -Node: Extension New Mechanism Goals1183878 -Ref: Extension New Mechanism Goals-Footnote-11187238 -Node: Extension Other Design Decisions1187427 -Node: Extension Future Growth1189535 -Node: Old Extension Mechanism1190371 -Node: Notes summary1192133 -Node: Basic Concepts1193319 -Node: Basic High Level1194000 -Ref: figure-general-flow1194272 -Ref: figure-process-flow1194871 -Ref: Basic High Level-Footnote-11198100 -Node: Basic Data Typing1198285 -Node: Glossary1201613 -Node: Copying1233542 -Node: GNU Free Documentation License1271098 -Node: Index1296234 +Node: Foreword342524 +Node: Foreword446968 +Node: Preface48499 +Ref: Preface-Footnote-151370 +Ref: Preface-Footnote-251477 +Ref: Preface-Footnote-351710 +Node: History51852 +Node: Names54203 +Ref: Names-Footnote-155297 +Node: This Manual55443 +Ref: This Manual-Footnote-161943 +Node: Conventions62043 +Node: Manual History64380 +Ref: Manual History-Footnote-167373 +Ref: Manual History-Footnote-267414 +Node: How To Contribute67488 +Node: Acknowledgments68617 +Node: Getting Started73483 +Node: Running gawk75922 +Node: One-shot77112 +Node: Read Terminal78376 +Node: Long80407 +Node: Executable Scripts81920 +Ref: Executable Scripts-Footnote-184709 +Node: Comments84812 +Node: Quoting87294 +Node: DOS Quoting92812 +Node: Sample Data Files93487 +Node: Very Simple96082 +Node: Two Rules100981 +Node: More Complex102867 +Node: Statements/Lines105729 +Ref: Statements/Lines-Footnote-1110184 +Node: Other Features110449 +Node: When111385 +Ref: When-Footnote-1113139 +Node: Intro Summary113204 +Node: Invoking Gawk114088 +Node: Command Line115602 +Node: Options116400 +Ref: Options-Footnote-1132195 +Ref: Options-Footnote-2132424 +Node: Other Arguments132449 +Node: Naming Standard Input135397 +Node: Environment Variables136490 +Node: AWKPATH Variable137048 +Ref: AWKPATH Variable-Footnote-1140455 +Ref: AWKPATH Variable-Footnote-2140500 +Node: AWKLIBPATH Variable140760 +Node: Other Environment Variables142016 +Node: Exit Status145647 +Node: Include Files146323 +Node: Loading Shared Libraries149912 +Node: Obsolete151339 +Node: Undocumented152031 +Node: Invoking Summary152298 +Node: Regexp153961 +Node: Regexp Usage155480 +Node: Escape Sequences157517 +Node: Regexp Operators163746 +Ref: Regexp Operators-Footnote-1171156 +Ref: Regexp Operators-Footnote-2171303 +Node: Bracket Expressions171401 +Ref: table-char-classes173416 +Node: Leftmost Longest176358 +Node: Computed Regexps177660 +Node: GNU Regexp Operators181089 +Node: Case-sensitivity184761 +Ref: Case-sensitivity-Footnote-1187655 +Ref: Case-sensitivity-Footnote-2187890 +Node: Strong Regexp Constants187998 +Node: Regexp Summary190754 +Node: Reading Files192361 +Node: Records194523 +Node: awk split records195256 +Node: gawk split records200185 +Ref: gawk split records-Footnote-1204724 +Node: Fields204761 +Ref: Fields-Footnote-1207539 +Node: Nonconstant Fields207625 +Ref: Nonconstant Fields-Footnote-1209863 +Node: Changing Fields210066 +Node: Field Separators215997 +Node: Default Field Splitting218701 +Node: Regexp Field Splitting219818 +Node: Single Character Fields223168 +Node: Command Line Field Separator224227 +Node: Full Line Fields227444 +Ref: Full Line Fields-Footnote-1228965 +Ref: Full Line Fields-Footnote-2229011 +Node: Field Splitting Summary229112 +Node: Constant Size231186 +Node: Splitting By Content235765 +Ref: Splitting By Content-Footnote-1239730 +Node: Multiple Line239893 +Ref: Multiple Line-Footnote-1245774 +Node: Getline245953 +Node: Plain Getline248423 +Node: Getline/Variable251063 +Node: Getline/File252212 +Node: Getline/Variable/File253597 +Ref: Getline/Variable/File-Footnote-1255200 +Node: Getline/Pipe255287 +Node: Getline/Variable/Pipe257965 +Node: Getline/Coprocess259096 +Node: Getline/Variable/Coprocess260360 +Node: Getline Notes261099 +Node: Getline Summary263893 +Ref: table-getline-variants264305 +Node: Read Timeout265134 +Ref: Read Timeout-Footnote-1269037 +Node: Retrying Input269095 +Node: Command-line directories270294 +Node: Input Summary271201 +Node: Input Exercises274586 +Node: Printing275314 +Node: Print277149 +Node: Print Examples278606 +Node: Output Separators281385 +Node: OFMT283403 +Node: Printf284758 +Node: Basic Printf285543 +Node: Control Letters287115 +Node: Format Modifiers291100 +Node: Printf Examples297106 +Node: Redirection299592 +Node: Special FD306430 +Ref: Special FD-Footnote-1309596 +Node: Special Files309670 +Node: Other Inherited Files310287 +Node: Special Network311287 +Node: Special Caveats312149 +Node: Close Files And Pipes313098 +Ref: Close Files And Pipes-Footnote-1320283 +Ref: Close Files And Pipes-Footnote-2320431 +Node: Nonfatal320581 +Node: Output Summary322906 +Node: Output Exercises324127 +Node: Expressions324807 +Node: Values325996 +Node: Constants326673 +Node: Scalar Constants327364 +Ref: Scalar Constants-Footnote-1328226 +Node: Nondecimal-numbers328476 +Node: Regexp Constants331486 +Node: Using Constant Regexps332012 +Node: Variables335175 +Node: Using Variables335832 +Node: Assignment Options337743 +Node: Conversion339618 +Node: Strings And Numbers340142 +Ref: Strings And Numbers-Footnote-1343207 +Node: Locale influences conversions343316 +Ref: table-locale-affects346062 +Node: All Operators346654 +Node: Arithmetic Ops347283 +Node: Concatenation349788 +Ref: Concatenation-Footnote-1352607 +Node: Assignment Ops352714 +Ref: table-assign-ops357693 +Node: Increment Ops359003 +Node: Truth Values and Conditions362434 +Node: Truth Values363517 +Node: Typing and Comparison364566 +Node: Variable Typing365382 +Node: Comparison Operators369049 +Ref: table-relational-ops369459 +Node: POSIX String Comparison372954 +Ref: POSIX String Comparison-Footnote-1374026 +Node: Boolean Ops374165 +Ref: Boolean Ops-Footnote-1378643 +Node: Conditional Exp378734 +Node: Function Calls380472 +Node: Precedence384352 +Node: Locales388012 +Node: Expressions Summary389644 +Node: Patterns and Actions392215 +Node: Pattern Overview393335 +Node: Regexp Patterns395014 +Node: Expression Patterns395557 +Node: Ranges399337 +Node: BEGIN/END402444 +Node: Using BEGIN/END403205 +Ref: Using BEGIN/END-Footnote-1405941 +Node: I/O And BEGIN/END406047 +Node: BEGINFILE/ENDFILE408362 +Node: Empty411268 +Node: Using Shell Variables411585 +Node: Action Overview413858 +Node: Statements416184 +Node: If Statement418032 +Node: While Statement419527 +Node: Do Statement421555 +Node: For Statement422703 +Node: Switch Statement425861 +Node: Break Statement428243 +Node: Continue Statement430336 +Node: Next Statement432163 +Node: Nextfile Statement434544 +Node: Exit Statement437172 +Node: Built-in Variables439583 +Node: User-modified440716 +Ref: User-modified-Footnote-1448350 +Node: Auto-set448412 +Ref: Auto-set-Footnote-1462644 +Ref: Auto-set-Footnote-2462849 +Node: ARGC and ARGV462905 +Node: Pattern Action Summary467123 +Node: Arrays469556 +Node: Array Basics470885 +Node: Array Intro471729 +Ref: figure-array-elements473666 +Ref: Array Intro-Footnote-1476289 +Node: Reference to Elements476417 +Node: Assigning Elements478879 +Node: Array Example479370 +Node: Scanning an Array481129 +Node: Controlling Scanning484152 +Ref: Controlling Scanning-Footnote-1489546 +Node: Numeric Array Subscripts489862 +Node: Uninitialized Subscripts492047 +Node: Delete493664 +Ref: Delete-Footnote-1496413 +Node: Multidimensional496470 +Node: Multiscanning499567 +Node: Arrays of Arrays501156 +Node: Arrays Summary505910 +Node: Functions508001 +Node: Built-in509040 +Node: Calling Built-in510118 +Node: Numeric Functions512113 +Ref: Numeric Functions-Footnote-1516946 +Ref: Numeric Functions-Footnote-2517303 +Ref: Numeric Functions-Footnote-3517351 +Node: String Functions517623 +Ref: String Functions-Footnote-1541124 +Ref: String Functions-Footnote-2541253 +Ref: String Functions-Footnote-3541501 +Node: Gory Details541588 +Ref: table-sub-escapes543369 +Ref: table-sub-proposed544884 +Ref: table-posix-sub546246 +Ref: table-gensub-escapes547783 +Ref: Gory Details-Footnote-1548616 +Node: I/O Functions548767 +Ref: I/O Functions-Footnote-1556003 +Node: Time Functions556150 +Ref: Time Functions-Footnote-1566659 +Ref: Time Functions-Footnote-2566727 +Ref: Time Functions-Footnote-3566885 +Ref: Time Functions-Footnote-4566996 +Ref: Time Functions-Footnote-5567108 +Ref: Time Functions-Footnote-6567335 +Node: Bitwise Functions567601 +Ref: table-bitwise-ops568163 +Ref: Bitwise Functions-Footnote-1572491 +Node: Type Functions572663 +Node: I18N Functions574516 +Node: User-defined576163 +Node: Definition Syntax576968 +Ref: Definition Syntax-Footnote-1582627 +Node: Function Example582698 +Ref: Function Example-Footnote-1585619 +Node: Function Caveats585641 +Node: Calling A Function586159 +Node: Variable Scope587117 +Node: Pass By Value/Reference590110 +Node: Return Statement593607 +Node: Dynamic Typing596586 +Node: Indirect Calls597515 +Ref: Indirect Calls-Footnote-1607758 +Node: Functions Summary607886 +Node: Library Functions610588 +Ref: Library Functions-Footnote-1614196 +Ref: Library Functions-Footnote-2614339 +Node: Library Names614510 +Ref: Library Names-Footnote-1617968 +Ref: Library Names-Footnote-2618191 +Node: General Functions618277 +Node: Strtonum Function619380 +Node: Assert Function622402 +Node: Round Function625726 +Node: Cliff Random Function627267 +Node: Ordinal Functions628283 +Ref: Ordinal Functions-Footnote-1631346 +Ref: Ordinal Functions-Footnote-2631598 +Node: Join Function631809 +Ref: Join Function-Footnote-1633579 +Node: Getlocaltime Function633779 +Node: Readfile Function637523 +Node: Shell Quoting639495 +Node: Data File Management640896 +Node: Filetrans Function641528 +Node: Rewind Function645624 +Node: File Checking647010 +Ref: File Checking-Footnote-1648343 +Node: Empty Files648544 +Node: Ignoring Assigns650523 +Node: Getopt Function652073 +Ref: Getopt Function-Footnote-1663537 +Node: Passwd Functions663737 +Ref: Passwd Functions-Footnote-1672577 +Node: Group Functions672665 +Ref: Group Functions-Footnote-1680562 +Node: Walking Arrays680767 +Node: Library Functions Summary683773 +Node: Library Exercises685175 +Node: Sample Programs686455 +Node: Running Examples687225 +Node: Clones687953 +Node: Cut Program689177 +Node: Egrep Program698897 +Ref: Egrep Program-Footnote-1706400 +Node: Id Program706510 +Node: Split Program710186 +Ref: Split Program-Footnote-1713640 +Node: Tee Program713768 +Node: Uniq Program716557 +Node: Wc Program723976 +Ref: Wc Program-Footnote-1728226 +Node: Miscellaneous Programs728320 +Node: Dupword Program729533 +Node: Alarm Program731564 +Node: Translate Program736369 +Ref: Translate Program-Footnote-1740932 +Node: Labels Program741202 +Ref: Labels Program-Footnote-1744553 +Node: Word Sorting744637 +Node: History Sorting748707 +Node: Extract Program750542 +Node: Simple Sed758066 +Node: Igawk Program761136 +Ref: Igawk Program-Footnote-1775462 +Ref: Igawk Program-Footnote-2775663 +Ref: Igawk Program-Footnote-3775785 +Node: Anagram Program775900 +Node: Signature Program778961 +Node: Programs Summary780208 +Node: Programs Exercises781429 +Ref: Programs Exercises-Footnote-1785560 +Node: Advanced Features785651 +Node: Nondecimal Data787633 +Node: Array Sorting789223 +Node: Controlling Array Traversal789923 +Ref: Controlling Array Traversal-Footnote-1798289 +Node: Array Sorting Functions798407 +Ref: Array Sorting Functions-Footnote-1802293 +Node: Two-way I/O802489 +Ref: Two-way I/O-Footnote-1807434 +Ref: Two-way I/O-Footnote-2807620 +Node: TCP/IP Networking807702 +Node: Profiling810574 +Node: Advanced Features Summary818845 +Node: Internationalization820778 +Node: I18N and L10N822258 +Node: Explaining gettext822944 +Ref: Explaining gettext-Footnote-1827969 +Ref: Explaining gettext-Footnote-2828153 +Node: Programmer i18n828318 +Ref: Programmer i18n-Footnote-1833194 +Node: Translator i18n833243 +Node: String Extraction834037 +Ref: String Extraction-Footnote-1835168 +Node: Printf Ordering835254 +Ref: Printf Ordering-Footnote-1838040 +Node: I18N Portability838104 +Ref: I18N Portability-Footnote-1840560 +Node: I18N Example840623 +Ref: I18N Example-Footnote-1843426 +Node: Gawk I18N843498 +Node: I18N Summary844142 +Node: Debugger845482 +Node: Debugging846504 +Node: Debugging Concepts846945 +Node: Debugging Terms848755 +Node: Awk Debugging851327 +Node: Sample Debugging Session852233 +Node: Debugger Invocation852767 +Node: Finding The Bug854152 +Node: List of Debugger Commands860631 +Node: Breakpoint Control861963 +Node: Debugger Execution Control865640 +Node: Viewing And Changing Data868999 +Node: Execution Stack872375 +Node: Debugger Info874010 +Node: Miscellaneous Debugger Commands878055 +Node: Readline Support883056 +Node: Limitations883950 +Node: Debugging Summary886065 +Node: Arbitrary Precision Arithmetic887239 +Node: Computer Arithmetic888655 +Ref: table-numeric-ranges892232 +Ref: Computer Arithmetic-Footnote-1892756 +Node: Math Definitions892813 +Ref: table-ieee-formats896108 +Ref: Math Definitions-Footnote-1896712 +Node: MPFR features896817 +Node: FP Math Caution898488 +Ref: FP Math Caution-Footnote-1899538 +Node: Inexactness of computations899907 +Node: Inexact representation900866 +Node: Comparing FP Values902224 +Node: Errors accumulate903306 +Node: Getting Accuracy904738 +Node: Try To Round907442 +Node: Setting precision908341 +Ref: table-predefined-precision-strings909025 +Node: Setting the rounding mode910854 +Ref: table-gawk-rounding-modes911218 +Ref: Setting the rounding mode-Footnote-1914670 +Node: Arbitrary Precision Integers914849 +Ref: Arbitrary Precision Integers-Footnote-1919765 +Node: POSIX Floating Point Problems919914 +Ref: POSIX Floating Point Problems-Footnote-1923793 +Node: Floating point summary923831 +Node: Dynamic Extensions926018 +Node: Extension Intro927570 +Node: Plugin License928835 +Node: Extension Mechanism Outline929632 +Ref: figure-load-extension930060 +Ref: figure-register-new-function931540 +Ref: figure-call-new-function932544 +Node: Extension API Description934531 +Node: Extension API Functions Introduction936065 +Node: General Data Types940934 +Ref: General Data Types-Footnote-1946834 +Node: Memory Allocation Functions947133 +Ref: Memory Allocation Functions-Footnote-1949972 +Node: Constructor Functions950071 +Node: Registration Functions951810 +Node: Extension Functions952495 +Node: Exit Callback Functions954792 +Node: Extension Version String956040 +Node: Input Parsers956703 +Node: Output Wrappers966578 +Node: Two-way processors971091 +Node: Printing Messages973354 +Ref: Printing Messages-Footnote-1974430 +Node: Updating `ERRNO'974582 +Node: Requesting Values975322 +Ref: table-value-types-returned976049 +Node: Accessing Parameters977006 +Node: Symbol Table Access978240 +Node: Symbol table by name978754 +Node: Symbol table by cookie980774 +Ref: Symbol table by cookie-Footnote-1984919 +Node: Cached values984982 +Ref: Cached values-Footnote-1988478 +Node: Array Manipulation988569 +Ref: Array Manipulation-Footnote-1989659 +Node: Array Data Types989696 +Ref: Array Data Types-Footnote-1992351 +Node: Array Functions992443 +Node: Flattening Arrays996302 +Node: Creating Arrays1003204 +Node: Redirection API1007975 +Node: Extension API Variables1010800 +Node: Extension Versioning1011433 +Node: Extension API Informational Variables1013324 +Node: Extension API Boilerplate1014389 +Node: Finding Extensions1018198 +Node: Extension Example1018758 +Node: Internal File Description1019530 +Node: Internal File Ops1023597 +Ref: Internal File Ops-Footnote-11035348 +Node: Using Internal File Ops1035488 +Ref: Using Internal File Ops-Footnote-11037871 +Node: Extension Samples1038144 +Node: Extension Sample File Functions1039672 +Node: Extension Sample Fnmatch1047353 +Node: Extension Sample Fork1048841 +Node: Extension Sample Inplace1050056 +Node: Extension Sample Ord1052142 +Node: Extension Sample Readdir1052978 +Ref: table-readdir-file-types1053855 +Node: Extension Sample Revout1054666 +Node: Extension Sample Rev2way1055255 +Node: Extension Sample Read write array1055995 +Node: Extension Sample Readfile1057935 +Node: Extension Sample Time1059030 +Node: Extension Sample API Tests1060378 +Node: gawkextlib1060869 +Node: Extension summary1063316 +Node: Extension Exercises1067005 +Node: Language History1068501 +Node: V7/SVR3.11070157 +Node: SVR41072310 +Node: POSIX1073744 +Node: BTL1075125 +Node: POSIX/GNU1075856 +Node: Feature History1081695 +Node: Common Extensions1095685 +Node: Ranges and Locales1097057 +Ref: Ranges and Locales-Footnote-11101676 +Ref: Ranges and Locales-Footnote-21101703 +Ref: Ranges and Locales-Footnote-31101938 +Node: Contributors1102159 +Node: History summary1107699 +Node: Installation1109078 +Node: Gawk Distribution1110024 +Node: Getting1110508 +Node: Extracting1111331 +Node: Distribution contents1112968 +Node: Unix Installation1119070 +Node: Quick Installation1119753 +Node: Shell Startup Files1122164 +Node: Additional Configuration Options1123243 +Node: Configuration Philosophy1125047 +Node: Non-Unix Installation1127416 +Node: PC Installation1127874 +Node: PC Binary Installation1129194 +Node: PC Compiling1131042 +Ref: PC Compiling-Footnote-11134063 +Node: PC Testing1134172 +Node: PC Using1135348 +Node: Cygwin1139463 +Node: MSYS1140233 +Node: VMS Installation1140734 +Node: VMS Compilation1141526 +Ref: VMS Compilation-Footnote-11142755 +Node: VMS Dynamic Extensions1142813 +Node: VMS Installation Details1144497 +Node: VMS Running1146748 +Node: VMS GNV1149588 +Node: VMS Old Gawk1150323 +Node: Bugs1150793 +Node: Other Versions1154682 +Node: Installation summary1161116 +Node: Notes1162175 +Node: Compatibility Mode1163040 +Node: Additions1163822 +Node: Accessing The Source1164747 +Node: Adding Code1166182 +Node: New Ports1172339 +Node: Derived Files1176821 +Ref: Derived Files-Footnote-11182296 +Ref: Derived Files-Footnote-21182330 +Ref: Derived Files-Footnote-31182926 +Node: Future Extensions1183040 +Node: Implementation Limitations1183646 +Node: Extension Design1184894 +Node: Old Extension Problems1186048 +Ref: Old Extension Problems-Footnote-11187565 +Node: Extension New Mechanism Goals1187622 +Ref: Extension New Mechanism Goals-Footnote-11190982 +Node: Extension Other Design Decisions1191171 +Node: Extension Future Growth1193279 +Node: Old Extension Mechanism1194115 +Node: Notes summary1195877 +Node: Basic Concepts1197063 +Node: Basic High Level1197744 +Ref: figure-general-flow1198016 +Ref: figure-process-flow1198615 +Ref: Basic High Level-Footnote-11201844 +Node: Basic Data Typing1202029 +Node: Glossary1205357 +Node: Copying1237286 +Node: GNU Free Documentation License1274842 +Node: Index1299978 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 501aacde..7e53a1e4 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -562,6 +562,7 @@ particular records in a file and perform operations upon them. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -4999,6 +5000,7 @@ regular expressions work, we present more complicated instances. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @end menu @@ -6246,6 +6248,85 @@ The value of @code{IGNORECASE} has no effect if @command{gawk} is in compatibility mode (@pxref{Options}). Case is always significant in compatibility mode. +@node Strong Regexp Constants +@section Strongly Typed Regexp Constants + +This @value{SECTION} describes a @command{gawk}-specific feature. + +Regexp constants (@code{/@dots{}/}) hold a strange position in the +@command{awk} language. In most contexts, they act like an expression: +@samp{$0 ~ /@dots{}/}. In other contexts, they denote only a regexp to +be matched. In no case are they really a ``first class citizen'' of the +language. That is, you cannot define a scalar variable whose type is +``regexp'' in the same sense that you can define a variable to be a +number or a string: + +@example +num = 42 @ii{Numeric variable} +str = "hi" @ii{String variable} +re = /foo/ @ii{Wrong!} re @ii{is the result of} $0 ~ /foo/ +@end example + +For a number of more advanced use cases (described later on in this +@value{DOCUMENT}), it would be nice to have regexp constants that +are @dfn{strongly typed}; in other words, that denote a regexp useful +for matching, and not an expression. + +@command{gawk} provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an @samp{@@} sign: + +@example +re = @@/foo/ @ii{Regexp variable} +@end example + +Strongly typed regexp constants @emph{cannot} be used eveywhere that a +regular regexp constant can, because this would make the language even more +confusing. Instead, you may use them only in certain contexts: + +@itemize @bullet +@item +On the righthand side of the @samp{~} and @samp{!~} operators: @samp{some_var ~ @@/foo/} +(@pxref{Regexp Usage}). + +@item +In the @code{case} part of a @code{switch} statement +(@pxref{Switch Statement}). + +@item +As an argument to one of the built-in functions that accept regexp constants: +@code{gensub()}, +@code{gsub()}, +@code{match()}, +@code{patsplit()}, +@code{split()}, +and +@code{sub()} +(@pxref{String Functions}). + +@item +As a parameter in a call to a user-defined function. +(@pxref{User-defined}). + +@item +On the righthand side of an assignment to a variable: @samp{some_var = @@/foo/}. +In this case, the type of @code{some_var} is regexp. Additionally, @code{some_var} +can be used with @samp{~} and @code{!~}, passed to one of the built-in functions +listed above, or passed as a parameter to a user-defined function. +@end itemize + +You may use the @code{typeof()} built-in function +(@pxref{Type Functions}) +to determine if a variable or function parameter is +a regexp variable. + +The true power of this feature comes from the ability to create variables that +have regexp type. Such variables can be passed on to user-defined functions, +without the confusing aspects of computed regular expressions created from +strings or string constants. They may also be passed through indirect function +calls (@pxref{Indirect Calls}) +onto the built-in functions that accept regexp constants. + @node Regexp Summary @section Summary @@ -6289,6 +6370,11 @@ treated as regular expressions). case sensitivity of regexp matching. In other @command{awk} versions, use @code{tolower()} or @code{toupper()}. +@item +Strongly typed regexp constants (@code{@@/.../}) enable +certain advanced use cases to be described later on in the +@value{DOCUMENT}. + @end itemize @@ -19384,16 +19470,41 @@ results of the @code{compl()}, @code{lshift()}, and @code{rshift()} functions. @node Type Functions @subsection Getting Type Information -@command{gawk} provides a single function that lets you distinguish -an array from a scalar variable. This is necessary for writing code +@command{gawk} provides two functions that lets you distinguish +the type of a variable. +This is necessary for writing code that traverses every element of an array of arrays -(@pxref{Arrays of Arrays}). +(@pxref{Arrays of Arrays}), and in other contexts. @table @code @cindexgawkfunc{isarray} @cindex scalar or array @item isarray(@var{x}) Return a true value if @var{x} is an array. Otherwise, return false. + +@cindexgawkfunc{typeof} +@cindex variable type +@cindex type, of variable +@item typeof(@var{x}) +Return one of the following strings, depending upon the type of @var{x}: + +@c nested table +@table @code +@item "array" +@var{x} is an array. + +@item "regexp" +@var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). + +@item "scalar_n" +@var{x} is a number. + +@item "scalar_s" +@var{x} is a string. + +@item "untyped" +@var{x} has not yet been given a type. +@end table @end table @code{isarray()} is meant for use in two circumstances. The first is when @@ -19411,6 +19522,14 @@ that has not been previously used to @code{isarray()}, @command{gawk} ends up turning it into a scalar. @end quotation +The @code{typeof()} function is general; it allows you to determine +if a variable or function parameter is a scalar, an array, or a strongly +typed regexp. + +@code{isarray()} is deprecated; you should use @code{typeof()} instead. +You should replace any existing uses of @samp{isarray(var)} in your +code with @samp{typeof(var) == "array"}. + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk}, string-translation functions diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 663353d4..89c4e7bf 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -557,6 +557,7 @@ particular records in a file and perform operations upon them. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -4910,6 +4911,7 @@ regular expressions work, we present more complicated instances. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @end menu @@ -6030,6 +6032,85 @@ The value of @code{IGNORECASE} has no effect if @command{gawk} is in compatibility mode (@pxref{Options}). Case is always significant in compatibility mode. +@node Strong Regexp Constants +@section Strongly Typed Regexp Constants + +This @value{SECTION} describes a @command{gawk}-specific feature. + +Regexp constants (@code{/@dots{}/}) hold a strange position in the +@command{awk} language. In most contexts, they act like an expression: +@samp{$0 ~ /@dots{}/}. In other contexts, they denote only a regexp to +be matched. In no case are they really a ``first class citizen'' of the +language. That is, you cannot define a scalar variable whose type is +``regexp'' in the same sense that you can define a variable to be a +number or a string: + +@example +num = 42 @ii{Numeric variable} +str = "hi" @ii{String variable} +re = /foo/ @ii{Wrong!} re @ii{is the result of} $0 ~ /foo/ +@end example + +For a number of more advanced use cases (described later on in this +@value{DOCUMENT}), it would be nice to have regexp constants that +are @dfn{strongly typed}; in other words, that denote a regexp useful +for matching, and not an expression. + +@command{gawk} provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an @samp{@@} sign: + +@example +re = @@/foo/ @ii{Regexp variable} +@end example + +Strongly typed regexp constants @emph{cannot} be used eveywhere that a +regular regexp constant can, because this would make the language even more +confusing. Instead, you may use them only in certain contexts: + +@itemize @bullet +@item +On the righthand side of the @samp{~} and @samp{!~} operators: @samp{some_var ~ @@/foo/} +(@pxref{Regexp Usage}). + +@item +In the @code{case} part of a @code{switch} statement +(@pxref{Switch Statement}). + +@item +As an argument to one of the built-in functions that accept regexp constants: +@code{gensub()}, +@code{gsub()}, +@code{match()}, +@code{patsplit()}, +@code{split()}, +and +@code{sub()} +(@pxref{String Functions}). + +@item +As a parameter in a call to a user-defined function. +(@pxref{User-defined}). + +@item +On the righthand side of an assignment to a variable: @samp{some_var = @@/foo/}. +In this case, the type of @code{some_var} is regexp. Additionally, @code{some_var} +can be used with @samp{~} and @code{!~}, passed to one of the built-in functions +listed above, or passed as a parameter to a user-defined function. +@end itemize + +You may use the @code{typeof()} built-in function +(@pxref{Type Functions}) +to determine if a variable or function parameter is +a regexp variable. + +The true power of this feature comes from the ability to create variables that +have regexp type. Such variables can be passed on to user-defined functions, +without the confusing aspects of computed regular expressions created from +strings or string constants. They may also be passed through indirect function +calls (@pxref{Indirect Calls}) +onto the built-in functions that accept regexp constants. + @node Regexp Summary @section Summary @@ -6073,6 +6154,11 @@ treated as regular expressions). case sensitivity of regexp matching. In other @command{awk} versions, use @code{tolower()} or @code{toupper()}. +@item +Strongly typed regexp constants (@code{@@/.../}) enable +certain advanced use cases to be described later on in the +@value{DOCUMENT}. + @end itemize @@ -18505,16 +18591,41 @@ results of the @code{compl()}, @code{lshift()}, and @code{rshift()} functions. @node Type Functions @subsection Getting Type Information -@command{gawk} provides a single function that lets you distinguish -an array from a scalar variable. This is necessary for writing code +@command{gawk} provides two functions that lets you distinguish +the type of a variable. +This is necessary for writing code that traverses every element of an array of arrays -(@pxref{Arrays of Arrays}). +(@pxref{Arrays of Arrays}), and in other contexts. @table @code @cindexgawkfunc{isarray} @cindex scalar or array @item isarray(@var{x}) Return a true value if @var{x} is an array. Otherwise, return false. + +@cindexgawkfunc{typeof} +@cindex variable type +@cindex type, of variable +@item typeof(@var{x}) +Return one of the following strings, depending upon the type of @var{x}: + +@c nested table +@table @code +@item "array" +@var{x} is an array. + +@item "regexp" +@var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). + +@item "scalar_n" +@var{x} is a number. + +@item "scalar_s" +@var{x} is a string. + +@item "untyped" +@var{x} has not yet been given a type. +@end table @end table @code{isarray()} is meant for use in two circumstances. The first is when @@ -18532,6 +18643,14 @@ that has not been previously used to @code{isarray()}, @command{gawk} ends up turning it into a scalar. @end quotation +The @code{typeof()} function is general; it allows you to determine +if a variable or function parameter is a scalar, an array, or a strongly +typed regexp. + +@code{isarray()} is deprecated; you should use @code{typeof()} instead. +You should replace any existing uses of @samp{isarray(var)} in your +code with @samp{typeof(var) == "array"}. + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk}, string-translation functions @@ -234,6 +234,7 @@ static const char *const nodetypes[] = { "Node_val", "Node_regex", "Node_dynregex", + "Node_hardregex", "Node_var", "Node_var_array", "Node_var_new", @@ -1362,6 +1363,11 @@ setup_frame(INSTRUCTION *pc) r->var_value = m; break; + case Node_hardregex: + r->type = Node_var; + r->var_value = m; + break; + default: cant_happen(); } diff --git a/hardregex-semantics.awk b/hardregex-semantics.awk new file mode 100644 index 00000000..fc8ba805 --- /dev/null +++ b/hardregex-semantics.awk @@ -0,0 +1,296 @@ +# This file describes the semantics for hard regex constants +# As much as possible it's executable code so that it can be used +# (or split into) test cases for development and regression testing. + +function simple_tests( fbre, numresult, strresult) +{ + # usable as case value + switch ("foobaaar") { + case @/fo+ba+r/: + print "switch-case: ok" + break + default: + print "switch-case: fail" + break + } + + # usable with ~ and !~ + if ("foobaaar" ~ @/fo+ba+r/) + print "match ~: ok" + else + print "match ~: fail" + + if ("quasimoto" !~ @/fo+ba+r/) + print "match !~: ok" + else + print "match !~: fail" + + # assign to variable, use in match + fbre = @/fo+ba+r/ + if ("foobaaar" ~ fbre) + print "variable match ~: ok" + else + print "variable match ~: fail" + + if ("quasimoto" !~ fbre) + print "variable match !~: ok" + else + print "variable match !~: fail" + + # Use as numeric value, should be zero + numresult = fbre + 42 + if (numresult == 42) + print "variable as numeric value: ok" + else + print "variable as numeric value: fail" + + # Use as string value, should be string value of regexp text + strresult = "<" fbre ">" + if (strresult == "<fo+ba+r>") + print "variable as string value: ok" + else + print "variable as string value: fail", strresult + + # typeof should work + if (typeof(@/fo+ba+r/) == "regexp") + print "typeof constant: ok" + else + print "typeof constant: fail" + + if (typeof(fbre) == "regexp") + print "typeof variable: ok" + else + print "typeof variable: fail" + + # conversion to number, works. should it be fatal? + fbre++ + if (fbre == 1) + print "conversion to number: ok" + else + print "conversion to number: fail" + + if (typeof(fbre) == "scalar_n") + print "typeof variable after conversion: ok" + else + print "typeof variable after conversion: fail" +} + +function match_tests( fbre, fun) +{ + if (match("foobaaar", @/fo+ba+r/)) + print "match(constant): ok" + else + print "match(constant): fail" + + fbre = @/fo+ba+r/ + if (match("foobaaar", fbre)) + print "match(variable): ok" + else + print "match(variable): fail" + + fun = "match" + if (@fun("foobaaar", @/fo+ba+r/)) + print "match(constant) indirect: ok" + else + print "match(constant) indirect: fail" + + if (@fun("foobaaar", fbre)) + print "match(variable) indirect: ok" + else + print "match(variable) indirect: fail" +} + +function sub_tests( fbre, count, target, fun) +{ + target = "abc foobaar def foobar ghi" + count = sub(@/fo+ba+r/, "XX", target) + if (count == 1 && target == "abc XX def foobar ghi") + print "sub(constant): ok" + else + print "sub(constant): fail" + + fbre = @/fo+ba+r/ + target = "abc foobaar def foobar ghi" + count = sub(fbre, "XX", target) + if (count == 1 && target == "abc XX def foobar ghi") + print "sub(variable): ok" + else + print "sub(variable): fail" + + fun = "sub" + $0 = "abc foobaar def foobar ghi" + count = @fun(@/fo+ba+r/, "XX") + if (count == 1 && $0 == "abc XX def foobar ghi") + print "sub(constant) indirect: ok" + else + print "sub(constant) indirect: fail" + + $0 = "abc foobaar def foobar ghi" + count = @fun(fbre, "XX") + if (count == 1 && $0 == "abc XX def foobar ghi") + print "sub(variable) indirect: ok" + else + print "sub(variable) indirect: fail" +} + +function gsub_tests( fbre, count, target, fun) +{ + target = "abc foobaar def foobar ghi" + count = gsub(@/fo+ba+r/, "XX", target) + if (count == 2 && target == "abc XX def XX ghi") + print "gsub(constant): ok" + else + print "gsub(constant): fail" + + fbre = @/fo+ba+r/ + target = "abc foobaar def foobar ghi" + count = gsub(fbre, "XX", target) + if (count == 2 && target == "abc XX def XX ghi") + print "gsub(variable): ok" + else + print "gsub(variable): fail" + + fun = "gsub" + $0 = "abc foobaar def foobar ghi" + count = @fun(@/fo+ba+r/, "XX") + if (count == 2 && $0 == "abc XX def XX ghi") + print "gsub(constant) indirect: ok" + else + print "gsub(constant) indirect: fail" + + $0 = "abc foobaar def foobar ghi" + count = @fun(fbre, "XX") + if (count == 2 && $0 == "abc XX def XX ghi") + print "gsub(variable) indirect: ok" + else + print "gsub(variable) indirect: fail" +} + +function gensub_tests( fbre, result, target, fun) +{ + target = "abc foobaar def foobar ghi" + result = gensub(@/fo+ba+r/, "XX", "g", target) + if (result == "abc XX def XX ghi") + print "gensub(constant): ok" + else + print "gensub(constant): fail" + + fbre = @/fo+ba+r/ + target = "abc foobaar def foobar ghi" + result = gensub(fbre, "XX", "g", target) + if (result == "abc XX def XX ghi") + print "gensub(variable): ok" + else + print "gensub(variable): fail" + + fun = "gensub" + $0 = "abc foobaar def foobar ghi" + result = @fun(@/fo+ba+r/, "XX", "g") + if (result == "abc XX def XX ghi") + print "gensub(constant) indirect: ok" + else + print "gensub(constant) indirect: fail" + + $0 = "abc foobaar def foobar ghi" + result = @fun(fbre, "XX", "g") + if (result == "abc XX def XX ghi") + print "gensub(variable) indirect: ok" + else + print "gensub(variable) indirect: fail" + + result = @fun(@/fo+ba+r/, "XX", "g", target) + if (result == "abc XX def XX ghi") + print "gensub(constant) indirect 2: ok" + else + print "gensub(constant) indirect 2: fail" + + result = @fun(fbre, "XX", "g", target) + if (result == "abc XX def XX ghi") + print "gensub(variable) indirect 2: ok" + else + print "gensub(variable) indirect 2: fail" +} + +function split_tests( fbre, data, seps, fun, b1) +{ + delete data + delete seps + b1 = split("a:b:c:d", data, @/:/, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "split(constant): ok" + else + print "split(constant): fail" + + delete data + delete seps + fbre = @/:/ + b1 = split("a:b:c:d", data, fbre, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "split(variable): ok" + else + print "split(variable): fail" + + fun = "split" + delete data + delete seps + b1 = @fun("a:b:c:d", data, @/:/, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "split(constant) indirect: ok" + else + print "split(constant) indirect: fail" + + delete data + delete seps + b1 = @fun("a:b:c:d", data, fbre, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "split(variable) indirect: ok" + else + print "split(variable) indirect: fail" +} + +function patsplit_tests( fbre, data, seps, fun, b1) +{ + delete data + delete seps + b1 = patsplit("a:b:c:d", data, @/[a-z]+/, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "patsplit(constant): ok" + else + print "patsplit(constant): fail" + + delete data + delete seps + fbre = @/[a-z]+/ + b1 = patsplit("a:b:c:d", data, fbre, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "patsplit(variable): ok" + else + print "patsplit(variable): fail" + + fun = "patsplit" + delete data + delete seps + b1 = @fun("a:b:c:d", data, @/[a-z]+/, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "patsplit(constant) indirect: ok" + else + print "patsplit(constant) indirect: fail" + + delete data + delete seps + b1 = @fun("a:b:c:d", data, fbre, seps) + if (b1 == 4 && data[1] == "a" && seps[1] == ":") + print "patsplit(variable) indirect: ok" + else + print "patsplit(variable) indirect: fail" +} + +BEGIN { + simple_tests() + match_tests() + sub_tests() + gsub_tests() + gensub_tests() + split_tests() + patsplit_tests() +} diff --git a/hardregex.txt b/hardregex.txt new file mode 100644 index 00000000..557548c8 --- /dev/null +++ b/hardregex.txt @@ -0,0 +1,24 @@ +New variable type: "regexp", --> Node_hardregexp. (Need a better name). + +Syntax: @/.../ + +Use: + a = @/.../ # a now has type regexp + a = foo(1, "bar", @/.../) # pass a regex to user defined function + +New function: + t = typeof(exp) # "array", "regexp", "scalar" + # Open: "scalar" vs. "scalar_s" / "scalar_n" + +Obsolete function: + isarray(exp) + +Conversions: + r = @/.../ + s = r "" # what happens? becomes regex string? + s = r + 0 # what happens? treat as numeric 0? + +Why? + Allows passing regexes through user defined functions + Allows passing regexes through indirect funtion calls + In general, this is a gap in the language @@ -32,6 +32,8 @@ static void parenthesize(int type, NODE *left, NODE *right); static char *pp_list(int nargs, const char *paren, const char *delim); static char *pp_group3(const char *s1, const char *s2, const char *s3); static char *pp_concat(int nargs); +static char *pp_string_or_hard_regex(const char *in_str, size_t len, int delim, bool hard_regex); +static char *pp_hard_regex(const char *in_str, size_t len, int delim); static bool is_binary(int type); static bool is_scalar(int type); static int prec_level(int type); @@ -624,14 +626,17 @@ cleanup: break; case Op_push_re: - if (pc->memory->type != Node_regex) + if (pc->memory->type != Node_regex && pc->memory->type != Node_hardregex) break; /* else fall through */ case Op_match_rec: { NODE *re = pc->memory->re_exp; - str = pp_string(re->stptr, re->stlen, '/'); + if (pc->memory->type == Node_regex) + str = pp_string(re->stptr, re->stlen, '/'); + else + str = pp_hard_regex(re->stptr, re->stlen, '/'); pp_push(pc->opcode, str, CAN_FREE); } break; @@ -653,6 +658,11 @@ cleanup: txt = t2->pp_str; str = pp_group3(txt, op2str(pc->opcode), restr); pp_free(t2); + } else if (m->type == Node_hardregex) { + NODE *re = m->re_exp; + restr = pp_hard_regex(re->stptr, re->stlen, '/'); + str = pp_group3(txt, op2str(pc->opcode), restr); + efree(restr); } else { NODE *re = m->re_exp; restr = pp_string(re->stptr, re->stlen, '/'); @@ -1323,11 +1333,27 @@ parenthesize(int type, NODE *left, NODE *right) pp_parenthesize(right); } -/* pp_string --- pretty format a string or regex constant */ +/* pp_string --- pretty format a string or regular regex constant */ char * pp_string(const char *in_str, size_t len, int delim) { + return pp_string_or_hard_regex(in_str, len, delim, false); +} + +/* pp_hard_regex --- pretty format a hard regex constant */ + +static char * +pp_hard_regex(const char *in_str, size_t len, int delim) +{ + return pp_string_or_hard_regex(in_str, len, delim, true); +} + +/* pp_string_or_hard_regex --- pretty format a string, regex, or hard regex constant */ + +char * +pp_string_or_hard_regex(const char *in_str, size_t len, int delim, bool hard_regex) +{ static char str_escapes[] = "\a\b\f\n\r\t\v\\"; static char str_printables[] = "abfnrtv\\"; static char re_escapes[] = "\a\b\f\n\r\t\v"; @@ -1359,11 +1385,15 @@ pp_string(const char *in_str, size_t len, int delim) osiz *= 2; \ } ofre -= (l) - osiz = len + 3 + 1; /* initial size; 3 for delim + terminating null */ + /* initial size; 3 for delim + terminating null, 1 for @ */ + osiz = len + 3 + 1 + (hard_regex == true); emalloc(obuf, char *, osiz, "pp_string"); obufout = obuf; ofre = osiz - 1; + if (hard_regex) + *obufout++ = '@'; + *obufout++ = delim; for (; len > 0; len--, str++) { chksize(2); /* make space for 2 chars */ @@ -351,10 +351,14 @@ re_update(NODE *t) /* regex was compiled with settings matching IGNORECASE */ if ((t->re_flags & CONSTANT) != 0) { /* it's a constant, so just return it as is */ - assert(t->type == Node_regex); + assert(t->type == Node_regex || t->type == Node_hardregex); return t->re_reg; } t1 = t->re_exp; + if (t1->type == Node_hardregex) { + assert((t1->re_flags & CONSTANT) != 0); + return t1->re_reg; + } if (t->re_text != NULL) { /* if contents haven't changed, just return it */ if (cmp_nodes(t->re_text, t1) == 0) @@ -429,6 +433,15 @@ avoid_dfa(NODE *re, char *str, size_t len) { char *end; + /* + * f = @/.../ + * if ("foo" ~ f) ... + * + * This creates a Node_dynregex with NULL re_reg. + */ + if (re->re_reg == NULL) + return false; + if (! re->re_reg->has_anchor) return false; diff --git a/test/ChangeLog b/test/ChangeLog index 4d2d0098..e1430d70 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -124,6 +124,7 @@ 2015-02-27 Arnold D. Robbins <arnold@skeeve.com> * nonfatal1.ok: Update after code changes. + * id.ok: Updated after code change. 2015-02-26 Arnold D. Robbins <arnold@skeeve.com> @@ -45,6 +45,7 @@ BINMODE -> scalar sin -> builtin asorti -> builtin FIELDWIDTHS -> scalar +typeof -> builtin function1 -> user FILENAME -> scalar close -> builtin @@ -0,0 +1,9 @@ +BEGIN { + a = 5 ; print typeof(a) + print typeof(b) + print typeof(@/foo/) + c = "foo" ; print typeof(c) + d[1] = 1 ; print typeof(d), typeof(d[1]) + e = @/foo/ ; print typeof(e) + print typeof(@/bar/) +} @@ -0,0 +1 @@ +BEGIN { f = "foo" ; sub(@/f/, "q", f); print f } @@ -0,0 +1 @@ +BEGIN { f = "foo" ; p = @/o/ ; gsub(p, "q", f); print f } @@ -0,0 +1,8 @@ +BEGIN { + f = "foo" + p = @/o/ +// gsub(p, "q", f) + fun = "gsub" + @fun(p, "q", f) + print f +} @@ -0,0 +1,19 @@ +function testit(count, re, repl, fun, bi, n1, n2) +{ + $0 = "foo" + n1 = gsub(re, repl) + bi = $0 + + $0 = "foo" + fun = "gsub" + n2 = @fun(re, repl) + printf("%d: n1 = %d, bi -> %s, n2 = %d, indirect -> %s\n", + count, n1, bi, n2, $0) +} + +BEGIN { + testit(1, @/o/, "q") + p = @/o/ +stopme() + testit(2, p, "q") +} |