aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xChangeLog201
-rw-r--r--NEWS4
-rw-r--r--awk.h14
-rw-r--r--awkgram.c2301
-rw-r--r--awkgram.y812
-rw-r--r--debug.c56
-rw-r--r--doc/ChangeLog10
-rw-r--r--doc/gawk.info478
-rw-r--r--doc/gawk.texi13
-rw-r--r--doc/gawktexi.in13
-rw-r--r--profile.c311
-rw-r--r--test/ChangeLog28
-rw-r--r--test/Makefile.am6
-rw-r--r--test/Makefile.in11
-rw-r--r--test/Maketests5
-rw-r--r--test/profile0.ok2
-rw-r--r--test/profile10.ok12
-rw-r--r--test/profile11.awk321
-rw-r--r--test/profile11.ok371
-rw-r--r--test/profile5.ok222
20 files changed, 3437 insertions, 1754 deletions
diff --git a/ChangeLog b/ChangeLog
index e0c8abdf..a96b8e6f 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,31 @@
+2018-11-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (first_rule, func_first): Remove unused variables.
+ (Grammar): Simplify rule for range pattern.
+
+2018-11-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (debug_print_comment): New macro and function.
+ (load_library): Rework to not try to open the file if pretty printing.
+ (append_rule): Adjust handling of interblock_comment.
+
+2018-11-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): In rule for function, set interblock_comment.
+ (mk_function): Hook interblock_comment onto fi->comment, merge it
+ with the existing one first, if any. Append trailing_comment.
+
2018-11-26 Arnold D. Robbins <arnold@skeeve.com>
* main.c (platform_name): Add os390. Treat Cygwin and Mac OS X
as POSIX, per discussion with the dev team.
+ Unrelated:
+
+ * profile.c (print_comment): Indent for chained comment.
+ * awkgram.y (load_library): Return early if just pretty printing.
+ (yylex): Fix handling of ?: and allow_newline etc.
+
2018-11-25 Arnold D. Robbins <arnold@skeeve.com>
* main.c (platform_name): New function returning platform name.
@@ -16,6 +39,12 @@
2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+ * awkgram.y (interblock_comment, pending_comment): New variables.
+ (Grammar, mk_program, add_rule): Adjust to use them. Changes
+ handle comments at the outermost level, between blocks and functions.
+
+2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+
* main.c (arg_assign): Allow assigning strongly typed regexp
constants to variables on the command line and with -v.
Thanks to Peng Yu <pengyu.ut@gmail.com> for the report.
@@ -34,6 +63,47 @@
2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
* main.c (usage): Improve output for -Z in the help.
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (outer_comment): New variable.
+ (Grammar): More changes. We now get the simple case of leading
+ and trailing comments, but not all the cases.
+
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (trailing_comment): New variable.
+ (Grammar): For `action', append both trailing comments. This may
+ change. For `statements', append the value of `trailing_comment'
+ if set. At `statement := l_brace statements rbrace' save
+ trailing_comment from r_brace.
+ (make_braced_statements): Don't append the comment from r_brace
+ to the statement list.
+
+2018-10-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (NODE): New field: sub.nodep.x.cmnt, holds comment for
+ expressions being pretty-printed.
+ * awkgram.y (Grammar): For expression lists, save any comment
+ that came after a comma in the list.
+ * profile.c (pp_push): Accept a fourth argument which is any
+ comment associated with the expression. Either it's there or
+ it's NULL. Save it in the pp_comment field of the node being pushed.
+ (tabs, tabs_len, check_indent_level): Made into static globals.
+ (pprint): Adjust all calls to pp_push(). Fix parenthesization
+ for casts in string lengthes when indenting.
+ (pp_list): If a popped item has a comment, include it and the
+ following indentation in the formatted result.
+
+2018-10-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (include_source): Add second parameter to return
+ SRCFILE pointer.
+ (Grammar): For @include, save the comment for later dumping
+ along with the list of include files.
+ (make_include_comment): Removed. No longer used.
+ * profile.c: Update copyright year.
+ (print_include_list): New function.
+ (dump_prog): Call it.
2018-10-24 Arnold D. Robbins <arnold@skeeve.com>
@@ -43,11 +113,121 @@
* config.sub: Updated from GNULIB.
+2018-10-20 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (SRCFILE): Add comment field for comments on @load statements.
+ * awkgram.y (include_source): Type change to boolean.
+ (load_library): Type change to boolean, additiona parameter to
+ bring the SRCFILE struct up to where we can add the comment into it.
+ (make_include_comment): New function. Not used yet.
+ (Grammar): Add comment for @load statements. Start on preserving
+ @include statements and their comments for eventual inclusion
+ into the pretty-printed code.
+ * profile.c (print_lib_list): Made a little smarter about printing
+ the header and indentation. Print the comment if there is one.
+
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (commenttype): Add FOR_COMMENT.
+ * awkgram.y (Grammar): Handle all the opt_nls cases in
+ regular for statements.
+ * debug.c (print_instruction): Print the comments in Op_K_for.
+ * profile.c (pprint): Handle printing comments.
+
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * NEWS: Updated.
+ * awkgram.y (Grammar): Distinguish `print' and `print $0' in
+ what gets profiled / pretty-printed.
+ * profile.c (pprint): For case and default, add final newline
+ if there is no comment to print.
+
+2018-10-16 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Improve comment handling for many plain
+ statements. Improve handling for case and default.
+ Handle comments in `for (iggy in foo)' loops.
+ (yylex): After a colon, only allow newline if was part of ?:.
+ (merge_comments): Improve coding so we don't get two newlines
+ at the end of a merged comment.
+ * debug.c (print_instruction): Handle comments for case and default.
+ Simplify printing of comments.
+ * profile.c (pprint): Handle comments for case and default.
+ Remove compiler warning in Op_and/Op_or handling.
+
+2018-10-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Add comment handling for do...while.
+ Regularize comments about `else ...'.
+ * debug.c (print_instruction): Improve handling of comments for
+ do-while and switch, and in general.
+ * profile.c (pprint): Revise for do...while.
+
+2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (make_braced_statements): New function.
+ (Grammar): Use it in the right places instead of inline code.
+ * debug.c (print_instruction): For Op_comment, fix type string.
+ * profile.c (pprint): Move tabs and tabs_len to top of function.
+ For Op_and and Op_or, handle comments. Use new check_indent_level
+ for Op_and, Op_or and Op_cond_exp.
+
2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
* debug.c (print_instruction): For Op_comment, use print_func
instead of fprintf to print the comment type.
+2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): For statement -> { statements }, fix comment
+ handling. For `if' statement add comment support.
+ * profile.c (pp_print): Print comments associated with `if' and `else'.
+
+2018-10-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (Grammar): Fix handling of empty statement (just a semi-
+ colon).
+ (merge_comments): If no chained comment and no second comment,
+ just return early.
+
+2018-10-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awk.h (enum commenttype): New enum.
+ (NODE): Add it to sub.val.
+ (EOL_COMMENT, FULL_COMMENT): Replaced with above enum values.
+ * awkgram.y (Grammar): Finish up handling comments in function headers
+ and bodies. Get trailing comments at end of program
+ (get_comment): When doing comments, if we got EOF, push it back so that
+ multiple comments get merged together.
+ (merge_comments): Allow second parameter to be NULL.
+ * profile.c (pp_print): Change to use above enum everywhere. For
+ Op_K_print_rec produce plain `print' instead of `print $0'. Handle
+ comments in ?:. Handle printing function comments.
+ (print_comment): Simplify `after_newline' assignment. Add assertion
+ that chaining is only two deep.
+
+2018-10-06 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (action): Improve handling of comments attached
+ to braces. Helps with function bodies.
+
+2018-10-04 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y (merge_comments): Change return type to void. Adjust calls.
+ (Grammar): For action, pull comments out of braces and stick
+ into the list. For function_prologue, get comments from parameters
+ and ending newline, merge, and save. Wherever nls and opt_nls
+ are used, be sure to pass their values up via $$. For various
+ cases that can be empty, explicitly set $$ = NULL.
+ * profile.c (pprint): Get switch working. Get ?: working.
+ (print_comment): Print any chained comment.
+ (pp_func): Start revising.
+
+2018-10-03 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y: Range expressions, enable comment stuff.
+ Switch statement: start on comment handling.
+
2018-10-01 Nelson H.F. Beebe <beebe@math.utah.edu>
* custom.h (__builtin_expect): Define for non-GNU compilers.
@@ -77,6 +257,23 @@
2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+ * awk.h (INSTRUCTION): Add comment field to carry
+ comment around during parsing.
+ * awkgram.y (merge_comments): New function.
+ (split_comment, check_comment, comment, prior_comment,
+ comment_to_save, program_comment, function_comment,
+ block_comment): Removed.
+ (grammar): Remove old code and start passing the comment
+ up via yylval and the newlines in the grammar.
+
+2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+
+ * awkgram.y: Undo change of 2016-11-28 to make switch
+ head a separate production, in preparation for revamping
+ comment handling.
+
+2018-09-21 Arnold D. Robbins <arnold@skeeve.com>
+
* re.c (make_regexp): Handle backslash at end of
input string. Thanks to Anatoly Trosinenko
<anatoly.trosinenko@gmail.com> for the report.
@@ -1756,6 +1953,10 @@
* dfa.c: Sync with GNULIB. Twice in one day.
+ Unrelated: Start improving profiling comments for switch/case.
+
+ * awkgram.y (switch_head): New production.
+
2016-11-21 Arnold D. Robbins <arnold@skeeve.com>
* dfa.c: Sync with GNULIB.
diff --git a/NEWS b/NEWS
index b543b0fe..25a5a6a4 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,10 @@ Changes from 4.2.x to 5.0.0
5. Writing to elements of SYMTAB that are not variable names now
causes a fatal error.
+6. Comment handling in the pretty-printer has been reworked almost completely
+ from scratch. As a result, comments in many corner cases that were
+ previously lost are now included in the formatted output.
+
Changes from 4.2.1 to 4.2.2
---------------------------
diff --git a/awk.h b/awk.h
index b53674ee..6f0f5163 100644
--- a/awk.h
+++ b/awk.h
@@ -296,6 +296,12 @@ typedef union bucket_item {
} hi;
} BUCKET;
+enum commenttype {
+ EOL_COMMENT = 1,
+ BLOCK_COMMENT,
+ FOR_COMMENT // special case
+};
+
/* string hash table */
#define ahnext hs.next
#define ahname hs.name /* a string index node */
@@ -340,6 +346,7 @@ typedef struct exp_node {
struct exp_node *extra;
void (*aptr)(void);
long xl;
+ void *cmnt; // used by pretty printer
} x;
char *name;
size_t reserved;
@@ -368,6 +375,7 @@ typedef struct exp_node {
wchar_t *wsp;
size_t wslen;
struct exp_node *typre;
+ enum commenttype comtype;
} val;
} sub;
NODETYPE type;
@@ -565,9 +573,7 @@ typedef struct exp_node {
#define alevel sub.nodep.x.xl
/* Op_comment */
-#define comment_type sub.val.idx
-#define EOL_COMMENT 1
-#define FULL_COMMENT 2
+#define comment_type sub.val.comtype
/* --------------------------------lint warning types----------------------------*/
typedef enum lintvals {
@@ -764,6 +770,7 @@ typedef struct exp_instruction {
awk_ext_func_t *exf;
} x;
+ struct exp_instruction *comment;
short source_line;
short pool_size; // memory management in symbol.c
OPCODE opcode;
@@ -1009,6 +1016,7 @@ typedef struct srcfile {
char *lexeme;
char *lexptr_begin;
int lasttok;
+ INSTRUCTION *comment; /* comment on @load line */
} SRCFILE;
// structure for INSTRUCTION pool, needed mainly for debugger
diff --git a/awkgram.c b/awkgram.c
index 3d63f162..d467eb17 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -96,11 +96,28 @@ static int isnoeffect(OPCODE type);
static INSTRUCTION *make_assignable(INSTRUCTION *ip);
static void dumpintlstr(const char *str, size_t len);
static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2);
-static int include_source(INSTRUCTION *file);
-static int load_library(INSTRUCTION *file);
+static bool include_source(INSTRUCTION *file, void **srcfile_p);
+static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
+static INSTRUCTION *trailing_comment;
+static INSTRUCTION *outer_comment;
+static INSTRUCTION *interblock_comment;
+static INSTRUCTION *pending_comment;
+
+#ifdef DEBUG_COMMENTS
+static void
+debug_print_comment_s(const char *name, INSTRUCTION *comment, int line)
+{
+ if (comment != NULL)
+ fprintf(stderr, "%d: %s: <%.*s>\n", line, name,
+ (int) (comment->memory->stlen - 1),
+ comment->memory->stptr);
+}
+#define debug_print_comment(comment) \
+ debug_print_comment_s(# comment, comment, __LINE__)
+#endif
#define instruction(t) bcalloc(t, 1, 0)
@@ -127,8 +144,8 @@ static void check_funcs(void);
static ssize_t read_one_line(int fd, void *buffer, size_t count);
static int one_line_close(int fd);
-static void split_comment(void);
-static void check_comment(void);
+static void merge_comments(INSTRUCTION *c1, INSTRUCTION *c2);
+static INSTRUCTION *make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace);
static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
@@ -195,27 +212,16 @@ static INSTRUCTION *ip_endfile;
static INSTRUCTION *ip_beginfile;
INSTRUCTION *main_beginfile;
-static INSTRUCTION *comment = NULL;
-static INSTRUCTION *prior_comment = NULL;
-static INSTRUCTION *comment_to_save = NULL;
-static INSTRUCTION *program_comment = NULL;
-static INSTRUCTION *function_comment = NULL;
-static INSTRUCTION *block_comment = NULL;
-
-static bool func_first = true;
-static bool first_rule = true;
-
static inline INSTRUCTION *list_create(INSTRUCTION *x);
static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2);
-static inline INSTRUCTION *add_pending_comment(INSTRUCTION *stmt);
extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 219 "awkgram.c" /* yacc.c:338 */
+#line 225 "awkgram.c" /* yacc.c:338 */
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
@@ -605,7 +611,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 1236
+#define YYLAST 1209
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 76
@@ -614,7 +620,7 @@ union yyalloc
/* YYNRULES -- Number of rules. */
#define YYNRULES 203
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 350
+#define YYNSTATES 349
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
@@ -665,27 +671,27 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 215, 215, 217, 222, 223, 227, 239, 244, 255,
- 262, 268, 277, 285, 287, 292, 300, 302, 308, 316,
- 326, 356, 370, 384, 392, 403, 415, 417, 419, 425,
- 433, 434, 438, 438, 484, 483, 517, 532, 534, 539,
- 549, 596, 601, 602, 606, 608, 610, 617, 707, 749,
- 791, 904, 911, 918, 929, 939, 949, 959, 971, 988,
- 987, 1001, 1013, 1013, 1112, 1112, 1146, 1177, 1186, 1187,
- 1193, 1194, 1201, 1206, 1218, 1232, 1234, 1242, 1249, 1251,
- 1259, 1268, 1270, 1279, 1280, 1288, 1293, 1293, 1306, 1310,
- 1318, 1319, 1322, 1324, 1329, 1330, 1339, 1340, 1345, 1350,
- 1359, 1361, 1363, 1370, 1371, 1377, 1378, 1383, 1385, 1390,
- 1392, 1400, 1405, 1414, 1415, 1420, 1422, 1427, 1429, 1437,
- 1442, 1450, 1451, 1456, 1463, 1467, 1469, 1471, 1484, 1501,
- 1511, 1518, 1520, 1525, 1527, 1529, 1537, 1539, 1544, 1546,
- 1551, 1553, 1555, 1612, 1614, 1616, 1618, 1620, 1622, 1624,
- 1626, 1640, 1645, 1650, 1675, 1681, 1683, 1685, 1687, 1689,
- 1691, 1696, 1700, 1732, 1740, 1746, 1752, 1765, 1766, 1767,
- 1772, 1777, 1781, 1785, 1800, 1821, 1826, 1863, 1892, 1893,
- 1899, 1900, 1905, 1907, 1914, 1931, 1948, 1950, 1957, 1962,
- 1970, 1980, 1992, 2001, 2005, 2009, 2013, 2017, 2021, 2024,
- 2026, 2030, 2034, 2038
+ 0, 223, 223, 224, 229, 239, 243, 255, 263, 277,
+ 288, 298, 311, 321, 323, 328, 338, 340, 346, 350,
+ 355, 385, 397, 409, 415, 424, 442, 444, 446, 452,
+ 460, 461, 465, 465, 499, 498, 532, 547, 549, 554,
+ 555, 575, 580, 581, 585, 596, 601, 608, 716, 767,
+ 817, 943, 964, 985, 995, 1005, 1015, 1026, 1039, 1057,
+ 1056, 1070, 1088, 1088, 1186, 1186, 1219, 1249, 1257, 1258,
+ 1264, 1265, 1272, 1277, 1290, 1305, 1307, 1315, 1322, 1324,
+ 1332, 1341, 1343, 1352, 1353, 1361, 1366, 1366, 1379, 1385,
+ 1397, 1401, 1423, 1424, 1430, 1431, 1440, 1441, 1446, 1451,
+ 1468, 1470, 1472, 1479, 1480, 1486, 1487, 1492, 1494, 1501,
+ 1503, 1511, 1516, 1527, 1528, 1533, 1535, 1542, 1544, 1552,
+ 1557, 1567, 1568, 1573, 1580, 1584, 1586, 1588, 1601, 1618,
+ 1628, 1635, 1637, 1642, 1644, 1646, 1654, 1656, 1661, 1663,
+ 1668, 1670, 1672, 1729, 1731, 1733, 1735, 1737, 1739, 1741,
+ 1743, 1757, 1762, 1767, 1792, 1798, 1800, 1802, 1804, 1806,
+ 1808, 1813, 1817, 1849, 1857, 1863, 1869, 1882, 1883, 1884,
+ 1889, 1894, 1898, 1902, 1917, 1938, 1943, 1980, 2009, 2010,
+ 2016, 2017, 2022, 2024, 2031, 2048, 2065, 2067, 2074, 2079,
+ 2087, 2097, 2109, 2118, 2122, 2127, 2131, 2135, 2139, 2144,
+ 2145, 2149, 2153, 2157
};
#endif
@@ -740,10 +746,10 @@ static const yytype_uint16 yytoknum[] =
};
# endif
-#define YYPACT_NINF -275
+#define YYPACT_NINF -277
#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-275)))
+ (!!((Yystate) == (-277)))
#define YYTABLE_NINF -115
@@ -754,41 +760,41 @@ static const yytype_uint16 yytoknum[] =
STATE-NUM. */
static const yytype_int16 yypact[] =
{
- -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
+ -277, 349, -277, -277, -34, -17, -277, -277, -277, -277,
+ 166, -277, -277, 62, 62, 62, -7, -4, -277, -277,
+ -277, 1112, 1112, -277, 1112, 1139, 842, 26, -277, -24,
+ -6, -277, -277, 87, 857, 1038, 344, 372, -277, -277,
+ -277, -277, 233, 768, 842, -277, 0, -277, -277, -277,
+ -277, -277, 84, 78, -277, 99, -277, -277, -277, 768,
+ 768, 157, 105, 106, 105, 105, 1112, 113, -277, -277,
+ 108, 320, 44, 47, -277, 120, -277, -277, -277, 87,
+ -277, 120, -277, 171, -277, -277, 1065, 178, 1112, 1112,
+ 1112, 120, -277, -277, -277, 1112, 1112, 146, 344, 1112,
+ 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112,
+ 1112, -277, 177, -277, -277, 173, 1112, -277, -277, -277,
+ 128, 109, -277, 1080, 20, 1080, -277, -277, -277, -277,
+ 1112, -277, 128, 128, 320, -277, -277, -277, 1112, -277,
+ 160, 889, -277, -277, 3, 18, -277, 39, 18, 87,
+ -277, 572, -277, -277, -277, 25, -277, 16, 618, 1021,
+ -277, 126, 1080, 62, 82, 82, 105, 105, 105, 105,
+ 82, 82, 105, 105, 105, 105, -277, -277, 1080, -277,
+ 1065, 815, -277, 43, 344, -277, -277, 1080, 178, -277,
+ 1080, -277, -277, -277, -277, -277, 134, -277, 12, 136,
+ 137, 120, 140, 18, 18, -277, -277, 18, 1112, 18,
+ 120, -277, -277, 18, -277, -277, 1080, -277, 150, 120,
+ 1112, -277, -277, -277, -277, -277, -277, 128, 112, -277,
+ 1112, 1112, -277, 223, 1112, 1112, 688, 922, -277, -277,
+ -277, 18, 1080, -277, -277, -277, 619, 572, 120, -277,
+ -277, 1080, 120, -277, 59, 320, 18, -17, 169, 320,
+ 320, 208, -9, -277, 150, -277, 842, 240, -277, 198,
+ -277, -277, -277, -277, -277, 120, -277, -277, 1, -277,
+ -277, -277, 120, 120, 176, 178, 120, 108, -277, -277,
+ 688, -277, -277, -6, 688, 1112, 128, 735, 160, 1112,
+ 231, -277, -277, 320, 120, 285, 120, 1038, 120, 148,
+ 120, 688, 120, 970, 688, -277, 311, 200, -277, 182,
+ -277, -277, 970, 128, -277, -277, -277, 251, 253, -277,
+ -277, 200, -277, 120, -277, 128, 120, -277, -277, 120,
+ -277, 120, 688, -277, 422, 688, -277, 497, -277
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -805,56 +811,56 @@ static const yytype_uint8 yydefact[] =
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, 92, 137, 139, 138, 0, 0, 0, 142, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 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, 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, 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,
+ 203, 130, 20, 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, 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
+ 0, 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[] =
{
- -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
+ -277, -277, -277, -277, -277, -277, 232, -277, -277, -277,
+ -277, -55, -277, -85, -277, -208, 95, -152, -277, -277,
+ -232, -277, -277, -276, -277, -277, -277, -277, -277, -277,
+ -277, -277, 7, 5, -277, -277, -277, 33, -277, -29,
+ 94, -277, -14, -1, -277, -277, -277, -31, 17, -277,
+ 244, -277, 114, 107, -277, -277, -3, -36, -277, -277,
+ -57, -2, -277, -27, -240, -64, -277, -15, -59, -10
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
-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
+ 183, 31, 83, 119, 32, 151, 78, 211, 212, 231,
+ 213, 246, 257, 264, 309, 318, 331, 214, 267, 289,
+ 299, 215, 149, 150, 131, 227, 228, 241, 268, 70,
+ 120, 121, 122, 216, 116, 94, 95, 35, 36, 37,
+ 38, 39, 40, 55, 277, 278, 279, 45, 46, 47,
+ 41, 42, 137, 217, 218, 142, 248, 219, 333, 141
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -862,258 +868,252 @@ static const yytype_int16 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
- 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, -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,
+ 34, 154, 80, 80, 191, 263, 140, 270, 33, 247,
+ 127, 56, 57, 58, 81, 124, 232, 126, 291, 63,
+ 63, 138, 63, 68, 96, 71, 85, 176, 19, 4,
+ 156, 86, 285, 63, 43, 85, 79, 323, 62, 64,
+ 193, 65, 123, 125, 225, 143, 335, 226, 146, 75,
+ 144, 76, 98, 147, 44, -12, 179, 87, 123, 123,
+ 273, 59, 44, 274, 60, 134, 5, 75, 185, 186,
+ 19, 44, 44, 92, 93, 72, 91, 73, -12, 334,
+ 233, 263, 92, 93, 261, 155, 152, 157, 158, 159,
+ 263, -15, 182, 76, 161, 162, 160, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 138,
+ 180, 181, -96, 253, -15, 178, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 63, 25,
+ 81, 229, 344, 81, 128, 347, -115, 187, 300, 84,
+ 190, 74, 302, 101, 102, 103, 129, 184, 104, 315,
+ 113, 114, 79, 132, 133, 79, 130, 135, 136, 321,
+ 4, 56, 324, 252, 91, 91, 222, 224, 91, 48,
+ 49, 104, 19, 316, 317, 74, 153, 139, -114, 123,
+ 123, -97, 5, -115, -115, 163, 118, 177, 81, 81,
+ 346, 275, 81, 348, 81, 282, 283, 139, 81, 138,
+ 19, 188, 230, 249, 234, 235, 236, 242, 237, -106,
+ 79, 79, 50, 51, 79, 244, 79, 269, 254, 251,
+ 79, 280, -92, 298, 250, 76, 81, 258, 296, 255,
+ 242, 330, 304, 259, 260, 284, 52, 287, 281, 310,
+ 192, 81, 280, 194, 295, 125, 111, 112, 79, 286,
+ -106, 288, 308, 271, 91, 332, 210, 272, 337, 336,
+ 338, 329, 82, 79, 256, 71, 301, -106, 307, 67,
+ 221, 341, 339, -106, 0, 292, 0, 113, 114, 0,
+ 290, 0, 306, 0, 0, 0, 115, 293, 294, 0,
+ 312, 297, 0, 0, 303, 85, 305, 63, 238, 239,
+ 86, 0, 240, 0, 243, 63, 0, 0, 245, 311,
+ 0, 313, 0, 314, 319, 320, 0, 322, 325, 326,
+ 118, 0, 0, 0, 98, 0, 87, 88, 89, 0,
+ 85, 0, 0, 0, 0, 86, 265, 0, 340, 90,
+ 0, 342, 92, 93, 343, 0, 345, 0, 0, 2,
+ 3, 276, 4, 5, 0, 0, 6, 7, 0, 0,
+ 76, 87, 88, 89, 20, 0, 0, 8, 9, 0,
+ 327, 328, 0, 23, 90, 0, 0, 92, 93, 0,
+ 0, 0, 0, 0, 0, 10, 11, 12, 13, 139,
+ 0, 0, 0, 14, 15, 16, 17, 18, 0, 0,
+ 0, 19, 20, 99, 100, 101, 102, 103, 21, 22,
+ 104, 23, 0, 24, 0, 0, 25, 26, 0, 27,
+ 0, 0, -18, 195, -18, 4, 5, 0, 0, 6,
+ 7, 105, 106, 107, 108, 109, 0, 0, 110, 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, 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,
+ 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, -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, 85, 0,
+ -105, 21, 22, 86, 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, 87,
+ 88, 0, 0, 14, 15, 16, 17, 0, 0, 0,
+ 0, -105, 20, 0, 0, 92, 93, 0, 21, 22,
+ 0, 23, 0, 24, 0, 0, 25, 266, -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, 117,
+ 0, 4, 5, 0, 13, 6, 7, 118, 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, 0, 13, 0, 0,
+ 76, 0, 14, 15, 16, 17, 223, 0, 4, 5,
+ 0, 20, 6, 7, 118, 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,
- 0, 0, 4, 5, 0, 20, 6, 7, 87, 88,
+ 189, 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,
+ 26, 90, 61, 91, 92, 93, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 4, 262, 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,
+ 97, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 87, 88, 89, 0, 0, 0, 4, 5,
+ 0, 0, 6, 7, 118, 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, 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
+ 0, 23, 0, 24, 0, 0, 25, 66, 0, 61
};
static const yytype_int16 yycheck[] =
{
- 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, -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, 86, 29, 30, 1, 237, 70, 247, 1, 217,
+ 46, 13, 14, 15, 29, 44, 4, 17, 17, 21,
+ 22, 1, 24, 25, 34, 26, 10, 112, 52, 3,
+ 87, 15, 41, 35, 68, 10, 29, 313, 21, 22,
+ 1, 24, 43, 44, 1, 1, 322, 4, 1, 73,
+ 6, 75, 35, 6, 71, 52, 120, 41, 59, 60,
+ 1, 68, 71, 4, 68, 66, 4, 73, 132, 133,
+ 52, 71, 71, 57, 58, 49, 56, 51, 75, 319,
+ 68, 313, 57, 58, 236, 86, 81, 88, 89, 90,
+ 322, 52, 72, 75, 95, 96, 91, 99, 100, 101,
+ 102, 103, 104, 105, 106, 107, 108, 109, 110, 1,
+ 1, 121, 69, 1, 75, 116, 99, 100, 101, 102,
+ 103, 104, 105, 106, 107, 108, 109, 110, 130, 67,
+ 145, 188, 340, 148, 50, 343, 10, 138, 290, 52,
+ 141, 27, 294, 61, 62, 63, 68, 130, 66, 1,
+ 44, 45, 145, 59, 60, 148, 57, 44, 45, 311,
+ 3, 163, 314, 227, 56, 56, 180, 181, 56, 3,
+ 4, 66, 52, 25, 26, 61, 5, 69, 69, 180,
+ 181, 69, 4, 57, 58, 39, 9, 14, 203, 204,
+ 342, 255, 207, 345, 209, 259, 260, 69, 213, 1,
+ 52, 41, 68, 218, 68, 68, 201, 208, 68, 11,
+ 203, 204, 46, 47, 207, 210, 209, 246, 228, 220,
+ 213, 257, 74, 287, 219, 75, 241, 4, 285, 230,
+ 231, 316, 296, 234, 235, 27, 70, 266, 69, 303,
+ 145, 256, 278, 148, 68, 246, 13, 14, 241, 264,
+ 52, 11, 21, 248, 56, 55, 74, 252, 7, 323,
+ 7, 316, 30, 256, 231, 266, 293, 69, 299, 25,
+ 163, 335, 331, 75, -1, 278, -1, 44, 45, -1,
+ 275, -1, 297, -1, -1, -1, 53, 282, 283, -1,
+ 305, 286, -1, -1, 295, 10, 297, 299, 203, 204,
+ 15, -1, 207, -1, 209, 307, -1, -1, 213, 304,
+ -1, 306, -1, 308, 309, 310, -1, 312, 7, 8,
+ 9, -1, -1, -1, 307, -1, 41, 42, 43, -1,
+ 10, -1, -1, -1, -1, 15, 241, -1, 333, 54,
+ -1, 336, 57, 58, 339, -1, 341, -1, -1, 0,
+ 1, 256, 3, 4, -1, -1, 7, 8, -1, -1,
+ 75, 41, 42, 43, 53, -1, -1, 18, 19, -1,
+ 59, 60, -1, 62, 54, -1, -1, 57, 58, -1,
+ -1, -1, -1, -1, -1, 36, 37, 38, 39, 69,
+ -1, -1, -1, 44, 45, 46, 47, 48, -1, -1,
+ -1, 52, 53, 59, 60, 61, 62, 63, 59, 60,
+ 66, 62, -1, 64, -1, -1, 67, 68, -1, 70,
+ -1, -1, 73, 1, 75, 3, 4, -1, -1, 7,
+ 8, 59, 60, 61, 62, 63, -1, -1, 66, -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, 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, 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,
+ 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, -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, 10, -1,
+ 11, 59, 60, 15, 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, 41,
+ 42, -1, -1, 44, 45, 46, 47, -1, -1, -1,
+ -1, 52, 53, -1, -1, 57, 58, -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, 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,
+ 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,
+ 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,
- 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, 62, -1, 64, -1, -1, 67, 68, -1, 70
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1129,32 +1129,32 @@ static const yytype_uint8 yystos[] =
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,
+ 54, 56, 57, 58, 121, 122, 145, 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, 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,
+ 109, 119, 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, 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
+ 55, 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. */
@@ -1188,7 +1188,7 @@ 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,
+ 3, 1, 1, 1, 1, 5, 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,
@@ -1882,25 +1882,45 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 3:
-#line 218 "awkgram.y" /* yacc.c:1645 */
+ case 2:
+#line 223 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 1889 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 3:
+#line 225 "awkgram.y" /* yacc.c:1645 */
{
rule = 0;
yyerrok;
}
-#line 1892 "awkgram.c" /* yacc.c:1645 */
+#line 1898 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 4:
+#line 230 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL) {
+ if ((yyvsp[-1]) == NULL)
+ outer_comment = (yyvsp[0]);
+ else
+ interblock_comment = (yyvsp[0]);
+ }
+ (yyval) = (yyvsp[-1]);
+ }
+#line 1912 "awkgram.c" /* yacc.c:1645 */
break;
case 5:
-#line 224 "awkgram.y" /* yacc.c:1645 */
+#line 240 "awkgram.y" /* yacc.c:1645 */
{
next_sourcefile();
}
-#line 1900 "awkgram.c" /* yacc.c:1645 */
+#line 1920 "awkgram.c" /* yacc.c:1645 */
break;
case 6:
-#line 228 "awkgram.y" /* yacc.c:1645 */
+#line 244 "awkgram.y" /* yacc.c:1645 */
{
rule = 0;
/*
@@ -1909,20 +1929,23 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 1913 "awkgram.c" /* yacc.c:1645 */
+#line 1933 "awkgram.c" /* yacc.c:1645 */
break;
case 7:
-#line 240 "awkgram.y" /* yacc.c:1645 */
+#line 256 "awkgram.y" /* yacc.c:1645 */
{
(void) append_rule((yyvsp[-1]), (yyvsp[0]));
- first_rule = false;
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
}
-#line 1922 "awkgram.c" /* yacc.c:1645 */
+#line 1945 "awkgram.c" /* yacc.c:1645 */
break;
case 8:
-#line 245 "awkgram.y" /* yacc.c:1645 */
+#line 264 "awkgram.y" /* yacc.c:1645 */
{
if (rule != Rule) {
msg(_("%s blocks must have an action part"), ruletab[rule]);
@@ -1930,291 +1953,287 @@ yyreduce:
} else if ((yyvsp[-1]) == NULL) {
msg(_("each rule must have a pattern or an action part"));
errcount++;
- } else /* pattern rule with non-empty pattern */
+ } else { /* pattern rule with non-empty pattern */
+ if ((yyvsp[0]) != NULL)
+ list_append((yyvsp[-1]), (yyvsp[0]));
(void) append_rule((yyvsp[-1]), NULL);
+ }
}
-#line 1937 "awkgram.c" /* yacc.c:1645 */
+#line 1963 "awkgram.c" /* yacc.c:1645 */
break;
case 9:
-#line 256 "awkgram.y" /* yacc.c:1645 */
+#line 278 "awkgram.y" /* yacc.c:1645 */
{
in_function = NULL;
(void) mk_function((yyvsp[-1]), (yyvsp[0]));
want_param_names = DONT_CHECK;
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
yyerrok;
}
-#line 1948 "awkgram.c" /* yacc.c:1645 */
+#line 1978 "awkgram.c" /* yacc.c:1645 */
break;
case 10:
-#line 263 "awkgram.y" /* yacc.c:1645 */
+#line 289 "awkgram.y" /* yacc.c:1645 */
{
want_source = false;
at_seen = false;
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ SRCFILE *s = (SRCFILE *) (yyvsp[-1]);
+ s->comment = (yyvsp[0]);
+ }
yyerrok;
}
-#line 1958 "awkgram.c" /* yacc.c:1645 */
+#line 1992 "awkgram.c" /* yacc.c:1645 */
break;
case 11:
-#line 269 "awkgram.y" /* yacc.c:1645 */
+#line 299 "awkgram.y" /* yacc.c:1645 */
{
want_source = false;
at_seen = false;
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ SRCFILE *s = (SRCFILE *) (yyvsp[-1]);
+ s->comment = (yyvsp[0]);
+ }
yyerrok;
}
-#line 1968 "awkgram.c" /* yacc.c:1645 */
+#line 2006 "awkgram.c" /* yacc.c:1645 */
break;
case 12:
-#line 278 "awkgram.y" /* yacc.c:1645 */
+#line 312 "awkgram.y" /* yacc.c:1645 */
{
- if (include_source((yyvsp[0])) < 0)
+ void *srcfile = NULL;
+
+ if (! include_source((yyvsp[0]), & srcfile))
YYABORT;
efree((yyvsp[0])->lextok);
bcfree((yyvsp[0]));
- (yyval) = NULL;
+ (yyval) = (INSTRUCTION *) srcfile;
}
-#line 1980 "awkgram.c" /* yacc.c:1645 */
+#line 2020 "awkgram.c" /* yacc.c:1645 */
break;
case 13:
-#line 286 "awkgram.y" /* yacc.c:1645 */
+#line 322 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 1986 "awkgram.c" /* yacc.c:1645 */
+#line 2026 "awkgram.c" /* yacc.c:1645 */
break;
case 14:
-#line 288 "awkgram.y" /* yacc.c:1645 */
+#line 324 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 1992 "awkgram.c" /* yacc.c:1645 */
+#line 2032 "awkgram.c" /* yacc.c:1645 */
break;
case 15:
-#line 293 "awkgram.y" /* yacc.c:1645 */
+#line 329 "awkgram.y" /* yacc.c:1645 */
{
- if (load_library((yyvsp[0])) < 0)
+ void *srcfile;
+
+ if (! load_library((yyvsp[0]), & srcfile))
YYABORT;
efree((yyvsp[0])->lextok);
bcfree((yyvsp[0]));
- (yyval) = NULL;
+ (yyval) = (INSTRUCTION *) srcfile;
}
-#line 2004 "awkgram.c" /* yacc.c:1645 */
+#line 2046 "awkgram.c" /* yacc.c:1645 */
break;
case 16:
-#line 301 "awkgram.y" /* yacc.c:1645 */
+#line 339 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2010 "awkgram.c" /* yacc.c:1645 */
+#line 2052 "awkgram.c" /* yacc.c:1645 */
break;
case 17:
-#line 303 "awkgram.y" /* yacc.c:1645 */
+#line 341 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2016 "awkgram.c" /* yacc.c:1645 */
+#line 2058 "awkgram.c" /* yacc.c:1645 */
break;
case 18:
-#line 308 "awkgram.y" /* yacc.c:1645 */
+#line 346 "awkgram.y" /* yacc.c:1645 */
{
rule = Rule;
- if (comment != NULL) {
- (yyval) = list_create(comment);
- comment = NULL;
- } else
- (yyval) = NULL;
+ (yyval) = NULL;
}
-#line 2029 "awkgram.c" /* yacc.c:1645 */
+#line 2067 "awkgram.c" /* yacc.c:1645 */
break;
case 19:
-#line 317 "awkgram.y" /* yacc.c:1645 */
+#line 351 "awkgram.y" /* yacc.c:1645 */
{
rule = Rule;
- if (comment != NULL) {
- (yyval) = list_prepend((yyvsp[0]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[0]);
}
-#line 2042 "awkgram.c" /* yacc.c:1645 */
+#line 2075 "awkgram.c" /* yacc.c:1645 */
break;
case 20:
-#line 327 "awkgram.y" /* yacc.c:1645 */
+#line 356 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *tp;
- add_lint((yyvsp[-3]), LINT_assign_in_cond);
+ add_lint((yyvsp[-2]), LINT_assign_in_cond);
add_lint((yyvsp[0]), LINT_assign_in_cond);
tp = instruction(Op_no_op);
- list_prepend((yyvsp[-3]), bcalloc(Op_line_range, !!do_pretty_print + 1, 0));
- (yyvsp[-3])->nexti->triggered = false;
- (yyvsp[-3])->nexti->target_jmp = (yyvsp[0])->nexti;
+ list_prepend((yyvsp[-2]), bcalloc(Op_line_range, !!do_pretty_print + 1, 0));
+ (yyvsp[-2])->nexti->triggered = false;
+ (yyvsp[-2])->nexti->target_jmp = (yyvsp[0])->nexti;
- list_append((yyvsp[-3]), instruction(Op_cond_pair));
- (yyvsp[-3])->lasti->line_range = (yyvsp[-3])->nexti;
- (yyvsp[-3])->lasti->target_jmp = tp;
+ list_append((yyvsp[-2]), instruction(Op_cond_pair));
+ (yyvsp[-2])->lasti->line_range = (yyvsp[-2])->nexti;
+ (yyvsp[-2])->lasti->target_jmp = tp;
list_append((yyvsp[0]), instruction(Op_cond_pair));
- (yyvsp[0])->lasti->line_range = (yyvsp[-3])->nexti;
+ (yyvsp[0])->lasti->line_range = (yyvsp[-2])->nexti;
(yyvsp[0])->lasti->target_jmp = tp;
if (do_pretty_print) {
- ((yyvsp[-3])->nexti + 1)->condpair_left = (yyvsp[-3])->lasti;
- ((yyvsp[-3])->nexti + 1)->condpair_right = (yyvsp[0])->lasti;
+ ((yyvsp[-2])->nexti + 1)->condpair_left = (yyvsp[-2])->lasti;
+ ((yyvsp[-2])->nexti + 1)->condpair_right = (yyvsp[0])->lasti;
}
- if (comment != NULL) {
- (yyval) = list_append(list_merge(list_prepend((yyvsp[-3]), comment), (yyvsp[0])), tp);
- comment = NULL;
- } else
- (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp);
+ /* Put any comments in front of the range expression */
+ if ((yyvsp[-1]) != NULL)
+ (yyval) = list_append(list_merge(list_prepend((yyvsp[-2]), (yyvsp[-1])), (yyvsp[0])), tp);
+ else
+ (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), tp);
rule = Rule;
}
-#line 2076 "awkgram.c" /* yacc.c:1645 */
+#line 2109 "awkgram.c" /* yacc.c:1645 */
break;
case 21:
-#line 357 "awkgram.y" /* yacc.c:1645 */
+#line 386 "awkgram.y" /* yacc.c:1645 */
{
static int begin_seen = 0;
- func_first = false;
if (do_lint_old && ++begin_seen == 2)
warning_ln((yyvsp[0])->source_line,
_("old awk does not support multiple `BEGIN' or `END' rules"));
(yyvsp[0])->in_rule = rule = BEGIN;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2094 "awkgram.c" /* yacc.c:1645 */
+#line 2125 "awkgram.c" /* yacc.c:1645 */
break;
case 22:
-#line 371 "awkgram.y" /* yacc.c:1645 */
+#line 398 "awkgram.y" /* yacc.c:1645 */
{
static int end_seen = 0;
- func_first = false;
if (do_lint_old && ++end_seen == 2)
warning_ln((yyvsp[0])->source_line,
_("old awk does not support multiple `BEGIN' or `END' rules"));
(yyvsp[0])->in_rule = rule = END;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2112 "awkgram.c" /* yacc.c:1645 */
+#line 2141 "awkgram.c" /* yacc.c:1645 */
break;
case 23:
-#line 385 "awkgram.y" /* yacc.c:1645 */
+#line 410 "awkgram.y" /* yacc.c:1645 */
{
- func_first = false;
(yyvsp[0])->in_rule = rule = BEGINFILE;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2124 "awkgram.c" /* yacc.c:1645 */
+#line 2151 "awkgram.c" /* yacc.c:1645 */
break;
case 24:
-#line 393 "awkgram.y" /* yacc.c:1645 */
+#line 416 "awkgram.y" /* yacc.c:1645 */
{
- func_first = false;
(yyvsp[0])->in_rule = rule = ENDFILE;
(yyvsp[0])->source_file = source;
- check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2136 "awkgram.c" /* yacc.c:1645 */
+#line 2161 "awkgram.c" /* yacc.c:1645 */
break;
case 25:
-#line 404 "awkgram.y" /* yacc.c:1645 */
+#line 425 "awkgram.y" /* yacc.c:1645 */
{
- INSTRUCTION *ip;
- if ((yyvsp[-3]) == NULL)
- ip = list_create(instruction(Op_no_op));
- else
- ip = (yyvsp[-3]);
+ INSTRUCTION *ip = make_braced_statements((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]));
+
+ if ((yyvsp[-2]) != NULL && (yyvsp[0]) != NULL) {
+ merge_comments((yyvsp[-2]), (yyvsp[0]));
+ pending_comment = (yyvsp[-2]);
+ } else if ((yyvsp[-2]) != NULL) {
+ pending_comment = (yyvsp[-2]);
+ } else if ((yyvsp[0]) != NULL) {
+ pending_comment = (yyvsp[0]);
+ }
+
(yyval) = ip;
}
-#line 2149 "awkgram.c" /* yacc.c:1645 */
+#line 2180 "awkgram.c" /* yacc.c:1645 */
break;
case 26:
-#line 416 "awkgram.y" /* yacc.c:1645 */
+#line 443 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 2155 "awkgram.c" /* yacc.c:1645 */
+#line 2186 "awkgram.c" /* yacc.c:1645 */
break;
case 27:
-#line 418 "awkgram.y" /* yacc.c:1645 */
+#line 445 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 2161 "awkgram.c" /* yacc.c:1645 */
+#line 2192 "awkgram.c" /* yacc.c:1645 */
break;
case 28:
-#line 420 "awkgram.y" /* yacc.c:1645 */
+#line 447 "awkgram.y" /* yacc.c:1645 */
{
yyerror(_("`%s' is a built-in function, it cannot be redefined"),
tokstart);
YYABORT;
}
-#line 2171 "awkgram.c" /* yacc.c:1645 */
+#line 2202 "awkgram.c" /* yacc.c:1645 */
break;
case 29:
-#line 426 "awkgram.y" /* yacc.c:1645 */
+#line 453 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = (yyvsp[0]);
at_seen = false;
}
-#line 2180 "awkgram.c" /* yacc.c:1645 */
+#line 2211 "awkgram.c" /* yacc.c:1645 */
break;
case 32:
-#line 438 "awkgram.y" /* yacc.c:1645 */
+#line 465 "awkgram.y" /* yacc.c:1645 */
{ want_param_names = FUNC_HEADER; }
-#line 2186 "awkgram.c" /* yacc.c:1645 */
+#line 2217 "awkgram.c" /* yacc.c:1645 */
break;
case 33:
-#line 439 "awkgram.y" /* yacc.c:1645 */
+#line 466 "awkgram.y" /* yacc.c:1645 */
{
- /*
- * treat any comments between BOF and the first function
- * definition (with no intervening BEGIN etc block) as
- * program comments. Special kludge: iff there are more
- * than one such comments, treat the last as a function
- * comment.
- */
- if (prior_comment != NULL) {
- comment_to_save = prior_comment;
- prior_comment = NULL;
- } else if (comment != NULL) {
- comment_to_save = comment;
- comment = NULL;
- } else
- comment_to_save = NULL;
-
- if (comment_to_save != NULL && func_first
- && strstr(comment_to_save->memory->stptr, "\n\n") != NULL)
- split_comment();
-
- /* save any other pre-function comment as function comment */
- if (comment_to_save != NULL) {
- function_comment = comment_to_save;
- comment_to_save = NULL;
+ INSTRUCTION *func_comment = NULL;
+ // Merge any comments found in the parameter list with those
+ // following the function header, associate the whole shebang
+ // with the function as one block comment.
+ if ((yyvsp[-2]) != NULL && (yyvsp[-2])->comment != NULL) {
+ if ((yyvsp[0]) != NULL) {
+ merge_comments((yyvsp[-2])->comment, (yyvsp[0]));
+ }
+ func_comment = (yyvsp[-2])->comment;
+ } else if ((yyvsp[0]) != NULL) {
+ func_comment = (yyvsp[0]);
}
- func_first = false;
+
(yyvsp[-6])->source_file = source;
+ (yyvsp[-6])->comment = func_comment;
if (install_function((yyvsp[-5])->lextok, (yyvsp[-6]), (yyvsp[-2])) < 0)
YYABORT;
in_function = (yyvsp[-5])->lextok;
@@ -2224,17 +2243,17 @@ yyreduce:
(yyval) = (yyvsp[-6]);
want_param_names = FUNC_BODY;
}
-#line 2228 "awkgram.c" /* yacc.c:1645 */
+#line 2247 "awkgram.c" /* yacc.c:1645 */
break;
case 34:
-#line 484 "awkgram.y" /* yacc.c:1645 */
+#line 499 "awkgram.y" /* yacc.c:1645 */
{ want_regexp = true; }
-#line 2234 "awkgram.c" /* yacc.c:1645 */
+#line 2253 "awkgram.c" /* yacc.c:1645 */
break;
case 35:
-#line 486 "awkgram.y" /* yacc.c:1645 */
+#line 501 "awkgram.y" /* yacc.c:1645 */
{
NODE *n, *exp;
char *re;
@@ -2263,11 +2282,11 @@ yyreduce:
(yyval)->opcode = Op_match_rec;
(yyval)->memory = n;
}
-#line 2267 "awkgram.c" /* yacc.c:1645 */
+#line 2286 "awkgram.c" /* yacc.c:1645 */
break;
case 36:
-#line 518 "awkgram.y" /* yacc.c:1645 */
+#line 533 "awkgram.y" /* yacc.c:1645 */
{
char *re;
size_t len;
@@ -2280,112 +2299,100 @@ yyreduce:
(yyval)->opcode = Op_push_re;
(yyval)->memory = make_typed_regex(re, len);
}
-#line 2284 "awkgram.c" /* yacc.c:1645 */
+#line 2303 "awkgram.c" /* yacc.c:1645 */
break;
case 37:
-#line 533 "awkgram.y" /* yacc.c:1645 */
+#line 548 "awkgram.y" /* yacc.c:1645 */
{ bcfree((yyvsp[0])); }
-#line 2290 "awkgram.c" /* yacc.c:1645 */
+#line 2309 "awkgram.c" /* yacc.c:1645 */
break;
case 39:
-#line 539 "awkgram.y" /* yacc.c:1645 */
- {
- if (prior_comment != NULL) {
- (yyval) = list_create(prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL) {
- (yyval) = list_create(comment);
- comment = NULL;
- } else
- (yyval) = NULL;
- }
-#line 2305 "awkgram.c" /* yacc.c:1645 */
+#line 554 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 2315 "awkgram.c" /* yacc.c:1645 */
break;
case 40:
-#line 550 "awkgram.y" /* yacc.c:1645 */
+#line 556 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0]) == NULL) {
- if (prior_comment != NULL) {
- (yyval) = list_append((yyvsp[-1]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- (yyval) = list_append((yyval), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- (yyval) = list_append((yyvsp[-1]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[-1]);
+ (yyval) = (yyvsp[-1]);
} else {
add_lint((yyvsp[0]), LINT_no_effect);
if ((yyvsp[-1]) == NULL) {
- if (prior_comment != NULL) {
- (yyval) = list_append((yyvsp[0]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- (yyval) = list_append((yyval), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- (yyval) = list_append((yyvsp[0]), comment);
- comment = NULL;
- } else
- (yyval) = (yyvsp[0]);
+ (yyval) = (yyvsp[0]);
} else {
- if (prior_comment != NULL) {
- list_append((yyvsp[0]), prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- list_append((yyvsp[0]), comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- list_append((yyvsp[0]), comment);
- comment = NULL;
- }
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
}
+
+ if (trailing_comment != NULL) {
+ (yyval) = list_append((yyval), trailing_comment);
+ trailing_comment = NULL;
+ }
+
yyerrok;
}
-#line 2356 "awkgram.c" /* yacc.c:1645 */
+#line 2339 "awkgram.c" /* yacc.c:1645 */
break;
case 41:
-#line 597 "awkgram.y" /* yacc.c:1645 */
+#line 576 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 2362 "awkgram.c" /* yacc.c:1645 */
+#line 2345 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 42:
+#line 580 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 2351 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 43:
+#line 581 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 2357 "awkgram.c" /* yacc.c:1645 */
break;
case 44:
-#line 607 "awkgram.y" /* yacc.c:1645 */
- { (yyval) = NULL; }
-#line 2368 "awkgram.c" /* yacc.c:1645 */
+#line 586 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL) {
+ INSTRUCTION *ip;
+
+ merge_comments((yyvsp[0]), NULL);
+ ip = list_create(instruction(Op_no_op));
+ (yyval) = list_append(ip, (yyvsp[0]));
+ } else
+ (yyval) = NULL;
+ }
+#line 2372 "awkgram.c" /* yacc.c:1645 */
break;
case 45:
-#line 609 "awkgram.y" /* yacc.c:1645 */
- { (yyval) = (yyvsp[-1]); }
-#line 2374 "awkgram.c" /* yacc.c:1645 */
+#line 597 "awkgram.y" /* yacc.c:1645 */
+ {
+ trailing_comment = (yyvsp[0]); // NULL or comment
+ (yyval) = make_braced_statements((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]));
+ }
+#line 2381 "awkgram.c" /* yacc.c:1645 */
break;
case 46:
-#line 611 "awkgram.y" /* yacc.c:1645 */
+#line 602 "awkgram.y" /* yacc.c:1645 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
}
-#line 2385 "awkgram.c" /* yacc.c:1645 */
+#line 2392 "awkgram.c" /* yacc.c:1645 */
break;
case 47:
-#line 618 "awkgram.y" /* yacc.c:1645 */
+#line 609 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2403,8 +2410,9 @@ yyreduce:
if ((yyvsp[-2]) != NULL) {
curr = (yyvsp[-2])->nexti;
bcfree((yyvsp[-2])); /* Op_list */
- } /* else
- curr = NULL; */
+ }
+ /* else
+ curr = NULL; */
for (; curr != NULL; curr = nextc) {
INSTRUCTION *caseexp = curr->case_exp;
@@ -2460,26 +2468,43 @@ yyreduce:
ip = (yyvsp[-6]);
if (do_pretty_print) {
+ // first merge comments
+ INSTRUCTION *head_comment = NULL;
+
+ if ((yyvsp[-4]) != NULL && (yyvsp[-3]) != NULL) {
+ merge_comments((yyvsp[-4]), (yyvsp[-3]));
+ head_comment = (yyvsp[-4]);
+ } else if ((yyvsp[-4]) != NULL)
+ head_comment = (yyvsp[-4]);
+ else
+ head_comment = (yyvsp[-3]);
+
+ (yyvsp[-8])->comment = head_comment;
+
(void) list_prepend(ip, (yyvsp[-8]));
(void) list_prepend(ip, instruction(Op_exec_count));
(yyvsp[-8])->target_break = tbreak;
((yyvsp[-8]) + 1)->switch_start = cexp->nexti;
((yyvsp[-8]) + 1)->switch_end = cexp->lasti;
- }/* else
- $1 is NULL */
+ ((yyvsp[-8]) + 1)->switch_end->comment = (yyvsp[0]);
+ }
+ /* else
+ $1 is NULL */
(void) list_append(cexp, dflt);
(void) list_merge(ip, cexp);
+ if ((yyvsp[-1]) != NULL)
+ (void) list_append(cstmt, (yyvsp[-1]));
(yyval) = list_merge(ip, cstmt);
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2479 "awkgram.c" /* yacc.c:1645 */
+#line 2504 "awkgram.c" /* yacc.c:1645 */
break;
case 48:
-#line 708 "awkgram.y" /* yacc.c:1645 */
+#line 717 "awkgram.y" /* yacc.c:1645 */
{
/*
* -----------------
@@ -2508,8 +2533,17 @@ yyreduce:
(yyvsp[-5])->target_continue = tcont;
((yyvsp[-5]) + 1)->while_body = ip->lasti;
(void) list_prepend(ip, (yyvsp[-5]));
- }/* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
+
+ if ((yyvsp[-1]) != NULL) {
+ if ((yyvsp[0]) == NULL)
+ (yyvsp[0]) = list_create(instruction(Op_no_op));
+
+ (yyvsp[-1])->memory->comment_type = BLOCK_COMMENT;
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
+ }
if ((yyvsp[0]) != NULL)
(void) list_merge(ip, (yyvsp[0]));
@@ -2521,11 +2555,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2525 "awkgram.c" /* yacc.c:1645 */
+#line 2559 "awkgram.c" /* yacc.c:1645 */
break;
case 49:
-#line 750 "awkgram.y" /* yacc.c:1645 */
+#line 768 "awkgram.y" /* yacc.c:1645 */
{
/*
* -----------------
@@ -2548,8 +2582,13 @@ yyreduce:
ip = list_merge((yyvsp[-5]), (yyvsp[-2]));
else
ip = list_prepend((yyvsp[-2]), instruction(Op_no_op));
+
+ if ((yyvsp[-6]) != NULL)
+ (void) list_prepend(ip, (yyvsp[-6]));
+
if (do_pretty_print)
(void) list_prepend(ip, instruction(Op_exec_count));
+
(void) list_append(ip, instruction(Op_jmp_true));
ip->lasti->target_jmp = ip->nexti;
(yyval) = list_append(ip, tbreak);
@@ -2564,14 +2603,17 @@ yyreduce:
((yyvsp[-7]) + 1)->doloop_cond = tcont;
(yyval) = list_prepend(ip, (yyvsp[-7]));
bcfree((yyvsp[-4]));
- } /* else
+ if ((yyvsp[0]) != NULL)
+ (yyvsp[-7])->comment = (yyvsp[0]);
+ }
+ /* else
$1 and $4 are NULLs */
}
-#line 2571 "awkgram.c" /* yacc.c:1645 */
+#line 2613 "awkgram.c" /* yacc.c:1645 */
break;
case 50:
-#line 792 "awkgram.y" /* yacc.c:1645 */
+#line 818 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip;
char *var_name = (yyvsp[-5])->lextok;
@@ -2584,7 +2626,8 @@ yyreduce:
&& strcmp((yyvsp[0])->nexti->memory->vname, var_name) == 0
) {
- /* Efficiency hack. Recognize the special case of
+ /*
+ * Efficiency hack. Recognize the special case of
*
* for (iggy in foo)
* delete foo[iggy]
@@ -2616,6 +2659,10 @@ yyreduce:
bcfree((yyvsp[-5]));
bcfree((yyvsp[-4]));
bcfree((yyvsp[-3]));
+ if ((yyvsp[-1]) != NULL) {
+ merge_comments((yyvsp[-1]), NULL);
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
+ }
(yyval) = (yyvsp[0]);
} else
goto regular_loop;
@@ -2650,8 +2697,9 @@ regular_loop:
(yyvsp[-7])->target_continue = tcont;
(yyvsp[-7])->target_break = tbreak;
(void) list_append(ip, (yyvsp[-7]));
- } /* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
/* add update_FOO instruction if necessary */
if ((yyvsp[-4])->array_var->type == Node_var && (yyvsp[-4])->array_var->var_update) {
@@ -2672,8 +2720,15 @@ regular_loop:
((yyvsp[-7]) + 1)->forloop_body = ip->lasti;
}
- if ((yyvsp[0]) != NULL)
+ if ((yyvsp[-1]) != NULL)
+ merge_comments((yyvsp[-1]), NULL);
+
+ if ((yyvsp[0]) != NULL) {
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(void) list_merge(ip, (yyvsp[0]));
+ } else if ((yyvsp[-1]) != NULL)
+ (void) list_append(ip, (yyvsp[-1]));
(void) list_append(ip, instruction(Op_jmp));
ip->lasti->target_jmp = (yyvsp[-4]);
@@ -2684,73 +2739,100 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2688 "awkgram.c" /* yacc.c:1645 */
+#line 2743 "awkgram.c" /* yacc.c:1645 */
break;
case 51:
-#line 905 "awkgram.y" /* yacc.c:1645 */
+#line 944 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-7]) != NULL) {
+ merge_comments((yyvsp[-7]), NULL);
+ (yyvsp[-11])->comment = (yyvsp[-7]);
+ }
+ if ((yyvsp[-4]) != NULL) {
+ merge_comments((yyvsp[-4]), NULL);
+ if ((yyvsp[-11])->comment == NULL) {
+ (yyvsp[-4])->memory->comment_type = FOR_COMMENT;
+ (yyvsp[-11])->comment = (yyvsp[-4]);
+ } else
+ (yyvsp[-11])->comment->comment = (yyvsp[-4]);
+ }
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2699 "awkgram.c" /* yacc.c:1645 */
+#line 2768 "awkgram.c" /* yacc.c:1645 */
break;
case 52:
-#line 912 "awkgram.y" /* yacc.c:1645 */
+#line 965 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-6]) != NULL) {
+ merge_comments((yyvsp[-6]), NULL);
+ (yyvsp[-10])->comment = (yyvsp[-6]);
+ }
+ if ((yyvsp[-4]) != NULL) {
+ merge_comments((yyvsp[-4]), NULL);
+ if ((yyvsp[-10])->comment == NULL) {
+ (yyvsp[-4])->memory->comment_type = FOR_COMMENT;
+ (yyvsp[-10])->comment = (yyvsp[-4]);
+ } else
+ (yyvsp[-10])->comment->comment = (yyvsp[-4]);
+ }
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[0]) = list_prepend((yyvsp[0]), (yyvsp[-1]));
(yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2710 "awkgram.c" /* yacc.c:1645 */
+#line 2793 "awkgram.c" /* yacc.c:1645 */
break;
case 53:
-#line 919 "awkgram.y" /* yacc.c:1645 */
+#line 986 "awkgram.y" /* yacc.c:1645 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
- (yyval) = add_pending_comment((yyval));
}
-#line 2722 "awkgram.c" /* yacc.c:1645 */
+#line 2804 "awkgram.c" /* yacc.c:1645 */
break;
case 54:
-#line 930 "awkgram.y" /* yacc.c:1645 */
+#line 996 "awkgram.y" /* yacc.c:1645 */
{
if (! break_allowed)
error_ln((yyvsp[-1])->source_line,
_("`break' is not allowed outside a loop or switch"));
(yyvsp[-1])->target_jmp = NULL;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
-
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2736 "awkgram.c" /* yacc.c:1645 */
+#line 2818 "awkgram.c" /* yacc.c:1645 */
break;
case 55:
-#line 940 "awkgram.y" /* yacc.c:1645 */
+#line 1006 "awkgram.y" /* yacc.c:1645 */
{
if (! continue_allowed)
error_ln((yyvsp[-1])->source_line,
_("`continue' is not allowed outside a loop"));
(yyvsp[-1])->target_jmp = NULL;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
-
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2750 "awkgram.c" /* yacc.c:1645 */
+#line 2832 "awkgram.c" /* yacc.c:1645 */
break;
case 56:
-#line 950 "awkgram.y" /* yacc.c:1645 */
+#line 1016 "awkgram.y" /* yacc.c:1645 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2758,13 +2840,14 @@ regular_loop:
_("`next' used in %s action"), ruletab[rule]);
(yyvsp[-1])->target_jmp = ip_rec;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2764 "awkgram.c" /* yacc.c:1645 */
+#line 2847 "awkgram.c" /* yacc.c:1645 */
break;
case 57:
-#line 960 "awkgram.y" /* yacc.c:1645 */
+#line 1027 "awkgram.y" /* yacc.c:1645 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule == BEGIN || rule == END || rule == ENDFILE)
@@ -2774,13 +2857,14 @@ regular_loop:
(yyvsp[-1])->target_newfile = ip_newfile;
(yyvsp[-1])->target_endfile = ip_endfile;
(yyval) = list_create((yyvsp[-1]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2780 "awkgram.c" /* yacc.c:1645 */
+#line 2864 "awkgram.c" /* yacc.c:1645 */
break;
case 58:
-#line 972 "awkgram.y" /* yacc.c:1645 */
+#line 1040 "awkgram.y" /* yacc.c:1645 */
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2794,22 +2878,23 @@ regular_loop:
(yyval)->nexti->memory = dupnode(Nnull_string);
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
- (yyval) = add_pending_comment((yyval));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
}
-#line 2800 "awkgram.c" /* yacc.c:1645 */
+#line 2885 "awkgram.c" /* yacc.c:1645 */
break;
case 59:
-#line 988 "awkgram.y" /* yacc.c:1645 */
+#line 1057 "awkgram.y" /* yacc.c:1645 */
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 2809 "awkgram.c" /* yacc.c:1645 */
+#line 2894 "awkgram.c" /* yacc.c:1645 */
break;
case 60:
-#line 991 "awkgram.y" /* yacc.c:1645 */
+#line 1060 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-1]) == NULL) {
(yyval) = list_create((yyvsp[-3]));
@@ -2817,20 +2902,31 @@ regular_loop:
(yyval)->nexti->memory = dupnode(Nnull_string);
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyval), (yyvsp[0]));
+ }
+#line 2909 "awkgram.c" /* yacc.c:1645 */
+ break;
- (yyval) = add_pending_comment((yyval));
+ case 61:
+#line 1071 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[0]) != NULL)
+ (yyval) = list_append((yyvsp[-1]), (yyvsp[0]));
+ else
+ (yyval) = (yyvsp[-1]);
}
-#line 2824 "awkgram.c" /* yacc.c:1645 */
+#line 2920 "awkgram.c" /* yacc.c:1645 */
break;
case 62:
-#line 1013 "awkgram.y" /* yacc.c:1645 */
+#line 1088 "awkgram.y" /* yacc.c:1645 */
{ in_print = true; in_parens = 0; }
-#line 2830 "awkgram.c" /* yacc.c:1645 */
+#line 2926 "awkgram.c" /* yacc.c:1645 */
break;
case 63:
-#line 1014 "awkgram.y" /* yacc.c:1645 */
+#line 1089 "awkgram.y" /* yacc.c:1645 */
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -2838,7 +2934,7 @@ regular_loop:
* which is faster for these two cases.
*/
- if ((yyvsp[-3])->opcode == Op_K_print &&
+ if (do_optimize && (yyvsp[-3])->opcode == Op_K_print &&
((yyvsp[-1]) == NULL
|| ((yyvsp[-1])->lasti->opcode == Op_field_spec
&& (yyvsp[-1])->nexti->nexti->nexti == (yyvsp[-1])->lasti
@@ -2926,19 +3022,18 @@ regular_print:
}
}
}
- (yyval) = add_pending_comment((yyval));
}
-#line 2932 "awkgram.c" /* yacc.c:1645 */
+#line 3027 "awkgram.c" /* yacc.c:1645 */
break;
case 64:
-#line 1112 "awkgram.y" /* yacc.c:1645 */
+#line 1186 "awkgram.y" /* yacc.c:1645 */
{ sub_counter = 0; }
-#line 2938 "awkgram.c" /* yacc.c:1645 */
+#line 3033 "awkgram.c" /* yacc.c:1645 */
break;
case 65:
-#line 1113 "awkgram.y" /* yacc.c:1645 */
+#line 1187 "awkgram.y" /* yacc.c:1645 */
{
char *arr = (yyvsp[-2])->lextok;
@@ -2970,13 +3065,12 @@ regular_print:
(yyvsp[-3])->expr_count = sub_counter;
(yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3]));
}
- (yyval) = add_pending_comment((yyval));
}
-#line 2976 "awkgram.c" /* yacc.c:1645 */
+#line 3070 "awkgram.c" /* yacc.c:1645 */
break;
case 66:
-#line 1151 "awkgram.y" /* yacc.c:1645 */
+#line 1224 "awkgram.y" /* yacc.c:1645 */
{
static bool warned = false;
char *arr = (yyvsp[-1])->lextok;
@@ -3001,57 +3095,55 @@ regular_print:
else if ((yyvsp[-1])->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
- (yyval) = add_pending_comment((yyval));
}
-#line 3007 "awkgram.c" /* yacc.c:1645 */
+#line 3100 "awkgram.c" /* yacc.c:1645 */
break;
case 67:
-#line 1178 "awkgram.y" /* yacc.c:1645 */
+#line 1250 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = optimize_assignment((yyvsp[0]));
- (yyval) = add_pending_comment((yyval));
}
-#line 3016 "awkgram.c" /* yacc.c:1645 */
+#line 3108 "awkgram.c" /* yacc.c:1645 */
break;
case 68:
-#line 1186 "awkgram.y" /* yacc.c:1645 */
+#line 1257 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3022 "awkgram.c" /* yacc.c:1645 */
+#line 3114 "awkgram.c" /* yacc.c:1645 */
break;
case 69:
-#line 1188 "awkgram.y" /* yacc.c:1645 */
+#line 1259 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3028 "awkgram.c" /* yacc.c:1645 */
+#line 3120 "awkgram.c" /* yacc.c:1645 */
break;
case 70:
-#line 1193 "awkgram.y" /* yacc.c:1645 */
+#line 1264 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3034 "awkgram.c" /* yacc.c:1645 */
+#line 3126 "awkgram.c" /* yacc.c:1645 */
break;
case 71:
-#line 1195 "awkgram.y" /* yacc.c:1645 */
+#line 1266 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-1]) == NULL)
(yyval) = list_create((yyvsp[0]));
else
(yyval) = list_prepend((yyvsp[-1]), (yyvsp[0]));
}
-#line 3045 "awkgram.c" /* yacc.c:1645 */
+#line 3137 "awkgram.c" /* yacc.c:1645 */
break;
case 72:
-#line 1202 "awkgram.y" /* yacc.c:1645 */
+#line 1273 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3051 "awkgram.c" /* yacc.c:1645 */
+#line 3143 "awkgram.c" /* yacc.c:1645 */
break;
case 73:
-#line 1207 "awkgram.y" /* yacc.c:1645 */
+#line 1278 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -3060,14 +3152,15 @@ regular_print:
(void) list_prepend(casestmt, instruction(Op_exec_count));
(yyvsp[-4])->case_exp = (yyvsp[-3]);
(yyvsp[-4])->case_stmt = casestmt;
+ (yyvsp[-4])->comment = (yyvsp[-1]);
bcfree((yyvsp[-2]));
(yyval) = (yyvsp[-4]);
}
-#line 3067 "awkgram.c" /* yacc.c:1645 */
+#line 3160 "awkgram.c" /* yacc.c:1645 */
break;
case 74:
-#line 1219 "awkgram.y" /* yacc.c:1645 */
+#line 1291 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -3076,19 +3169,20 @@ regular_print:
(void) list_prepend(casestmt, instruction(Op_exec_count));
bcfree((yyvsp[-2]));
(yyvsp[-3])->case_stmt = casestmt;
+ (yyvsp[-3])->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-3]);
}
-#line 3082 "awkgram.c" /* yacc.c:1645 */
+#line 3176 "awkgram.c" /* yacc.c:1645 */
break;
case 75:
-#line 1233 "awkgram.y" /* yacc.c:1645 */
+#line 1306 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3088 "awkgram.c" /* yacc.c:1645 */
+#line 3182 "awkgram.c" /* yacc.c:1645 */
break;
case 76:
-#line 1235 "awkgram.y" /* yacc.c:1645 */
+#line 1308 "awkgram.y" /* yacc.c:1645 */
{
NODE *n = (yyvsp[0])->memory;
(void) force_number(n);
@@ -3096,28 +3190,28 @@ regular_print:
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3100 "awkgram.c" /* yacc.c:1645 */
+#line 3194 "awkgram.c" /* yacc.c:1645 */
break;
case 77:
-#line 1243 "awkgram.y" /* yacc.c:1645 */
+#line 1316 "awkgram.y" /* yacc.c:1645 */
{
NODE *n = (yyvsp[0])->lasti->memory;
bcfree((yyvsp[-1]));
add_sign_to_num(n, '+');
(yyval) = (yyvsp[0]);
}
-#line 3111 "awkgram.c" /* yacc.c:1645 */
+#line 3205 "awkgram.c" /* yacc.c:1645 */
break;
case 78:
-#line 1250 "awkgram.y" /* yacc.c:1645 */
+#line 1323 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3117 "awkgram.c" /* yacc.c:1645 */
+#line 3211 "awkgram.c" /* yacc.c:1645 */
break;
case 79:
-#line 1252 "awkgram.y" /* yacc.c:1645 */
+#line 1325 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->memory->type == Node_regex)
(yyvsp[0])->opcode = Op_push_re;
@@ -3125,57 +3219,57 @@ regular_print:
(yyvsp[0])->opcode = Op_push;
(yyval) = (yyvsp[0]);
}
-#line 3129 "awkgram.c" /* yacc.c:1645 */
+#line 3223 "awkgram.c" /* yacc.c:1645 */
break;
case 80:
-#line 1260 "awkgram.y" /* yacc.c:1645 */
+#line 1333 "awkgram.y" /* yacc.c:1645 */
{
assert(((yyvsp[0])->memory->flags & REGEX) == REGEX);
(yyvsp[0])->opcode = Op_push_re;
(yyval) = (yyvsp[0]);
}
-#line 3139 "awkgram.c" /* yacc.c:1645 */
+#line 3233 "awkgram.c" /* yacc.c:1645 */
break;
case 81:
-#line 1269 "awkgram.y" /* yacc.c:1645 */
+#line 1342 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3145 "awkgram.c" /* yacc.c:1645 */
+#line 3239 "awkgram.c" /* yacc.c:1645 */
break;
case 82:
-#line 1271 "awkgram.y" /* yacc.c:1645 */
+#line 1344 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3151 "awkgram.c" /* yacc.c:1645 */
+#line 3245 "awkgram.c" /* yacc.c:1645 */
break;
case 84:
-#line 1281 "awkgram.y" /* yacc.c:1645 */
+#line 1354 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = (yyvsp[-1]);
}
-#line 3159 "awkgram.c" /* yacc.c:1645 */
+#line 3253 "awkgram.c" /* yacc.c:1645 */
break;
case 85:
-#line 1288 "awkgram.y" /* yacc.c:1645 */
+#line 1361 "awkgram.y" /* yacc.c:1645 */
{
in_print = false;
in_parens = 0;
(yyval) = NULL;
}
-#line 3169 "awkgram.c" /* yacc.c:1645 */
+#line 3263 "awkgram.c" /* yacc.c:1645 */
break;
case 86:
-#line 1293 "awkgram.y" /* yacc.c:1645 */
+#line 1366 "awkgram.y" /* yacc.c:1645 */
{ in_print = false; in_parens = 0; }
-#line 3175 "awkgram.c" /* yacc.c:1645 */
+#line 3269 "awkgram.c" /* yacc.c:1645 */
break;
case 87:
-#line 1294 "awkgram.y" /* yacc.c:1645 */
+#line 1367 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->redir_type == redirect_twoway
&& (yyvsp[0])->lasti->opcode == Op_K_getline_redir
@@ -3185,139 +3279,197 @@ regular_print:
lintwarn(_("concatenation as I/O `>' redirection target is ambiguous"));
(yyval) = list_prepend((yyvsp[0]), (yyvsp[-2]));
}
-#line 3189 "awkgram.c" /* yacc.c:1645 */
+#line 3283 "awkgram.c" /* yacc.c:1645 */
break;
case 88:
-#line 1307 "awkgram.y" /* yacc.c:1645 */
+#line 1380 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-5])->comment = (yyvsp[-1]);
(yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL);
}
-#line 3197 "awkgram.c" /* yacc.c:1645 */
+#line 3293 "awkgram.c" /* yacc.c:1645 */
break;
case 89:
-#line 1312 "awkgram.y" /* yacc.c:1645 */
+#line 1387 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-4]) != NULL)
+ (yyvsp[-8])->comment = (yyvsp[-4]);
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->comment = (yyvsp[-1]);
(yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0]));
}
-#line 3205 "awkgram.c" /* yacc.c:1645 */
+#line 3305 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 90:
+#line 1398 "awkgram.y" /* yacc.c:1645 */
+ {
+ (yyval) = (yyvsp[0]);
+ }
+#line 3313 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 91:
+#line 1402 "awkgram.y" /* yacc.c:1645 */
+ {
+ if ((yyvsp[-1]) != NULL && (yyvsp[0]) != NULL) {
+ if ((yyvsp[-1])->memory->comment_type == EOL_COMMENT) {
+ assert((yyvsp[0])->memory->comment_type == BLOCK_COMMENT);
+ (yyvsp[-1])->comment = (yyvsp[0]); // chain them
+ } else {
+ merge_comments((yyvsp[-1]), (yyvsp[0]));
+ }
+
+ (yyval) = (yyvsp[-1]);
+ } else if ((yyvsp[-1]) != NULL) {
+ (yyval) = (yyvsp[-1]);
+ } else if ((yyvsp[0]) != NULL) {
+ (yyval) = (yyvsp[0]);
+ } else
+ (yyval) = NULL;
+ }
+#line 3335 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 92:
+#line 1423 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 3341 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 93:
+#line 1425 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 3347 "awkgram.c" /* yacc.c:1645 */
break;
case 94:
-#line 1329 "awkgram.y" /* yacc.c:1645 */
+#line 1430 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3211 "awkgram.c" /* yacc.c:1645 */
+#line 3353 "awkgram.c" /* yacc.c:1645 */
break;
case 95:
-#line 1331 "awkgram.y" /* yacc.c:1645 */
+#line 1432 "awkgram.y" /* yacc.c:1645 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3220 "awkgram.c" /* yacc.c:1645 */
+#line 3362 "awkgram.c" /* yacc.c:1645 */
break;
case 96:
-#line 1339 "awkgram.y" /* yacc.c:1645 */
+#line 1440 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3226 "awkgram.c" /* yacc.c:1645 */
+#line 3368 "awkgram.c" /* yacc.c:1645 */
break;
case 97:
-#line 1341 "awkgram.y" /* yacc.c:1645 */
+#line 1442 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3232 "awkgram.c" /* yacc.c:1645 */
+#line 3374 "awkgram.c" /* yacc.c:1645 */
break;
case 98:
-#line 1346 "awkgram.y" /* yacc.c:1645 */
+#line 1447 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->param_count = 0;
(yyval) = list_create((yyvsp[0]));
}
-#line 3241 "awkgram.c" /* yacc.c:1645 */
+#line 3383 "awkgram.c" /* yacc.c:1645 */
break;
case 99:
-#line 1351 "awkgram.y" /* yacc.c:1645 */
+#line 1452 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2]) != NULL && (yyvsp[0]) != NULL) {
- (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1;
+ (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1;
(yyval) = list_append((yyvsp[-2]), (yyvsp[0]));
yyerrok;
+
+ // newlines are allowed after commas, catch any comments
+ if ((yyvsp[-1]) != NULL) {
+ if ((yyvsp[-2])->comment != NULL)
+ merge_comments((yyvsp[-2])->comment, (yyvsp[-1]));
+ else
+ (yyvsp[-2])->comment = (yyvsp[-1]);
+ }
} else
(yyval) = NULL;
}
-#line 3254 "awkgram.c" /* yacc.c:1645 */
+#line 3404 "awkgram.c" /* yacc.c:1645 */
break;
case 100:
-#line 1360 "awkgram.y" /* yacc.c:1645 */
+#line 1469 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3260 "awkgram.c" /* yacc.c:1645 */
+#line 3410 "awkgram.c" /* yacc.c:1645 */
break;
case 101:
-#line 1362 "awkgram.y" /* yacc.c:1645 */
+#line 1471 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 3266 "awkgram.c" /* yacc.c:1645 */
+#line 3416 "awkgram.c" /* yacc.c:1645 */
break;
case 102:
-#line 1364 "awkgram.y" /* yacc.c:1645 */
+#line 1473 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-2]); }
-#line 3272 "awkgram.c" /* yacc.c:1645 */
+#line 3422 "awkgram.c" /* yacc.c:1645 */
break;
case 103:
-#line 1370 "awkgram.y" /* yacc.c:1645 */
+#line 1479 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3278 "awkgram.c" /* yacc.c:1645 */
+#line 3428 "awkgram.c" /* yacc.c:1645 */
break;
case 104:
-#line 1372 "awkgram.y" /* yacc.c:1645 */
+#line 1481 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3284 "awkgram.c" /* yacc.c:1645 */
+#line 3434 "awkgram.c" /* yacc.c:1645 */
break;
case 105:
-#line 1377 "awkgram.y" /* yacc.c:1645 */
+#line 1486 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3290 "awkgram.c" /* yacc.c:1645 */
+#line 3440 "awkgram.c" /* yacc.c:1645 */
break;
case 106:
-#line 1379 "awkgram.y" /* yacc.c:1645 */
+#line 1488 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3296 "awkgram.c" /* yacc.c:1645 */
+#line 3446 "awkgram.c" /* yacc.c:1645 */
break;
case 107:
-#line 1384 "awkgram.y" /* yacc.c:1645 */
+#line 1493 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3302 "awkgram.c" /* yacc.c:1645 */
+#line 3452 "awkgram.c" /* yacc.c:1645 */
break;
case 108:
-#line 1386 "awkgram.y" /* yacc.c:1645 */
+#line 1495 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3311 "awkgram.c" /* yacc.c:1645 */
+#line 3463 "awkgram.c" /* yacc.c:1645 */
break;
case 109:
-#line 1391 "awkgram.y" /* yacc.c:1645 */
+#line 1502 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3317 "awkgram.c" /* yacc.c:1645 */
+#line 3469 "awkgram.c" /* yacc.c:1645 */
break;
case 110:
-#line 1393 "awkgram.y" /* yacc.c:1645 */
+#line 1504 "awkgram.y" /* yacc.c:1645 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3325,62 +3477,66 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3329 "awkgram.c" /* yacc.c:1645 */
+#line 3481 "awkgram.c" /* yacc.c:1645 */
break;
case 111:
-#line 1401 "awkgram.y" /* yacc.c:1645 */
+#line 1512 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3338 "awkgram.c" /* yacc.c:1645 */
+#line 3490 "awkgram.c" /* yacc.c:1645 */
break;
case 112:
-#line 1406 "awkgram.y" /* yacc.c:1645 */
+#line 1517 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-2]);
}
-#line 3347 "awkgram.c" /* yacc.c:1645 */
+#line 3501 "awkgram.c" /* yacc.c:1645 */
break;
case 113:
-#line 1414 "awkgram.y" /* yacc.c:1645 */
+#line 1527 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3353 "awkgram.c" /* yacc.c:1645 */
+#line 3507 "awkgram.c" /* yacc.c:1645 */
break;
case 114:
-#line 1416 "awkgram.y" /* yacc.c:1645 */
+#line 1529 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3359 "awkgram.c" /* yacc.c:1645 */
+#line 3513 "awkgram.c" /* yacc.c:1645 */
break;
case 115:
-#line 1421 "awkgram.y" /* yacc.c:1645 */
+#line 1534 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3365 "awkgram.c" /* yacc.c:1645 */
+#line 3519 "awkgram.c" /* yacc.c:1645 */
break;
case 116:
-#line 1423 "awkgram.y" /* yacc.c:1645 */
+#line 1536 "awkgram.y" /* yacc.c:1645 */
{
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->lasti->comment = (yyvsp[-1]);
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3374 "awkgram.c" /* yacc.c:1645 */
+#line 3530 "awkgram.c" /* yacc.c:1645 */
break;
case 117:
-#line 1428 "awkgram.y" /* yacc.c:1645 */
+#line 1543 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 3380 "awkgram.c" /* yacc.c:1645 */
+#line 3536 "awkgram.c" /* yacc.c:1645 */
break;
case 118:
-#line 1430 "awkgram.y" /* yacc.c:1645 */
+#line 1545 "awkgram.y" /* yacc.c:1645 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3388,72 +3544,74 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3392 "awkgram.c" /* yacc.c:1645 */
+#line 3548 "awkgram.c" /* yacc.c:1645 */
break;
case 119:
-#line 1438 "awkgram.y" /* yacc.c:1645 */
+#line 1553 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3401 "awkgram.c" /* yacc.c:1645 */
+#line 3557 "awkgram.c" /* yacc.c:1645 */
break;
case 120:
-#line 1443 "awkgram.y" /* yacc.c:1645 */
+#line 1558 "awkgram.y" /* yacc.c:1645 */
{
/* Ditto */
+ if ((yyvsp[-1]) != NULL)
+ (yyvsp[-2])->comment = (yyvsp[-1]);
(yyval) = (yyvsp[-2]);
}
-#line 3410 "awkgram.c" /* yacc.c:1645 */
+#line 3568 "awkgram.c" /* yacc.c:1645 */
break;
case 121:
-#line 1450 "awkgram.y" /* yacc.c:1645 */
+#line 1567 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3416 "awkgram.c" /* yacc.c:1645 */
+#line 3574 "awkgram.c" /* yacc.c:1645 */
break;
case 122:
-#line 1451 "awkgram.y" /* yacc.c:1645 */
+#line 1568 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = list_create((yyvsp[0])); }
-#line 3422 "awkgram.c" /* yacc.c:1645 */
+#line 3580 "awkgram.c" /* yacc.c:1645 */
break;
case 123:
-#line 1457 "awkgram.y" /* yacc.c:1645 */
+#line 1574 "awkgram.y" /* yacc.c:1645 */
{
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 3433 "awkgram.c" /* yacc.c:1645 */
+#line 3591 "awkgram.c" /* yacc.c:1645 */
break;
case 124:
-#line 1464 "awkgram.y" /* yacc.c:1645 */
+#line 1581 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = mk_assignment((yyvsp[-2]), list_create((yyvsp[0])), (yyvsp[-1]));
}
-#line 3441 "awkgram.c" /* yacc.c:1645 */
+#line 3599 "awkgram.c" /* yacc.c:1645 */
break;
case 125:
-#line 1468 "awkgram.y" /* yacc.c:1645 */
+#line 1585 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3447 "awkgram.c" /* yacc.c:1645 */
+#line 3605 "awkgram.c" /* yacc.c:1645 */
break;
case 126:
-#line 1470 "awkgram.y" /* yacc.c:1645 */
+#line 1587 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3453 "awkgram.c" /* yacc.c:1645 */
+#line 3611 "awkgram.c" /* yacc.c:1645 */
break;
case 127:
-#line 1472 "awkgram.y" /* yacc.c:1645 */
+#line 1589 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3466,11 +3624,11 @@ regular_print:
bcfree((yyvsp[0]));
(yyval) = list_append((yyvsp[-2]), (yyvsp[-1]));
}
-#line 3470 "awkgram.c" /* yacc.c:1645 */
+#line 3628 "awkgram.c" /* yacc.c:1645 */
break;
case 128:
-#line 1485 "awkgram.y" /* yacc.c:1645 */
+#line 1602 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3487,11 +3645,11 @@ regular_print:
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3491 "awkgram.c" /* yacc.c:1645 */
+#line 3649 "awkgram.c" /* yacc.c:1645 */
break;
case 129:
-#line 1502 "awkgram.y" /* yacc.c:1645 */
+#line 1619 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint_old)
warning_ln((yyvsp[-1])->source_line,
@@ -3501,91 +3659,91 @@ regular_print:
(yyvsp[-1])->expr_count = 1;
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
-#line 3505 "awkgram.c" /* yacc.c:1645 */
+#line 3663 "awkgram.c" /* yacc.c:1645 */
break;
case 130:
-#line 1512 "awkgram.y" /* yacc.c:1645 */
+#line 1629 "awkgram.y" /* yacc.c:1645 */
{
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 3516 "awkgram.c" /* yacc.c:1645 */
+#line 3674 "awkgram.c" /* yacc.c:1645 */
break;
case 131:
-#line 1519 "awkgram.y" /* yacc.c:1645 */
+#line 1636 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); }
-#line 3522 "awkgram.c" /* yacc.c:1645 */
+#line 3680 "awkgram.c" /* yacc.c:1645 */
break;
case 132:
-#line 1521 "awkgram.y" /* yacc.c:1645 */
+#line 1638 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3528 "awkgram.c" /* yacc.c:1645 */
+#line 3686 "awkgram.c" /* yacc.c:1645 */
break;
case 133:
-#line 1526 "awkgram.y" /* yacc.c:1645 */
+#line 1643 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3534 "awkgram.c" /* yacc.c:1645 */
+#line 3692 "awkgram.c" /* yacc.c:1645 */
break;
case 134:
-#line 1528 "awkgram.y" /* yacc.c:1645 */
+#line 1645 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3540 "awkgram.c" /* yacc.c:1645 */
+#line 3698 "awkgram.c" /* yacc.c:1645 */
break;
case 135:
-#line 1530 "awkgram.y" /* yacc.c:1645 */
+#line 1647 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[0]);
}
-#line 3549 "awkgram.c" /* yacc.c:1645 */
+#line 3707 "awkgram.c" /* yacc.c:1645 */
break;
case 136:
-#line 1538 "awkgram.y" /* yacc.c:1645 */
+#line 1655 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3555 "awkgram.c" /* yacc.c:1645 */
+#line 3713 "awkgram.c" /* yacc.c:1645 */
break;
case 137:
-#line 1540 "awkgram.y" /* yacc.c:1645 */
+#line 1657 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3561 "awkgram.c" /* yacc.c:1645 */
+#line 3719 "awkgram.c" /* yacc.c:1645 */
break;
case 138:
-#line 1545 "awkgram.y" /* yacc.c:1645 */
+#line 1662 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3567 "awkgram.c" /* yacc.c:1645 */
+#line 3725 "awkgram.c" /* yacc.c:1645 */
break;
case 139:
-#line 1547 "awkgram.y" /* yacc.c:1645 */
+#line 1664 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3573 "awkgram.c" /* yacc.c:1645 */
+#line 3731 "awkgram.c" /* yacc.c:1645 */
break;
case 140:
-#line 1552 "awkgram.y" /* yacc.c:1645 */
+#line 1669 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3579 "awkgram.c" /* yacc.c:1645 */
+#line 3737 "awkgram.c" /* yacc.c:1645 */
break;
case 141:
-#line 1554 "awkgram.y" /* yacc.c:1645 */
+#line 1671 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 3585 "awkgram.c" /* yacc.c:1645 */
+#line 3743 "awkgram.c" /* yacc.c:1645 */
break;
case 142:
-#line 1556 "awkgram.y" /* yacc.c:1645 */
+#line 1673 "awkgram.y" /* yacc.c:1645 */
{
int count = 2;
bool is_simple_var = false;
@@ -3639,47 +3797,47 @@ regular_print:
max_args = count;
}
}
-#line 3643 "awkgram.c" /* yacc.c:1645 */
+#line 3801 "awkgram.c" /* yacc.c:1645 */
break;
case 144:
-#line 1615 "awkgram.y" /* yacc.c:1645 */
+#line 1732 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3649 "awkgram.c" /* yacc.c:1645 */
+#line 3807 "awkgram.c" /* yacc.c:1645 */
break;
case 145:
-#line 1617 "awkgram.y" /* yacc.c:1645 */
+#line 1734 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3655 "awkgram.c" /* yacc.c:1645 */
+#line 3813 "awkgram.c" /* yacc.c:1645 */
break;
case 146:
-#line 1619 "awkgram.y" /* yacc.c:1645 */
+#line 1736 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3661 "awkgram.c" /* yacc.c:1645 */
+#line 3819 "awkgram.c" /* yacc.c:1645 */
break;
case 147:
-#line 1621 "awkgram.y" /* yacc.c:1645 */
+#line 1738 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3667 "awkgram.c" /* yacc.c:1645 */
+#line 3825 "awkgram.c" /* yacc.c:1645 */
break;
case 148:
-#line 1623 "awkgram.y" /* yacc.c:1645 */
+#line 1740 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3673 "awkgram.c" /* yacc.c:1645 */
+#line 3831 "awkgram.c" /* yacc.c:1645 */
break;
case 149:
-#line 1625 "awkgram.y" /* yacc.c:1645 */
+#line 1742 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3679 "awkgram.c" /* yacc.c:1645 */
+#line 3837 "awkgram.c" /* yacc.c:1645 */
break;
case 150:
-#line 1627 "awkgram.y" /* yacc.c:1645 */
+#line 1744 "awkgram.y" /* yacc.c:1645 */
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3693,29 +3851,29 @@ regular_print:
_("non-redirected `getline' undefined inside END action"));
(yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input);
}
-#line 3697 "awkgram.c" /* yacc.c:1645 */
+#line 3855 "awkgram.c" /* yacc.c:1645 */
break;
case 151:
-#line 1641 "awkgram.y" /* yacc.c:1645 */
+#line 1758 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postincrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3706 "awkgram.c" /* yacc.c:1645 */
+#line 3864 "awkgram.c" /* yacc.c:1645 */
break;
case 152:
-#line 1646 "awkgram.y" /* yacc.c:1645 */
+#line 1763 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postdecrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3715 "awkgram.c" /* yacc.c:1645 */
+#line 3873 "awkgram.c" /* yacc.c:1645 */
break;
case 153:
-#line 1651 "awkgram.y" /* yacc.c:1645 */
+#line 1768 "awkgram.y" /* yacc.c:1645 */
{
if (do_lint_old) {
warning_ln((yyvsp[-1])->source_line,
@@ -3735,64 +3893,64 @@ regular_print:
(yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3739 "awkgram.c" /* yacc.c:1645 */
+#line 3897 "awkgram.c" /* yacc.c:1645 */
break;
case 154:
-#line 1676 "awkgram.y" /* yacc.c:1645 */
+#line 1793 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type);
bcfree((yyvsp[-2]));
}
-#line 3748 "awkgram.c" /* yacc.c:1645 */
+#line 3906 "awkgram.c" /* yacc.c:1645 */
break;
case 155:
-#line 1682 "awkgram.y" /* yacc.c:1645 */
+#line 1799 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3754 "awkgram.c" /* yacc.c:1645 */
+#line 3912 "awkgram.c" /* yacc.c:1645 */
break;
case 156:
-#line 1684 "awkgram.y" /* yacc.c:1645 */
+#line 1801 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3760 "awkgram.c" /* yacc.c:1645 */
+#line 3918 "awkgram.c" /* yacc.c:1645 */
break;
case 157:
-#line 1686 "awkgram.y" /* yacc.c:1645 */
+#line 1803 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3766 "awkgram.c" /* yacc.c:1645 */
+#line 3924 "awkgram.c" /* yacc.c:1645 */
break;
case 158:
-#line 1688 "awkgram.y" /* yacc.c:1645 */
+#line 1805 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3772 "awkgram.c" /* yacc.c:1645 */
+#line 3930 "awkgram.c" /* yacc.c:1645 */
break;
case 159:
-#line 1690 "awkgram.y" /* yacc.c:1645 */
+#line 1807 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3778 "awkgram.c" /* yacc.c:1645 */
+#line 3936 "awkgram.c" /* yacc.c:1645 */
break;
case 160:
-#line 1692 "awkgram.y" /* yacc.c:1645 */
+#line 1809 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3784 "awkgram.c" /* yacc.c:1645 */
+#line 3942 "awkgram.c" /* yacc.c:1645 */
break;
case 161:
-#line 1697 "awkgram.y" /* yacc.c:1645 */
+#line 1814 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3792 "awkgram.c" /* yacc.c:1645 */
+#line 3950 "awkgram.c" /* yacc.c:1645 */
break;
case 162:
-#line 1701 "awkgram.y" /* yacc.c:1645 */
+#line 1818 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
@@ -3824,11 +3982,11 @@ regular_print:
}
}
}
-#line 3828 "awkgram.c" /* yacc.c:1645 */
+#line 3986 "awkgram.c" /* yacc.c:1645 */
break;
case 163:
-#line 1733 "awkgram.y" /* yacc.c:1645 */
+#line 1850 "awkgram.y" /* yacc.c:1645 */
{
// Always include. Allows us to lint warn on
// print "foo" > "bar" 1
@@ -3836,31 +3994,31 @@ regular_print:
// print "foo" > ("bar" 1)
(yyval) = list_append((yyvsp[-1]), bcalloc(Op_parens, 1, sourceline));
}
-#line 3840 "awkgram.c" /* yacc.c:1645 */
+#line 3998 "awkgram.c" /* yacc.c:1645 */
break;
case 164:
-#line 1741 "awkgram.y" /* yacc.c:1645 */
+#line 1858 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3850 "awkgram.c" /* yacc.c:1645 */
+#line 4008 "awkgram.c" /* yacc.c:1645 */
break;
case 165:
-#line 1747 "awkgram.y" /* yacc.c:1645 */
+#line 1864 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3860 "awkgram.c" /* yacc.c:1645 */
+#line 4018 "awkgram.c" /* yacc.c:1645 */
break;
case 166:
-#line 1753 "awkgram.y" /* yacc.c:1645 */
+#line 1870 "awkgram.y" /* yacc.c:1645 */
{
static bool warned = false;
@@ -3873,45 +4031,45 @@ regular_print:
if ((yyval) == NULL)
YYABORT;
}
-#line 3877 "awkgram.c" /* yacc.c:1645 */
+#line 4035 "awkgram.c" /* yacc.c:1645 */
break;
case 169:
-#line 1768 "awkgram.y" /* yacc.c:1645 */
+#line 1885 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[-1])->opcode = Op_preincrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3886 "awkgram.c" /* yacc.c:1645 */
+#line 4044 "awkgram.c" /* yacc.c:1645 */
break;
case 170:
-#line 1773 "awkgram.y" /* yacc.c:1645 */
+#line 1890 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[-1])->opcode = Op_predecrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3895 "awkgram.c" /* yacc.c:1645 */
+#line 4053 "awkgram.c" /* yacc.c:1645 */
break;
case 171:
-#line 1778 "awkgram.y" /* yacc.c:1645 */
+#line 1895 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3903 "awkgram.c" /* yacc.c:1645 */
+#line 4061 "awkgram.c" /* yacc.c:1645 */
break;
case 172:
-#line 1782 "awkgram.y" /* yacc.c:1645 */
+#line 1899 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3911 "awkgram.c" /* yacc.c:1645 */
+#line 4069 "awkgram.c" /* yacc.c:1645 */
break;
case 173:
-#line 1786 "awkgram.y" /* yacc.c:1645 */
+#line 1903 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & STRING) == 0
@@ -3926,11 +4084,11 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3930 "awkgram.c" /* yacc.c:1645 */
+#line 4088 "awkgram.c" /* yacc.c:1645 */
break;
case 174:
-#line 1801 "awkgram.y" /* yacc.c:1645 */
+#line 1918 "awkgram.y" /* yacc.c:1645 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & STRING) == 0
@@ -3948,20 +4106,20 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3952 "awkgram.c" /* yacc.c:1645 */
+#line 4110 "awkgram.c" /* yacc.c:1645 */
break;
case 175:
-#line 1822 "awkgram.y" /* yacc.c:1645 */
+#line 1939 "awkgram.y" /* yacc.c:1645 */
{
func_use((yyvsp[0])->lasti->func_name, FUNC_USE);
(yyval) = (yyvsp[0]);
}
-#line 3961 "awkgram.c" /* yacc.c:1645 */
+#line 4119 "awkgram.c" /* yacc.c:1645 */
break;
case 176:
-#line 1827 "awkgram.y" /* yacc.c:1645 */
+#line 1944 "awkgram.y" /* yacc.c:1645 */
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3995,11 +4153,11 @@ regular_print:
(yyval) = list_prepend((yyvsp[0]), t);
at_seen = false;
}
-#line 3999 "awkgram.c" /* yacc.c:1645 */
+#line 4157 "awkgram.c" /* yacc.c:1645 */
break;
case 177:
-#line 1864 "awkgram.y" /* yacc.c:1645 */
+#line 1981 "awkgram.y" /* yacc.c:1645 */
{
NODE *n;
@@ -4024,49 +4182,49 @@ regular_print:
(yyval) = list_append(t, (yyvsp[-3]));
}
}
-#line 4028 "awkgram.c" /* yacc.c:1645 */
+#line 4186 "awkgram.c" /* yacc.c:1645 */
break;
case 178:
-#line 1892 "awkgram.y" /* yacc.c:1645 */
+#line 2009 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4034 "awkgram.c" /* yacc.c:1645 */
+#line 4192 "awkgram.c" /* yacc.c:1645 */
break;
case 179:
-#line 1894 "awkgram.y" /* yacc.c:1645 */
+#line 2011 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4040 "awkgram.c" /* yacc.c:1645 */
+#line 4198 "awkgram.c" /* yacc.c:1645 */
break;
case 180:
-#line 1899 "awkgram.y" /* yacc.c:1645 */
+#line 2016 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4046 "awkgram.c" /* yacc.c:1645 */
+#line 4204 "awkgram.c" /* yacc.c:1645 */
break;
case 181:
-#line 1901 "awkgram.y" /* yacc.c:1645 */
+#line 2018 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 4052 "awkgram.c" /* yacc.c:1645 */
+#line 4210 "awkgram.c" /* yacc.c:1645 */
break;
case 182:
-#line 1906 "awkgram.y" /* yacc.c:1645 */
+#line 2023 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4058 "awkgram.c" /* yacc.c:1645 */
+#line 4216 "awkgram.c" /* yacc.c:1645 */
break;
case 183:
-#line 1908 "awkgram.y" /* yacc.c:1645 */
+#line 2025 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 4066 "awkgram.c" /* yacc.c:1645 */
+#line 4224 "awkgram.c" /* yacc.c:1645 */
break;
case 184:
-#line 1915 "awkgram.y" /* yacc.c:1645 */
+#line 2032 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip = (yyvsp[0])->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated expressions */
@@ -4080,11 +4238,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
(yyval) = (yyvsp[0]);
}
-#line 4084 "awkgram.c" /* yacc.c:1645 */
+#line 4242 "awkgram.c" /* yacc.c:1645 */
break;
case 185:
-#line 1932 "awkgram.y" /* yacc.c:1645 */
+#line 2049 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *t = (yyvsp[-1]);
if ((yyvsp[-1]) == NULL) {
@@ -4098,31 +4256,31 @@ regular_print:
(yyvsp[0])->sub_count = count_expressions(&t, false);
(yyval) = list_append(t, (yyvsp[0]));
}
-#line 4102 "awkgram.c" /* yacc.c:1645 */
+#line 4260 "awkgram.c" /* yacc.c:1645 */
break;
case 186:
-#line 1949 "awkgram.y" /* yacc.c:1645 */
+#line 2066 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); }
-#line 4108 "awkgram.c" /* yacc.c:1645 */
+#line 4266 "awkgram.c" /* yacc.c:1645 */
break;
case 187:
-#line 1951 "awkgram.y" /* yacc.c:1645 */
+#line 2068 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 4116 "awkgram.c" /* yacc.c:1645 */
+#line 4274 "awkgram.c" /* yacc.c:1645 */
break;
case 188:
-#line 1958 "awkgram.y" /* yacc.c:1645 */
+#line 2075 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[-1]); }
-#line 4122 "awkgram.c" /* yacc.c:1645 */
+#line 4280 "awkgram.c" /* yacc.c:1645 */
break;
case 189:
-#line 1963 "awkgram.y" /* yacc.c:1645 */
+#line 2080 "awkgram.y" /* yacc.c:1645 */
{
char *var_name = (yyvsp[0])->lextok;
@@ -4130,22 +4288,22 @@ regular_print:
(yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new);
(yyval) = list_create((yyvsp[0]));
}
-#line 4134 "awkgram.c" /* yacc.c:1645 */
+#line 4292 "awkgram.c" /* yacc.c:1645 */
break;
case 190:
-#line 1971 "awkgram.y" /* yacc.c:1645 */
+#line 2088 "awkgram.y" /* yacc.c:1645 */
{
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 4145 "awkgram.c" /* yacc.c:1645 */
+#line 4303 "awkgram.c" /* yacc.c:1645 */
break;
case 191:
-#line 1981 "awkgram.y" /* yacc.c:1645 */
+#line 2098 "awkgram.y" /* yacc.c:1645 */
{
INSTRUCTION *ip = (yyvsp[0])->nexti;
if (ip->opcode == Op_push
@@ -4157,73 +4315,85 @@ regular_print:
} else
(yyval) = (yyvsp[0]);
}
-#line 4161 "awkgram.c" /* yacc.c:1645 */
+#line 4319 "awkgram.c" /* yacc.c:1645 */
break;
case 192:
-#line 1993 "awkgram.y" /* yacc.c:1645 */
+#line 2110 "awkgram.y" /* yacc.c:1645 */
{
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
if ((yyvsp[0]) != NULL)
mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 4171 "awkgram.c" /* yacc.c:1645 */
+#line 4329 "awkgram.c" /* yacc.c:1645 */
break;
case 193:
-#line 2002 "awkgram.y" /* yacc.c:1645 */
+#line 2119 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postincrement;
}
-#line 4179 "awkgram.c" /* yacc.c:1645 */
+#line 4337 "awkgram.c" /* yacc.c:1645 */
break;
case 194:
-#line 2006 "awkgram.y" /* yacc.c:1645 */
+#line 2123 "awkgram.y" /* yacc.c:1645 */
{
(yyvsp[0])->opcode = Op_postdecrement;
}
-#line 4187 "awkgram.c" /* yacc.c:1645 */
+#line 4345 "awkgram.c" /* yacc.c:1645 */
break;
case 195:
-#line 2009 "awkgram.y" /* yacc.c:1645 */
+#line 2127 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = NULL; }
-#line 4193 "awkgram.c" /* yacc.c:1645 */
+#line 4351 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 196:
+#line 2131 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); }
+#line 4357 "awkgram.c" /* yacc.c:1645 */
break;
case 197:
-#line 2017 "awkgram.y" /* yacc.c:1645 */
- { yyerrok; }
-#line 4199 "awkgram.c" /* yacc.c:1645 */
+#line 2135 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); yyerrok; }
+#line 4363 "awkgram.c" /* yacc.c:1645 */
break;
case 198:
-#line 2021 "awkgram.y" /* yacc.c:1645 */
+#line 2139 "awkgram.y" /* yacc.c:1645 */
{ yyerrok; }
-#line 4205 "awkgram.c" /* yacc.c:1645 */
+#line 4369 "awkgram.c" /* yacc.c:1645 */
+ break;
+
+ case 199:
+#line 2144 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = NULL; }
+#line 4375 "awkgram.c" /* yacc.c:1645 */
break;
case 201:
-#line 2030 "awkgram.y" /* yacc.c:1645 */
+#line 2149 "awkgram.y" /* yacc.c:1645 */
{ yyerrok; }
-#line 4211 "awkgram.c" /* yacc.c:1645 */
+#line 4381 "awkgram.c" /* yacc.c:1645 */
break;
case 202:
-#line 2034 "awkgram.y" /* yacc.c:1645 */
+#line 2153 "awkgram.y" /* yacc.c:1645 */
{ (yyval) = (yyvsp[0]); yyerrok; }
-#line 4217 "awkgram.c" /* yacc.c:1645 */
+#line 4387 "awkgram.c" /* yacc.c:1645 */
break;
case 203:
-#line 2038 "awkgram.y" /* yacc.c:1645 */
- { yyerrok; }
-#line 4223 "awkgram.c" /* yacc.c:1645 */
+#line 2157 "awkgram.y" /* yacc.c:1645 */
+ { (yyval) = (yyvsp[0]); yyerrok; }
+#line 4393 "awkgram.c" /* yacc.c:1645 */
break;
-#line 4227 "awkgram.c" /* yacc.c:1645 */
+#line 4397 "awkgram.c" /* yacc.c:1645 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4450,7 +4620,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 2040 "awkgram.y" /* yacc.c:1903 */
+#line 2159 "awkgram.y" /* yacc.c:1903 */
struct token {
@@ -4529,8 +4699,8 @@ static const struct token tokentab[] = {
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
{"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
-{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
-{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
+{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
+{"function", Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0, 0},
{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0, 0},
{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0, 0},
@@ -4889,11 +5059,12 @@ mk_program()
cp = end_block;
else
cp = list_merge(begin_block, end_block);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
- if (comment != NULL)
- (void) list_append(cp, comment);
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -4926,12 +5097,16 @@ mk_program()
if (begin_block != NULL)
cp = list_merge(begin_block, cp);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+ if (outer_comment != NULL) {
+ cp = list_merge(list_create(outer_comment), cp);
+ outer_comment = NULL;
}
- if (comment != NULL) {
- (void) list_append(cp, comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -4939,10 +5114,6 @@ out:
/* delete the Op_list, not needed */
tmp = cp->nexti;
bcfree(cp);
- /* these variables are not used again but zap them anyway. */
- comment = NULL;
- function_comment = NULL;
- program_comment = NULL;
return tmp;
#undef begin_block
@@ -5117,33 +5288,35 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
/* include_source --- read program from source included using `@include' */
-static int
-include_source(INSTRUCTION *file)
+static bool
+include_source(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@include is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @include"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open source file `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
/* save scanner state for the current sourcefile */
@@ -5162,42 +5335,53 @@ include_source(INSTRUCTION *file)
lasttok = 0;
lexeof = false;
eof_warned = false;
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* load_library --- load a shared library */
-static int
-load_library(INSTRUCTION *file)
+static bool
+load_library(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@load is a gawk extension"));
- return -1;
+ return false;
}
+
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @load"));
- return 0;
+ return true;
}
- s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
- if (s == NULL) {
- if (already_included)
- return 0;
- error_ln(file->source_line,
- _("can't open shared library `%s' for reading (%s)"),
- src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ if (do_pretty_print && ! do_profile) {
+ // create a fake one, don't try to open the file
+ s = do_add_srcfile(SRC_EXTLIB, src, src, sourcefile);
+ } else {
+ s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
+ if (s == NULL) {
+ if (already_included)
+ return true;
+ error_ln(file->source_line,
+ _("can't open shared library `%s' for reading (%s)"),
+ src, errcode ? strerror(errcode) : _("reason unknown"));
+ return false;
+ }
+
+ load_ext(s->fullpath);
}
- load_ext(s->fullpath);
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* next_sourcefile --- read program from the next source in srcfiles */
@@ -5605,37 +5789,23 @@ pushback(void)
(! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
}
-/* check_comment --- check for block comment */
-
-void
-check_comment(void)
-{
- if (comment != NULL) {
- if (first_rule) {
- program_comment = comment;
- } else
- block_comment = comment;
- comment = NULL;
- }
- first_rule = false;
-}
-
/*
* get_comment --- collect comment text.
* Flag = EOL_COMMENT for end-of-line comments.
- * Flag = FULL_COMMENT for self-contained comments.
+ * Flag = BLOCK_COMMENT for self-contained comments.
*/
-int
-get_comment(int flag)
+static int
+get_comment(enum commenttype flag, INSTRUCTION **comment_instruction)
{
int c;
int sl;
+ char *p1;
+ char *p2;
+
tok = tokstart;
tokadd('#');
sl = sourceline;
- char *p1;
- char *p2;
while (true) {
while ((c = nextc(false)) != '\n' && c != END_FILE) {
@@ -5671,9 +5841,6 @@ get_comment(int flag)
break;
}
- if (comment != NULL)
- prior_comment = comment;
-
/* remove any trailing blank lines (consecutive \n) from comment */
p1 = tok - 1;
p2 = tok - 2;
@@ -5683,49 +5850,18 @@ get_comment(int flag)
tok--;
}
- comment = bcalloc(Op_comment, 1, sl);
- comment->source_file = source;
- comment->memory = make_str_node(tokstart, tok - tokstart, 0);
- comment->memory->comment_type = flag;
+ (*comment_instruction) = bcalloc(Op_comment, 1, sl);
+ (*comment_instruction)->source_file = source;
+ (*comment_instruction)->memory = make_str_node(tokstart, tok - tokstart, 0);
+ (*comment_instruction)->memory->comment_type = flag;
return c;
}
-/* split_comment --- split initial comment text into program and function parts */
-
-static void
-split_comment(void)
-{
- char *p;
- int l;
- NODE *n;
-
- p = comment_to_save->memory->stptr;
- l = comment_to_save->memory->stlen - 3;
- /* have at least two comments so split at last blank line (\n\n) */
- while (l >= 0) {
- if (p[l] == '\n' && p[l+1] == '\n') {
- function_comment = comment_to_save;
- n = function_comment->memory;
- function_comment->memory = make_string(p + l + 2, n->stlen - l - 2);
- /* create program comment */
- program_comment = bcalloc(Op_comment, 1, sourceline);
- program_comment->source_file = comment_to_save->source_file;
- p[l + 2] = 0;
- program_comment->memory = make_str_node(p, l + 2, 0);
- comment_to_save = NULL;
- freenode(n);
- break;
- }
- else
- l--;
- }
-}
-
/* allow_newline --- allow newline after &&, ||, ? and : */
static void
-allow_newline(void)
+allow_newline(INSTRUCTION **new_comment)
{
int c;
@@ -5737,8 +5873,8 @@ allow_newline(void)
}
if (c == '#') {
if (do_pretty_print && ! do_profile) {
- /* collect comment byte code iff doing pretty print but not profiling. */
- c = get_comment(EOL_COMMENT);
+ /* collect comment byte code iff doing pretty print but not profiling. */
+ c = get_comment(EOL_COMMENT, new_comment);
} else {
while ((c = nextc(false)) != '\n' && c != END_FILE)
continue;
@@ -5805,6 +5941,7 @@ yylex(void)
bool intlstr = false;
AWKNUM d;
bool collecting_typed_regexp = false;
+ static int qm_col_count = 0;
#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline)
@@ -5969,18 +6106,25 @@ retry:
return lasttok = NEWLINE;
case '#': /* it's a comment */
+ yylval = NULL;
if (do_pretty_print && ! do_profile) {
/*
* Collect comment byte code iff doing pretty print
* but not profiling.
*/
+ INSTRUCTION *new_comment;
+
if (lasttok == NEWLINE || lasttok == 0)
- c = get_comment(FULL_COMMENT);
+ c = get_comment(BLOCK_COMMENT, & new_comment);
else
- c = get_comment(EOL_COMMENT);
+ c = get_comment(EOL_COMMENT, & new_comment);
- if (c == END_FILE)
- return lasttok = NEWLINE_EOF;
+ yylval = new_comment;
+
+ if (c == END_FILE) {
+ pushback();
+ return lasttok = NEWLINE;
+ }
} else {
while ((c = nextc(false)) != '\n') {
if (c == END_FILE)
@@ -6009,7 +6153,10 @@ retry:
* Use it at your own risk. We think it's a bad idea, which
* is why it's not on by default.
*/
+ yylval = NULL;
if (! do_traditional) {
+ INSTRUCTION *new_comment;
+
/* strip trailing white-space and/or comment */
while ((c = nextc(true)) == ' ' || c == '\t' || c == '\r')
continue;
@@ -6021,9 +6168,11 @@ retry:
lintwarn(
_("use of `\\ #...' line continuation is not portable"));
}
- if (do_pretty_print && ! do_profile)
- c = get_comment(EOL_COMMENT);
- else {
+ if (do_pretty_print && ! do_profile) {
+ c = get_comment(EOL_COMMENT, & new_comment);
+ yylval = new_comment;
+ return lasttok = c;
+ } else {
while ((c = nextc(false)) != '\n')
if (c == END_FILE)
break;
@@ -6044,11 +6193,20 @@ retry:
}
break;
- case ':':
case '?':
+ qm_col_count++;
+ // fall through
+ case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (! do_posix)
- allow_newline();
+ if (qm_col_count > 0) {
+ if (! do_posix) {
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+ }
+ if (c == ':')
+ qm_col_count--;
+ }
return lasttok = c;
/*
@@ -6470,7 +6628,10 @@ retry:
case '&':
if ((c = nextc(true)) == '&') {
yylval = GET_INSTRUCTION(Op_and);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_AND;
}
pushback();
@@ -6480,11 +6641,15 @@ retry:
case '|':
if ((c = nextc(true)) == '|') {
yylval = GET_INSTRUCTION(Op_or);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_OR;
} else if (! do_traditional && c == '&') {
yylval = GET_INSTRUCTION(Op_symbol);
yylval->redir_type = redirect_twoway;
+
return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN);
}
pushback();
@@ -6674,8 +6839,11 @@ out:
yylval->lextok = tokkey;
#define SMART_ALECK 1
- if (SMART_ALECK && do_lint
- && ! goto_warned && strcasecmp(tokkey, "goto") == 0) {
+ if (SMART_ALECK
+ && do_lint
+ && ! goto_warned
+ && tolower(tokkey[0]) == 'g'
+ && strcasecmp(tokkey, "goto") == 0) {
goto_warned = true;
lintwarn(_("`goto' considered harmful!"));
}
@@ -7148,13 +7316,15 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
/* add any pre-function comment to start of action for profile.c */
- if (function_comment != NULL) {
- function_comment->source_line = 0;
- (void) list_prepend(def, function_comment);
- function_comment = NULL;
+ if (interblock_comment != NULL) {
+ interblock_comment->source_line = 0;
+ merge_comments(interblock_comment, fi->comment);
+ fi->comment = interblock_comment;
+ interblock_comment = NULL;
}
- /* add an implicit return at end;
+ /*
+ * Add an implicit return at end;
* also used by 'return' command in debugger
*/
@@ -7162,6 +7332,11 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
def->lasti->memory = dupnode(Nnull_string);
(void) list_append(def, instruction(Op_K_return));
+ if (trailing_comment != NULL) {
+ (void) list_append(def, trailing_comment);
+ trailing_comment = NULL;
+ }
+
if (do_pretty_print)
(void) list_prepend(def, instruction(Op_exec_count));
@@ -7865,12 +8040,11 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 1)->lasti = action->lasti;
(rp + 2)->first_line = pattern->source_line;
(rp + 2)->last_line = lastline;
- if (block_comment != NULL) {
- ip = list_prepend(list_prepend(action, block_comment), rp);
- block_comment = NULL;
- } else
- ip = list_prepend(action, rp);
-
+ ip = list_prepend(action, rp);
+ if (interblock_comment != NULL) {
+ ip = list_prepend(ip, interblock_comment);
+ interblock_comment = NULL;
+ }
} else {
rp = bcalloc(Op_rule, 3, 0);
rp->in_rule = Rule;
@@ -7896,14 +8070,20 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 2)->last_line = find_line(pattern, LAST_LINE);
action = list_create(instruction(Op_K_print_rec));
if (do_pretty_print)
- (void) list_prepend(action, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
} else
(rp + 2)->last_line = lastline;
+ if (interblock_comment != NULL) { // was after previous action
+ pattern = list_prepend(pattern, interblock_comment);
+ interblock_comment = NULL;
+ }
+
if (do_pretty_print) {
- (void) list_prepend(pattern, instruction(Op_exec_count));
- (void) list_prepend(action, instruction(Op_exec_count));
+ pattern = list_prepend(pattern, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
}
+
(rp + 1)->firsti = action->nexti;
(rp + 1)->lasti = tp;
ip = list_append(
@@ -8275,8 +8455,9 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond,
forp->target_break = tbreak;
forp->target_continue = tcont;
ret = list_prepend(ret, forp);
- } /* else
- forp is NULL */
+ }
+ /* else
+ forp is NULL */
return ret;
}
@@ -8490,26 +8671,6 @@ list_merge(INSTRUCTION *l1, INSTRUCTION *l2)
return l1;
}
-/* add_pending_comment --- add a pending comment to a statement */
-
-static inline INSTRUCTION *
-add_pending_comment(INSTRUCTION *stmt)
-{
- INSTRUCTION *ret = stmt;
-
- if (prior_comment != NULL) {
- if (function_comment != prior_comment)
- ret = list_append(stmt, prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL && comment->memory->comment_type == EOL_COMMENT) {
- if (function_comment != comment)
- ret = list_append(stmt, comment);
- comment = NULL;
- }
-
- return ret;
-}
-
/* See if name is a special token. */
int
@@ -8749,3 +8910,91 @@ set_profile_text(NODE *n, const char *str, size_t len)
return n;
}
+
+/*
+ * merge_comments --- merge c2 into c1 and free c2 if successful.
+ * Allow c2 to be NULL, in which case just merged chained
+ * comments in c1.
+ */
+
+static void
+merge_comments(INSTRUCTION *c1, INSTRUCTION *c2)
+{
+ assert(c1->opcode == Op_comment);
+
+ if (c1->comment == NULL && c2 == NULL) // nothing to do
+ return;
+
+ size_t total = c1->memory->stlen;
+ if (c1->comment != NULL)
+ total += 1 /* \n */ + c1->comment->memory->stlen;
+
+ if (c2 != NULL) {
+ assert(c2->opcode == Op_comment);
+ total += 1 /* \n */ + c2->memory->stlen;
+ if (c2->comment != NULL)
+ total += c2->comment->memory->stlen + 1;
+ }
+
+ char *buffer;
+ emalloc(buffer, char *, total + 1, "merge_comments");
+
+ strcpy(buffer, c1->memory->stptr);
+ if (c1->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c1->comment->memory->stptr);
+ }
+
+ if (c2 != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->memory->stptr);
+ if (c2->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->comment->memory->stptr);
+ }
+
+ unref(c2->memory);
+ if (c2->comment != NULL) {
+ unref(c2->comment->memory);
+ bcfree(c2->comment);
+ c2->comment = NULL;
+ }
+ bcfree(c2);
+ }
+
+ c1->memory->comment_type = BLOCK_COMMENT;
+ free(c1->memory->stptr);
+ c1->memory->stptr = buffer;
+ c1->memory->stlen = strlen(buffer);
+
+ // now free everything else
+ if (c1->comment != NULL) {
+ unref(c1->comment->memory);
+ bcfree(c1->comment);
+ c1->comment = NULL;
+ }
+}
+
+/* make_braced_statements --- handle `l_brace statements r_brace' with comments */
+
+static INSTRUCTION *
+make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace)
+{
+ INSTRUCTION *ip;
+
+ if (stmts == NULL)
+ ip = list_create(instruction(Op_no_op));
+ else
+ ip = stmts;
+
+ if (lbrace != NULL) {
+ INSTRUCTION *comment2 = lbrace->comment;
+ if (comment2 != NULL) {
+ ip = list_prepend(ip, comment2);
+ lbrace->comment = NULL;
+ }
+ ip = list_prepend(ip, lbrace);
+ }
+
+ return ip;
+}
diff --git a/awkgram.y b/awkgram.y
index 1afad27e..41876301 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -53,11 +53,28 @@ static int isnoeffect(OPCODE type);
static INSTRUCTION *make_assignable(INSTRUCTION *ip);
static void dumpintlstr(const char *str, size_t len);
static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2);
-static int include_source(INSTRUCTION *file);
-static int load_library(INSTRUCTION *file);
+static bool include_source(INSTRUCTION *file, void **srcfile_p);
+static bool load_library(INSTRUCTION *file, void **srcfile_p);
static void next_sourcefile(void);
static char *tokexpand(void);
static NODE *set_profile_text(NODE *n, const char *str, size_t len);
+static INSTRUCTION *trailing_comment;
+static INSTRUCTION *outer_comment;
+static INSTRUCTION *interblock_comment;
+static INSTRUCTION *pending_comment;
+
+#ifdef DEBUG_COMMENTS
+static void
+debug_print_comment_s(const char *name, INSTRUCTION *comment, int line)
+{
+ if (comment != NULL)
+ fprintf(stderr, "%d: %s: <%.*s>\n", line, name,
+ (int) (comment->memory->stlen - 1),
+ comment->memory->stptr);
+}
+#define debug_print_comment(comment) \
+ debug_print_comment_s(# comment, comment, __LINE__)
+#endif
#define instruction(t) bcalloc(t, 1, 0)
@@ -84,8 +101,8 @@ static void check_funcs(void);
static ssize_t read_one_line(int fd, void *buffer, size_t count);
static int one_line_close(int fd);
-static void split_comment(void);
-static void check_comment(void);
+static void merge_comments(INSTRUCTION *c1, INSTRUCTION *c2);
+static INSTRUCTION *make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace);
static void add_sign_to_num(NODE *n, char sign);
static bool at_seen = false;
@@ -152,21 +169,10 @@ static INSTRUCTION *ip_endfile;
static INSTRUCTION *ip_beginfile;
INSTRUCTION *main_beginfile;
-static INSTRUCTION *comment = NULL;
-static INSTRUCTION *prior_comment = NULL;
-static INSTRUCTION *comment_to_save = NULL;
-static INSTRUCTION *program_comment = NULL;
-static INSTRUCTION *function_comment = NULL;
-static INSTRUCTION *block_comment = NULL;
-
-static bool func_first = true;
-static bool first_rule = true;
-
static inline INSTRUCTION *list_create(INSTRUCTION *x);
static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x);
static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2);
-static inline INSTRUCTION *add_pending_comment(INSTRUCTION *stmt);
extern double fmod(double x, double y);
@@ -214,12 +220,22 @@ extern double fmod(double x, double y);
program
: /* empty */
+ { $$ = NULL; }
| program rule
{
rule = 0;
yyerrok;
}
| program nls
+ {
+ if ($2 != NULL) {
+ if ($1 == NULL)
+ outer_comment = $2;
+ else
+ interblock_comment = $2;
+ }
+ $$ = $1;
+ }
| program LEX_EOF
{
next_sourcefile();
@@ -239,7 +255,10 @@ rule
: pattern action
{
(void) append_rule($1, $2);
- first_rule = false;
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
}
| pattern statement_term
{
@@ -249,26 +268,41 @@ rule
} else if ($1 == NULL) {
msg(_("each rule must have a pattern or an action part"));
errcount++;
- } else /* pattern rule with non-empty pattern */
+ } else { /* pattern rule with non-empty pattern */
+ if ($2 != NULL)
+ list_append($1, $2);
(void) append_rule($1, NULL);
+ }
}
| function_prologue action
{
in_function = NULL;
(void) mk_function($1, $2);
want_param_names = DONT_CHECK;
+ if (pending_comment != NULL) {
+ interblock_comment = pending_comment;
+ pending_comment = NULL;
+ }
yyerrok;
}
| '@' LEX_INCLUDE source statement_term
{
want_source = false;
at_seen = false;
+ if ($3 != NULL && $4 != NULL) {
+ SRCFILE *s = (SRCFILE *) $3;
+ s->comment = $4;
+ }
yyerrok;
}
| '@' LEX_LOAD library statement_term
{
want_source = false;
at_seen = false;
+ if ($3 != NULL && $4 != NULL) {
+ SRCFILE *s = (SRCFILE *) $3;
+ s->comment = $4;
+ }
yyerrok;
}
;
@@ -276,11 +310,13 @@ rule
source
: FILENAME
{
- if (include_source($1) < 0)
+ void *srcfile = NULL;
+
+ if (! include_source($1, & srcfile))
YYABORT;
efree($1->lextok);
bcfree($1);
- $$ = NULL;
+ $$ = (INSTRUCTION *) srcfile;
}
| FILENAME error
{ $$ = NULL; }
@@ -291,11 +327,13 @@ source
library
: FILENAME
{
- if (load_library($1) < 0)
+ void *srcfile;
+
+ if (! load_library($1, & srcfile))
YYABORT;
efree($1->lextok);
bcfree($1);
- $$ = NULL;
+ $$ = (INSTRUCTION *) srcfile;
}
| FILENAME error
{ $$ = NULL; }
@@ -307,94 +345,77 @@ pattern
: /* empty */
{
rule = Rule;
- if (comment != NULL) {
- $$ = list_create(comment);
- comment = NULL;
- } else
- $$ = NULL;
+ $$ = NULL;
}
| exp
{
rule = Rule;
- if (comment != NULL) {
- $$ = list_prepend($1, comment);
- comment = NULL;
- } else
- $$ = $1;
}
- | exp ',' opt_nls exp
+ | exp comma exp
{
INSTRUCTION *tp;
add_lint($1, LINT_assign_in_cond);
- add_lint($4, LINT_assign_in_cond);
+ add_lint($3, LINT_assign_in_cond);
tp = instruction(Op_no_op);
list_prepend($1, bcalloc(Op_line_range, !!do_pretty_print + 1, 0));
$1->nexti->triggered = false;
- $1->nexti->target_jmp = $4->nexti;
+ $1->nexti->target_jmp = $3->nexti;
list_append($1, instruction(Op_cond_pair));
$1->lasti->line_range = $1->nexti;
$1->lasti->target_jmp = tp;
- list_append($4, instruction(Op_cond_pair));
- $4->lasti->line_range = $1->nexti;
- $4->lasti->target_jmp = tp;
+ list_append($3, instruction(Op_cond_pair));
+ $3->lasti->line_range = $1->nexti;
+ $3->lasti->target_jmp = tp;
if (do_pretty_print) {
($1->nexti + 1)->condpair_left = $1->lasti;
- ($1->nexti + 1)->condpair_right = $4->lasti;
+ ($1->nexti + 1)->condpair_right = $3->lasti;
}
- if (comment != NULL) {
- $$ = list_append(list_merge(list_prepend($1, comment), $4), tp);
- comment = NULL;
- } else
- $$ = list_append(list_merge($1, $4), tp);
+ /* Put any comments in front of the range expression */
+ if ($2 != NULL)
+ $$ = list_append(list_merge(list_prepend($1, $2), $3), tp);
+ else
+ $$ = list_append(list_merge($1, $3), tp);
rule = Rule;
}
| LEX_BEGIN
{
static int begin_seen = 0;
- func_first = false;
if (do_lint_old && ++begin_seen == 2)
warning_ln($1->source_line,
_("old awk does not support multiple `BEGIN' or `END' rules"));
$1->in_rule = rule = BEGIN;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_END
{
static int end_seen = 0;
- func_first = false;
if (do_lint_old && ++end_seen == 2)
warning_ln($1->source_line,
_("old awk does not support multiple `BEGIN' or `END' rules"));
$1->in_rule = rule = END;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_BEGINFILE
{
- func_first = false;
$1->in_rule = rule = BEGINFILE;
$1->source_file = source;
- check_comment();
$$ = $1;
}
| LEX_ENDFILE
{
- func_first = false;
$1->in_rule = rule = ENDFILE;
$1->source_file = source;
- check_comment();
$$ = $1;
}
;
@@ -402,11 +423,17 @@ pattern
action
: l_brace statements r_brace opt_semi opt_nls
{
- INSTRUCTION *ip;
- if ($2 == NULL)
- ip = list_create(instruction(Op_no_op));
- else
- ip = $2;
+ INSTRUCTION *ip = make_braced_statements($1, $2, $3);
+
+ if ($3 != NULL && $5 != NULL) {
+ merge_comments($3, $5);
+ pending_comment = $3;
+ } else if ($3 != NULL) {
+ pending_comment = $3;
+ } else if ($5 != NULL) {
+ pending_comment = $5;
+ }
+
$$ = ip;
}
;
@@ -437,33 +464,21 @@ lex_builtin
function_prologue
: LEX_FUNCTION func_name '(' { want_param_names = FUNC_HEADER; } opt_param_list r_paren opt_nls
{
- /*
- * treat any comments between BOF and the first function
- * definition (with no intervening BEGIN etc block) as
- * program comments. Special kludge: iff there are more
- * than one such comments, treat the last as a function
- * comment.
- */
- if (prior_comment != NULL) {
- comment_to_save = prior_comment;
- prior_comment = NULL;
- } else if (comment != NULL) {
- comment_to_save = comment;
- comment = NULL;
- } else
- comment_to_save = NULL;
-
- if (comment_to_save != NULL && func_first
- && strstr(comment_to_save->memory->stptr, "\n\n") != NULL)
- split_comment();
-
- /* save any other pre-function comment as function comment */
- if (comment_to_save != NULL) {
- function_comment = comment_to_save;
- comment_to_save = NULL;
+ INSTRUCTION *func_comment = NULL;
+ // Merge any comments found in the parameter list with those
+ // following the function header, associate the whole shebang
+ // with the function as one block comment.
+ if ($5 != NULL && $5->comment != NULL) {
+ if ($7 != NULL) {
+ merge_comments($5->comment, $7);
+ }
+ func_comment = $5->comment;
+ } else if ($7 != NULL) {
+ func_comment = $7;
}
- func_first = false;
+
$1->source_file = source;
+ $1->comment = func_comment;
if (install_function($2->lextok, $1, $5) < 0)
YYABORT;
in_function = $2->lextok;
@@ -536,61 +551,25 @@ a_slash
statements
: /* empty */
- {
- if (prior_comment != NULL) {
- $$ = list_create(prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL) {
- $$ = list_create(comment);
- comment = NULL;
- } else
- $$ = NULL;
- }
+ { $$ = NULL; }
| statements statement
{
if ($2 == NULL) {
- if (prior_comment != NULL) {
- $$ = list_append($1, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- $$ = list_append($$, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- $$ = list_append($1, comment);
- comment = NULL;
- } else
- $$ = $1;
+ $$ = $1;
} else {
add_lint($2, LINT_no_effect);
if ($1 == NULL) {
- if (prior_comment != NULL) {
- $$ = list_append($2, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- $$ = list_append($$, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- $$ = list_append($2, comment);
- comment = NULL;
- } else
- $$ = $2;
+ $$ = $2;
} else {
- if (prior_comment != NULL) {
- list_append($2, prior_comment);
- prior_comment = NULL;
- if (comment != NULL) {
- list_append($2, comment);
- comment = NULL;
- }
- } else if (comment != NULL) {
- list_append($2, comment);
- comment = NULL;
- }
$$ = list_merge($1, $2);
}
}
+
+ if (trailing_comment != NULL) {
+ $$ = list_append($$, trailing_comment);
+ trailing_comment = NULL;
+ }
+
yyerrok;
}
| statements error
@@ -598,15 +577,27 @@ statements
;
statement_term
- : nls
- | semi opt_nls
+ : nls { $$ = $1; }
+ | semi opt_nls { $$ = $2; }
;
statement
: semi opt_nls
- { $$ = NULL; }
+ {
+ if ($2 != NULL) {
+ INSTRUCTION *ip;
+
+ merge_comments($2, NULL);
+ ip = list_create(instruction(Op_no_op));
+ $$ = list_append(ip, $2);
+ } else
+ $$ = NULL;
+ }
| l_brace statements r_brace
- { $$ = $2; }
+ {
+ trailing_comment = $3; // NULL or comment
+ $$ = make_braced_statements($1, $2, $3);
+ }
| if_statement
{
if (do_pretty_print)
@@ -632,8 +623,9 @@ statement
if ($7 != NULL) {
curr = $7->nexti;
bcfree($7); /* Op_list */
- } /* else
- curr = NULL; */
+ }
+ /* else
+ curr = NULL; */
for (; curr != NULL; curr = nextc) {
INSTRUCTION *caseexp = curr->case_exp;
@@ -689,16 +681,33 @@ statement
ip = $3;
if (do_pretty_print) {
+ // first merge comments
+ INSTRUCTION *head_comment = NULL;
+
+ if ($5 != NULL && $6 != NULL) {
+ merge_comments($5, $6);
+ head_comment = $5;
+ } else if ($5 != NULL)
+ head_comment = $5;
+ else
+ head_comment = $6;
+
+ $1->comment = head_comment;
+
(void) list_prepend(ip, $1);
(void) list_prepend(ip, instruction(Op_exec_count));
$1->target_break = tbreak;
($1 + 1)->switch_start = cexp->nexti;
($1 + 1)->switch_end = cexp->lasti;
- }/* else
- $1 is NULL */
+ ($1 + 1)->switch_end->comment = $9;
+ }
+ /* else
+ $1 is NULL */
(void) list_append(cexp, dflt);
(void) list_merge(ip, cexp);
+ if ($8 != NULL)
+ (void) list_append(cstmt, $8);
$$ = list_merge(ip, cstmt);
break_allowed--;
@@ -733,8 +742,17 @@ statement
$1->target_continue = tcont;
($1 + 1)->while_body = ip->lasti;
(void) list_prepend(ip, $1);
- }/* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
+
+ if ($5 != NULL) {
+ if ($6 == NULL)
+ $6 = list_create(instruction(Op_no_op));
+
+ $5->memory->comment_type = BLOCK_COMMENT;
+ $6 = list_prepend($6, $5);
+ }
if ($6 != NULL)
(void) list_merge(ip, $6);
@@ -769,8 +787,13 @@ statement
ip = list_merge($3, $6);
else
ip = list_prepend($6, instruction(Op_no_op));
+
+ if ($2 != NULL)
+ (void) list_prepend(ip, $2);
+
if (do_pretty_print)
(void) list_prepend(ip, instruction(Op_exec_count));
+
(void) list_append(ip, instruction(Op_jmp_true));
ip->lasti->target_jmp = ip->nexti;
$$ = list_append(ip, tbreak);
@@ -785,7 +808,10 @@ statement
($1 + 1)->doloop_cond = tcont;
$$ = list_prepend(ip, $1);
bcfree($4);
- } /* else
+ if ($8 != NULL)
+ $1->comment = $8;
+ }
+ /* else
$1 and $4 are NULLs */
}
| LEX_FOR '(' NAME LEX_IN simple_variable r_paren opt_nls statement
@@ -801,7 +827,8 @@ statement
&& strcmp($8->nexti->memory->vname, var_name) == 0
) {
- /* Efficiency hack. Recognize the special case of
+ /*
+ * Efficiency hack. Recognize the special case of
*
* for (iggy in foo)
* delete foo[iggy]
@@ -833,6 +860,10 @@ statement
bcfree($3);
bcfree($4);
bcfree($5);
+ if ($7 != NULL) {
+ merge_comments($7, NULL);
+ $8 = list_prepend($8, $7);
+ }
$$ = $8;
} else
goto regular_loop;
@@ -867,8 +898,9 @@ regular_loop:
$1->target_continue = tcont;
$1->target_break = tbreak;
(void) list_append(ip, $1);
- } /* else
- $1 is NULL */
+ }
+ /* else
+ $1 is NULL */
/* add update_FOO instruction if necessary */
if ($4->array_var->type == Node_var && $4->array_var->var_update) {
@@ -889,8 +921,15 @@ regular_loop:
($1 + 1)->forloop_body = ip->lasti;
}
- if ($8 != NULL)
+ if ($7 != NULL)
+ merge_comments($7, NULL);
+
+ if ($8 != NULL) {
+ if ($7 != NULL)
+ $8 = list_prepend($8, $7);
(void) list_merge(ip, $8);
+ } else if ($7 != NULL)
+ (void) list_append(ip, $7);
(void) list_append(ip, instruction(Op_jmp));
ip->lasti->target_jmp = $4;
@@ -903,6 +942,20 @@ regular_loop:
}
| LEX_FOR '(' opt_simple_stmt semi opt_nls exp semi opt_nls opt_simple_stmt r_paren opt_nls statement
{
+ if ($5 != NULL) {
+ merge_comments($5, NULL);
+ $1->comment = $5;
+ }
+ if ($8 != NULL) {
+ merge_comments($8, NULL);
+ if ($1->comment == NULL) {
+ $8->memory->comment_type = FOR_COMMENT;
+ $1->comment = $8;
+ } else
+ $1->comment->comment = $8;
+ }
+ if ($11 != NULL)
+ $12 = list_prepend($12, $11);
$$ = mk_for_loop($1, $3, $6, $9, $12);
break_allowed--;
@@ -910,6 +963,20 @@ regular_loop:
}
| LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r_paren opt_nls statement
{
+ if ($5 != NULL) {
+ merge_comments($5, NULL);
+ $1->comment = $5;
+ }
+ if ($7 != NULL) {
+ merge_comments($7, NULL);
+ if ($1->comment == NULL) {
+ $7->memory->comment_type = FOR_COMMENT;
+ $1->comment = $7;
+ } else
+ $1->comment->comment = $7;
+ }
+ if ($10 != NULL)
+ $11 = list_prepend($11, $10);
$$ = mk_for_loop($1, $3, (INSTRUCTION *) NULL, $8, $11);
break_allowed--;
@@ -921,7 +988,6 @@ regular_loop:
$$ = list_prepend($1, instruction(Op_exec_count));
else
$$ = $1;
- $$ = add_pending_comment($$);
}
;
@@ -933,8 +999,8 @@ non_compound_stmt
_("`break' is not allowed outside a loop or switch"));
$1->target_jmp = NULL;
$$ = list_create($1);
- $$ = add_pending_comment($$);
-
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_CONTINUE statement_term
{
@@ -943,8 +1009,8 @@ non_compound_stmt
_("`continue' is not allowed outside a loop"));
$1->target_jmp = NULL;
$$ = list_create($1);
- $$ = add_pending_comment($$);
-
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_NEXT statement_term
{
@@ -954,7 +1020,8 @@ non_compound_stmt
_("`next' used in %s action"), ruletab[rule]);
$1->target_jmp = ip_rec;
$$ = list_create($1);
- $$ = add_pending_comment($$);
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_NEXTFILE statement_term
{
@@ -966,7 +1033,8 @@ non_compound_stmt
$1->target_newfile = ip_newfile;
$1->target_endfile = ip_endfile;
$$ = list_create($1);
- $$ = add_pending_comment($$);
+ if ($2 != NULL)
+ $$ = list_append($$, $2);
}
| LEX_EXIT opt_exp statement_term
{
@@ -982,7 +1050,8 @@ non_compound_stmt
$$->nexti->memory = dupnode(Nnull_string);
} else
$$ = list_append($2, $1);
- $$ = add_pending_comment($$);
+ if ($3 != NULL)
+ $$ = list_append($$, $3);
}
| LEX_RETURN
{
@@ -995,10 +1064,16 @@ non_compound_stmt
$$->nexti->memory = dupnode(Nnull_string);
} else
$$ = list_append($3, $1);
-
- $$ = add_pending_comment($$);
+ if ($4 != NULL)
+ $$ = list_append($$, $4);
}
| simple_stmt statement_term
+ {
+ if ($2 != NULL)
+ $$ = list_append($1, $2);
+ else
+ $$ = $1;
+ }
;
/*
@@ -1018,7 +1093,7 @@ simple_stmt
* which is faster for these two cases.
*/
- if ($1->opcode == Op_K_print &&
+ if (do_optimize && $1->opcode == Op_K_print &&
($3 == NULL
|| ($3->lasti->opcode == Op_field_spec
&& $3->nexti->nexti->nexti == $3->lasti
@@ -1106,7 +1181,6 @@ regular_print:
}
}
}
- $$ = add_pending_comment($$);
}
| LEX_DELETE NAME { sub_counter = 0; } delete_subscript_list
@@ -1141,7 +1215,6 @@ regular_print:
$1->expr_count = sub_counter;
$$ = list_append(list_append($4, $2), $1);
}
- $$ = add_pending_comment($$);
}
| LEX_DELETE '(' NAME ')'
/*
@@ -1172,12 +1245,10 @@ regular_print:
else if ($3->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
- $$ = add_pending_comment($$);
}
| exp
{
$$ = optimize_assignment($1);
- $$ = add_pending_comment($$);
}
;
@@ -1212,6 +1283,7 @@ case_statement
(void) list_prepend(casestmt, instruction(Op_exec_count));
$1->case_exp = $2;
$1->case_stmt = casestmt;
+ $1->comment = $4;
bcfree($3);
$$ = $1;
}
@@ -1224,6 +1296,7 @@ case_statement
(void) list_prepend(casestmt, instruction(Op_exec_count));
bcfree($2);
$1->case_stmt = casestmt;
+ $1->comment = $3;
$$ = $1;
}
;
@@ -1305,23 +1378,51 @@ output_redir
if_statement
: LEX_IF '(' exp r_paren opt_nls statement
{
+ if ($5 != NULL)
+ $1->comment = $5;
$$ = mk_condition($3, $1, $6, NULL, NULL);
}
| LEX_IF '(' exp r_paren opt_nls statement
LEX_ELSE opt_nls statement
{
+ if ($5 != NULL)
+ $1->comment = $5;
+ if ($8 != NULL)
+ $7->comment = $8;
$$ = mk_condition($3, $1, $6, $7, $9);
}
;
nls
: NEWLINE
+ {
+ $$ = $1;
+ }
| nls NEWLINE
+ {
+ if ($1 != NULL && $2 != NULL) {
+ if ($1->memory->comment_type == EOL_COMMENT) {
+ assert($2->memory->comment_type == BLOCK_COMMENT);
+ $1->comment = $2; // chain them
+ } else {
+ merge_comments($1, $2);
+ }
+
+ $$ = $1;
+ } else if ($1 != NULL) {
+ $$ = $1;
+ } else if ($2 != NULL) {
+ $$ = $2;
+ } else
+ $$ = NULL;
+ }
;
opt_nls
: /* empty */
+ { $$ = NULL; }
| nls
+ { $$ = $1; }
;
input_redir
@@ -1350,9 +1451,17 @@ param_list
| param_list comma NAME
{
if ($1 != NULL && $3 != NULL) {
- $3->param_count = $1->lasti->param_count + 1;
+ $3->param_count = $1->lasti->param_count + 1;
$$ = list_append($1, $3);
yyerrok;
+
+ // newlines are allowed after commas, catch any comments
+ if ($2 != NULL) {
+ if ($1->comment != NULL)
+ merge_comments($1->comment, $2);
+ else
+ $1->comment = $2;
+ }
} else
$$ = NULL;
}
@@ -1384,6 +1493,8 @@ expression_list
{ $$ = mk_expression_list(NULL, $1); }
| expression_list comma exp
{
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = mk_expression_list($1, $3);
yyerrok;
}
@@ -1405,6 +1516,8 @@ expression_list
| expression_list comma error
{
/* Ditto */
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = $1;
}
;
@@ -1421,6 +1534,8 @@ fcall_expression_list
{ $$ = mk_expression_list(NULL, $1); }
| fcall_expression_list comma fcall_exp
{
+ if ($2 != NULL)
+ $1->lasti->comment = $2;
$$ = mk_expression_list($1, $3);
yyerrok;
}
@@ -1442,6 +1557,8 @@ fcall_expression_list
| fcall_expression_list comma error
{
/* Ditto */
+ if ($2 != NULL)
+ $1->comment = $2;
$$ = $1;
}
;
@@ -2006,15 +2123,16 @@ opt_incdec
{
$1->opcode = Op_postdecrement;
}
- | /* empty */ { $$ = NULL; }
+ | /* empty */
+ { $$ = NULL; }
;
l_brace
- : '{' opt_nls
+ : '{' opt_nls { $$ = $2; }
;
r_brace
- : '}' opt_nls { yyerrok; }
+ : '}' opt_nls { $$ = $2; yyerrok; }
;
r_paren
@@ -2023,6 +2141,7 @@ r_paren
opt_semi
: /* empty */
+ { $$ = NULL; }
| semi
;
@@ -2035,7 +2154,7 @@ colon
;
comma
- : ',' opt_nls { yyerrok; }
+ : ',' opt_nls { $$ = $2; yyerrok; }
;
%%
@@ -2115,8 +2234,8 @@ static const struct token tokentab[] = {
{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)},
{"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0},
{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0},
-{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
-{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
+{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0},
+{"function", Op_func, LEX_FUNCTION, NOT_OLD, 0, 0},
{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0, 0},
{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0, 0},
{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0, 0},
@@ -2475,11 +2594,12 @@ mk_program()
cp = end_block;
else
cp = list_merge(begin_block, end_block);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
- if (comment != NULL)
- (void) list_append(cp, comment);
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -2512,12 +2632,16 @@ mk_program()
if (begin_block != NULL)
cp = list_merge(begin_block, cp);
- if (program_comment != NULL) {
- (void) list_prepend(cp, program_comment);
+ if (outer_comment != NULL) {
+ cp = list_merge(list_create(outer_comment), cp);
+ outer_comment = NULL;
}
- if (comment != NULL) {
- (void) list_append(cp, comment);
+
+ if (interblock_comment != NULL) {
+ (void) list_append(cp, interblock_comment);
+ interblock_comment = NULL;
}
+
(void) list_append(cp, ip_atexit);
(void) list_append(cp, instruction(Op_stop));
@@ -2525,10 +2649,6 @@ out:
/* delete the Op_list, not needed */
tmp = cp->nexti;
bcfree(cp);
- /* these variables are not used again but zap them anyway. */
- comment = NULL;
- function_comment = NULL;
- program_comment = NULL;
return tmp;
#undef begin_block
@@ -2703,33 +2823,35 @@ add_srcfile(enum srctype stype, char *src, SRCFILE *thisfile, bool *already_incl
/* include_source --- read program from source included using `@include' */
-static int
-include_source(INSTRUCTION *file)
+static bool
+include_source(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@include is a gawk extension"));
- return -1;
+ return false;
}
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @include"));
- return 0;
+ return true;
}
s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode);
if (s == NULL) {
if (already_included)
- return 0;
+ return true;
error_ln(file->source_line,
_("can't open source file `%s' for reading (%s)"),
src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ return false;
}
/* save scanner state for the current sourcefile */
@@ -2748,42 +2870,53 @@ include_source(INSTRUCTION *file)
lasttok = 0;
lexeof = false;
eof_warned = false;
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* load_library --- load a shared library */
-static int
-load_library(INSTRUCTION *file)
+static bool
+load_library(INSTRUCTION *file, void **srcfile_p)
{
SRCFILE *s;
char *src = file->lextok;
int errcode;
bool already_included;
+ *srcfile_p = NULL;
+
if (do_traditional || do_posix) {
error_ln(file->source_line, _("@load is a gawk extension"));
- return -1;
+ return false;
}
+
if (strlen(src) == 0) {
if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @load"));
- return 0;
+ return true;
}
- s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
- if (s == NULL) {
- if (already_included)
- return 0;
- error_ln(file->source_line,
- _("can't open shared library `%s' for reading (%s)"),
- src, errcode ? strerror(errcode) : _("reason unknown"));
- return -1;
+ if (do_pretty_print && ! do_profile) {
+ // create a fake one, don't try to open the file
+ s = do_add_srcfile(SRC_EXTLIB, src, src, sourcefile);
+ } else {
+ s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, &errcode);
+ if (s == NULL) {
+ if (already_included)
+ return true;
+ error_ln(file->source_line,
+ _("can't open shared library `%s' for reading (%s)"),
+ src, errcode ? strerror(errcode) : _("reason unknown"));
+ return false;
+ }
+
+ load_ext(s->fullpath);
}
- load_ext(s->fullpath);
- return 0;
+ *srcfile_p = (void *) s;
+ return true;
}
/* next_sourcefile --- read program from the next source in srcfiles */
@@ -3191,37 +3324,23 @@ pushback(void)
(! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr);
}
-/* check_comment --- check for block comment */
-
-void
-check_comment(void)
-{
- if (comment != NULL) {
- if (first_rule) {
- program_comment = comment;
- } else
- block_comment = comment;
- comment = NULL;
- }
- first_rule = false;
-}
-
/*
* get_comment --- collect comment text.
* Flag = EOL_COMMENT for end-of-line comments.
- * Flag = FULL_COMMENT for self-contained comments.
+ * Flag = BLOCK_COMMENT for self-contained comments.
*/
-int
-get_comment(int flag)
+static int
+get_comment(enum commenttype flag, INSTRUCTION **comment_instruction)
{
int c;
int sl;
+ char *p1;
+ char *p2;
+
tok = tokstart;
tokadd('#');
sl = sourceline;
- char *p1;
- char *p2;
while (true) {
while ((c = nextc(false)) != '\n' && c != END_FILE) {
@@ -3257,9 +3376,6 @@ get_comment(int flag)
break;
}
- if (comment != NULL)
- prior_comment = comment;
-
/* remove any trailing blank lines (consecutive \n) from comment */
p1 = tok - 1;
p2 = tok - 2;
@@ -3269,49 +3385,18 @@ get_comment(int flag)
tok--;
}
- comment = bcalloc(Op_comment, 1, sl);
- comment->source_file = source;
- comment->memory = make_str_node(tokstart, tok - tokstart, 0);
- comment->memory->comment_type = flag;
+ (*comment_instruction) = bcalloc(Op_comment, 1, sl);
+ (*comment_instruction)->source_file = source;
+ (*comment_instruction)->memory = make_str_node(tokstart, tok - tokstart, 0);
+ (*comment_instruction)->memory->comment_type = flag;
return c;
}
-/* split_comment --- split initial comment text into program and function parts */
-
-static void
-split_comment(void)
-{
- char *p;
- int l;
- NODE *n;
-
- p = comment_to_save->memory->stptr;
- l = comment_to_save->memory->stlen - 3;
- /* have at least two comments so split at last blank line (\n\n) */
- while (l >= 0) {
- if (p[l] == '\n' && p[l+1] == '\n') {
- function_comment = comment_to_save;
- n = function_comment->memory;
- function_comment->memory = make_string(p + l + 2, n->stlen - l - 2);
- /* create program comment */
- program_comment = bcalloc(Op_comment, 1, sourceline);
- program_comment->source_file = comment_to_save->source_file;
- p[l + 2] = 0;
- program_comment->memory = make_str_node(p, l + 2, 0);
- comment_to_save = NULL;
- freenode(n);
- break;
- }
- else
- l--;
- }
-}
-
/* allow_newline --- allow newline after &&, ||, ? and : */
static void
-allow_newline(void)
+allow_newline(INSTRUCTION **new_comment)
{
int c;
@@ -3323,8 +3408,8 @@ allow_newline(void)
}
if (c == '#') {
if (do_pretty_print && ! do_profile) {
- /* collect comment byte code iff doing pretty print but not profiling. */
- c = get_comment(EOL_COMMENT);
+ /* collect comment byte code iff doing pretty print but not profiling. */
+ c = get_comment(EOL_COMMENT, new_comment);
} else {
while ((c = nextc(false)) != '\n' && c != END_FILE)
continue;
@@ -3391,6 +3476,7 @@ yylex(void)
bool intlstr = false;
AWKNUM d;
bool collecting_typed_regexp = false;
+ static int qm_col_count = 0;
#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline)
@@ -3555,18 +3641,25 @@ retry:
return lasttok = NEWLINE;
case '#': /* it's a comment */
+ yylval = NULL;
if (do_pretty_print && ! do_profile) {
/*
* Collect comment byte code iff doing pretty print
* but not profiling.
*/
+ INSTRUCTION *new_comment;
+
if (lasttok == NEWLINE || lasttok == 0)
- c = get_comment(FULL_COMMENT);
+ c = get_comment(BLOCK_COMMENT, & new_comment);
else
- c = get_comment(EOL_COMMENT);
+ c = get_comment(EOL_COMMENT, & new_comment);
- if (c == END_FILE)
- return lasttok = NEWLINE_EOF;
+ yylval = new_comment;
+
+ if (c == END_FILE) {
+ pushback();
+ return lasttok = NEWLINE;
+ }
} else {
while ((c = nextc(false)) != '\n') {
if (c == END_FILE)
@@ -3595,7 +3688,10 @@ retry:
* Use it at your own risk. We think it's a bad idea, which
* is why it's not on by default.
*/
+ yylval = NULL;
if (! do_traditional) {
+ INSTRUCTION *new_comment;
+
/* strip trailing white-space and/or comment */
while ((c = nextc(true)) == ' ' || c == '\t' || c == '\r')
continue;
@@ -3607,9 +3703,11 @@ retry:
lintwarn(
_("use of `\\ #...' line continuation is not portable"));
}
- if (do_pretty_print && ! do_profile)
- c = get_comment(EOL_COMMENT);
- else {
+ if (do_pretty_print && ! do_profile) {
+ c = get_comment(EOL_COMMENT, & new_comment);
+ yylval = new_comment;
+ return lasttok = c;
+ } else {
while ((c = nextc(false)) != '\n')
if (c == END_FILE)
break;
@@ -3630,11 +3728,20 @@ retry:
}
break;
- case ':':
case '?':
+ qm_col_count++;
+ // fall through
+ case ':':
yylval = GET_INSTRUCTION(Op_cond_exp);
- if (! do_posix)
- allow_newline();
+ if (qm_col_count > 0) {
+ if (! do_posix) {
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+ }
+ if (c == ':')
+ qm_col_count--;
+ }
return lasttok = c;
/*
@@ -4056,7 +4163,10 @@ retry:
case '&':
if ((c = nextc(true)) == '&') {
yylval = GET_INSTRUCTION(Op_and);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_AND;
}
pushback();
@@ -4066,11 +4176,15 @@ retry:
case '|':
if ((c = nextc(true)) == '|') {
yylval = GET_INSTRUCTION(Op_or);
- allow_newline();
+ INSTRUCTION *new_comment = NULL;
+ allow_newline(& new_comment);
+ yylval->comment = new_comment;
+
return lasttok = LEX_OR;
} else if (! do_traditional && c == '&') {
yylval = GET_INSTRUCTION(Op_symbol);
yylval->redir_type = redirect_twoway;
+
return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN);
}
pushback();
@@ -4260,8 +4374,11 @@ out:
yylval->lextok = tokkey;
#define SMART_ALECK 1
- if (SMART_ALECK && do_lint
- && ! goto_warned && strcasecmp(tokkey, "goto") == 0) {
+ if (SMART_ALECK
+ && do_lint
+ && ! goto_warned
+ && tolower(tokkey[0]) == 'g'
+ && strcasecmp(tokkey, "goto") == 0) {
goto_warned = true;
lintwarn(_("`goto' considered harmful!"));
}
@@ -4734,13 +4851,15 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
/* add any pre-function comment to start of action for profile.c */
- if (function_comment != NULL) {
- function_comment->source_line = 0;
- (void) list_prepend(def, function_comment);
- function_comment = NULL;
+ if (interblock_comment != NULL) {
+ interblock_comment->source_line = 0;
+ merge_comments(interblock_comment, fi->comment);
+ fi->comment = interblock_comment;
+ interblock_comment = NULL;
}
- /* add an implicit return at end;
+ /*
+ * Add an implicit return at end;
* also used by 'return' command in debugger
*/
@@ -4748,6 +4867,11 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def)
def->lasti->memory = dupnode(Nnull_string);
(void) list_append(def, instruction(Op_K_return));
+ if (trailing_comment != NULL) {
+ (void) list_append(def, trailing_comment);
+ trailing_comment = NULL;
+ }
+
if (do_pretty_print)
(void) list_prepend(def, instruction(Op_exec_count));
@@ -5451,12 +5575,11 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 1)->lasti = action->lasti;
(rp + 2)->first_line = pattern->source_line;
(rp + 2)->last_line = lastline;
- if (block_comment != NULL) {
- ip = list_prepend(list_prepend(action, block_comment), rp);
- block_comment = NULL;
- } else
- ip = list_prepend(action, rp);
-
+ ip = list_prepend(action, rp);
+ if (interblock_comment != NULL) {
+ ip = list_prepend(ip, interblock_comment);
+ interblock_comment = NULL;
+ }
} else {
rp = bcalloc(Op_rule, 3, 0);
rp->in_rule = Rule;
@@ -5482,14 +5605,20 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action)
(rp + 2)->last_line = find_line(pattern, LAST_LINE);
action = list_create(instruction(Op_K_print_rec));
if (do_pretty_print)
- (void) list_prepend(action, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
} else
(rp + 2)->last_line = lastline;
+ if (interblock_comment != NULL) { // was after previous action
+ pattern = list_prepend(pattern, interblock_comment);
+ interblock_comment = NULL;
+ }
+
if (do_pretty_print) {
- (void) list_prepend(pattern, instruction(Op_exec_count));
- (void) list_prepend(action, instruction(Op_exec_count));
+ pattern = list_prepend(pattern, instruction(Op_exec_count));
+ action = list_prepend(action, instruction(Op_exec_count));
}
+
(rp + 1)->firsti = action->nexti;
(rp + 1)->lasti = tp;
ip = list_append(
@@ -5861,8 +5990,9 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond,
forp->target_break = tbreak;
forp->target_continue = tcont;
ret = list_prepend(ret, forp);
- } /* else
- forp is NULL */
+ }
+ /* else
+ forp is NULL */
return ret;
}
@@ -6076,26 +6206,6 @@ list_merge(INSTRUCTION *l1, INSTRUCTION *l2)
return l1;
}
-/* add_pending_comment --- add a pending comment to a statement */
-
-static inline INSTRUCTION *
-add_pending_comment(INSTRUCTION *stmt)
-{
- INSTRUCTION *ret = stmt;
-
- if (prior_comment != NULL) {
- if (function_comment != prior_comment)
- ret = list_append(stmt, prior_comment);
- prior_comment = NULL;
- } else if (comment != NULL && comment->memory->comment_type == EOL_COMMENT) {
- if (function_comment != comment)
- ret = list_append(stmt, comment);
- comment = NULL;
- }
-
- return ret;
-}
-
/* See if name is a special token. */
int
@@ -6335,3 +6445,91 @@ set_profile_text(NODE *n, const char *str, size_t len)
return n;
}
+
+/*
+ * merge_comments --- merge c2 into c1 and free c2 if successful.
+ * Allow c2 to be NULL, in which case just merged chained
+ * comments in c1.
+ */
+
+static void
+merge_comments(INSTRUCTION *c1, INSTRUCTION *c2)
+{
+ assert(c1->opcode == Op_comment);
+
+ if (c1->comment == NULL && c2 == NULL) // nothing to do
+ return;
+
+ size_t total = c1->memory->stlen;
+ if (c1->comment != NULL)
+ total += 1 /* \n */ + c1->comment->memory->stlen;
+
+ if (c2 != NULL) {
+ assert(c2->opcode == Op_comment);
+ total += 1 /* \n */ + c2->memory->stlen;
+ if (c2->comment != NULL)
+ total += c2->comment->memory->stlen + 1;
+ }
+
+ char *buffer;
+ emalloc(buffer, char *, total + 1, "merge_comments");
+
+ strcpy(buffer, c1->memory->stptr);
+ if (c1->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c1->comment->memory->stptr);
+ }
+
+ if (c2 != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->memory->stptr);
+ if (c2->comment != NULL) {
+ strcat(buffer, "\n");
+ strcat(buffer, c2->comment->memory->stptr);
+ }
+
+ unref(c2->memory);
+ if (c2->comment != NULL) {
+ unref(c2->comment->memory);
+ bcfree(c2->comment);
+ c2->comment = NULL;
+ }
+ bcfree(c2);
+ }
+
+ c1->memory->comment_type = BLOCK_COMMENT;
+ free(c1->memory->stptr);
+ c1->memory->stptr = buffer;
+ c1->memory->stlen = strlen(buffer);
+
+ // now free everything else
+ if (c1->comment != NULL) {
+ unref(c1->comment->memory);
+ bcfree(c1->comment);
+ c1->comment = NULL;
+ }
+}
+
+/* make_braced_statements --- handle `l_brace statements r_brace' with comments */
+
+static INSTRUCTION *
+make_braced_statements(INSTRUCTION *lbrace, INSTRUCTION *stmts, INSTRUCTION *rbrace)
+{
+ INSTRUCTION *ip;
+
+ if (stmts == NULL)
+ ip = list_create(instruction(Op_no_op));
+ else
+ ip = stmts;
+
+ if (lbrace != NULL) {
+ INSTRUCTION *comment2 = lbrace->comment;
+ if (comment2 != NULL) {
+ ip = list_prepend(ip, comment2);
+ lbrace->comment = NULL;
+ }
+ ip = list_prepend(ip, lbrace);
+ }
+
+ return ip;
+}
diff --git a/debug.c b/debug.c
index b24a8db6..6c6a59f5 100644
--- a/debug.c
+++ b/debug.c
@@ -3807,7 +3807,12 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
break;
case Op_K_do:
- print_func(fp, "[doloop_cond = %p] [target_break = %p]\n", (pc+1)->doloop_cond, pc->target_break);
+ print_func(fp, "[doloop_cond = %p] [target_break = %p]", (pc+1)->doloop_cond, pc->target_break);
+ if (pc->comment)
+ print_func(fp, " [comment = %p]", pc->comment);
+ print_func(fp, "\n");
+ if (pc->comment)
+ print_instruction(pc->comment, print_func, fp, in_dump);
break;
case Op_K_for:
@@ -3815,15 +3820,44 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
/* fall through */
case Op_K_arrayfor:
print_func(fp, "[forloop_body = %p] ", (pc+1)->forloop_body);
- print_func(fp, "[target_break = %p] [target_continue = %p]\n", pc->target_break, pc->target_continue);
+ print_func(fp, "[target_break = %p] [target_continue = %p]", pc->target_break, pc->target_continue);
+ if (pc->comment != NULL) {
+ print_func(fp, " [comment = %p]\n", (pc)->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_K_switch:
+ {
+ bool need_newline = false;
print_func(fp, "[switch_start = %p] [switch_end = %p]\n", (pc+1)->switch_start, (pc+1)->switch_end);
+ if (pc->comment || (pc+1)->switch_end->comment)
+ print_func(fp, "%*s", noffset, "");
+ if (pc->comment) {
+ print_func(fp, "[start_comment = %p]", pc->comment);
+ need_newline = true;
+ }
+ if ((pc+1)->switch_end->comment) {
+ print_func(fp, "[end_comment = %p]", (pc + 1)->switch_end->comment);
+ need_newline = true;
+ }
+ if (need_newline)
+ print_func(fp, "\n");
+ if (pc->comment)
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ if ((pc+1)->switch_end->comment)
+ print_instruction((pc+1)->switch_end->comment, print_func, fp, in_dump);
+ }
break;
case Op_K_default:
- print_func(fp, "[stmt_start = %p] [stmt_end = %p]\n", pc->stmt_start, pc->stmt_end);
+ print_func(fp, "[stmt_start = %p] [stmt_end = %p]", pc->stmt_start, pc->stmt_end);
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_var_update:
@@ -3915,8 +3949,13 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
break;
case Op_K_case:
- print_func(fp, "[target_jmp = %p] [match_exp = %s]\n",
+ print_func(fp, "[target_jmp = %p] [match_exp = %s]",
pc->target_jmp, (pc + 1)->match_exp ? "true" : "false");
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_arrayfor_incr:
@@ -4032,9 +4071,14 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump)
case Op_comment:
print_memory(pc->memory, func, print_func, fp);
- print_func(fp, " [comment_type = %s]\n",
+ print_func(fp, " [comment_type = %s]",
pc->memory->comment_type == EOL_COMMENT ?
- "EOL" : "FULL");
+ "EOL" : "BLOCK");
+ if (pc->comment) {
+ print_func(fp, " [comment = %p]\n", pc->comment);
+ print_instruction(pc->comment, print_func, fp, in_dump);
+ } else
+ print_func(fp, "\n");
break;
case Op_push_i:
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 261388a2..f4fb7b69 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -42,6 +42,10 @@
* gawktexi.in): Small typo fixes. Thanks to Antonio
Giovanni Colombo for pointing them out.
+2018-11-01 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Profiling): Review and update.
+
2018-10-30 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Arrays of Arrays): Typo fix in code. Thanks to Alto Tom
@@ -59,6 +63,12 @@
Communications Guidelines, with URL.
* texinfo.tex: Updated from GNULIB.
+2018-10-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Profiling): Revise example for pattern without
+ action and note that the profiler distinguishes `print' and
+ `print $0'.
+
2018-09-23 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Extracting): Note that patch levels above
diff --git a/doc/gawk.info b/doc/gawk.info
index 60713f8f..e0738357 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -20794,7 +20794,8 @@ output. They are as follows:
structure of the program and the precedence rules. For example,
'(3 + 5) * 4' means add three and five, then multiply the total by
four. However, '3 + 5 * 4' has no parentheses, and means '3 + (5 *
- 4)'.
+ 4)'. However, explicit parentheses in the source program are
+ retained.
* Parentheses are used around the arguments to 'print' and 'printf'
only when the 'print' or 'printf' statement is followed by a
@@ -20816,10 +20817,11 @@ representation. Also, things such as:
come out as:
/foo/ {
- print $0
+ print
}
-which is correct, but possibly unexpected.
+which is correct, but possibly unexpected. (If a program uses both
+'print $0' and plain 'print', that distinction is retained.)
Besides creating profiles when a program has completed, 'gawk' can
produce a profile while it is running. This is useful if your 'awk'
@@ -20875,7 +20877,10 @@ without any execution counts.
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.(1)
+source code. However, no comments should be lost. Also, 'gawk' does
+the best it can to preserve the distinction between comments at the end
+of a statement and comments on lines by themselves. This isn't always
+perfect, though.
However, as a deliberate design decision, profiling output _omits_
the original program's comments. This allows you to focus on the
@@ -20895,14 +20900,6 @@ disable 'gawk''s default optimizations.
constants; if you used an octal or hexadecimal value in your source
code, it will appear that way in the output.
- ---------- Footnotes ----------
-
- (1) 'gawk' does the best it can to preserve the distinction between
-comments at the end of a statement and comments on lines by themselves.
-Due to implementation constraints, it does not always do so correctly,
-particularly for 'switch' statements. The 'gawk' maintainers hope to
-improve this in a subsequent release.
-

File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanced Features
@@ -34197,7 +34194,7 @@ Index
* dump debugger command: Miscellaneous Debugger Commands.
(line 9)
* dupword.awk program: Dupword Program. (line 31)
-* dynamic profiling: Profiling. (line 177)
+* dynamic profiling: Profiling. (line 179)
* dynamically loaded extensions: Dynamic Extensions. (line 6)
* e debugger command (alias for enable): Breakpoint Control. (line 73)
* EBCDIC: Ordinal Functions. (line 45)
@@ -34586,7 +34583,7 @@ Index
* G., Daniel Richard: Acknowledgments. (line 60)
* G., Daniel Richard <1>: Maintainers. (line 14)
* Garfinkle, Scott: Contributors. (line 35)
-* gawk program, dynamic profiling: Profiling. (line 177)
+* gawk program, dynamic profiling: Profiling. (line 179)
* gawk version: Auto-set. (line 262)
* gawk, ARGIND variable in: Other Arguments. (line 15)
* gawk, awk and: Preface. (line 21)
@@ -34793,7 +34790,7 @@ Index
* history expansion, in debugger: Readline Support. (line 6)
* histsort.awk program: History Sorting. (line 25)
* Hughes, Phil: Acknowledgments. (line 43)
-* HUP signal, for dynamic profiling: Profiling. (line 209)
+* HUP signal, for dynamic profiling: Profiling. (line 211)
* hyphen (-), - operator: Precedence. (line 51)
* hyphen (-), - operator <1>: Precedence. (line 57)
* hyphen (-), -- operator: Increment Ops. (line 48)
@@ -34875,7 +34872,7 @@ Index
* installing gawk: Installation. (line 6)
* instruction tracing, in debugger: Debugger Info. (line 90)
* int: Numeric Functions. (line 24)
-* INT signal (MS-Windows): Profiling. (line 212)
+* INT signal (MS-Windows): Profiling. (line 214)
* integer array indices: Numeric Array Subscripts.
(line 31)
* integers, arbitrary precision: Arbitrary Precision Integers.
@@ -34931,7 +34928,7 @@ Index
* Kernighan, Brian <8>: Other Versions. (line 13)
* Kernighan, Brian <9>: Basic Data Typing. (line 54)
* Kernighan, Brian <10>: Glossary. (line 204)
-* kill command, dynamic profiling: Profiling. (line 186)
+* kill command, dynamic profiling: Profiling. (line 188)
* Knights, jedi: Undocumented. (line 6)
* Kwok, Conrad: Contributors. (line 35)
* l debugger command (alias for list): Miscellaneous Debugger Commands.
@@ -35446,7 +35443,7 @@ Index
* PROCINFO, values of sorted_in: Controlling Scanning.
(line 26)
* profiling awk programs: Profiling. (line 6)
-* profiling awk programs, dynamically: Profiling. (line 177)
+* profiling awk programs, dynamically: Profiling. (line 179)
* program identifiers: Auto-set. (line 193)
* program, definition of: Getting Started. (line 21)
* programming conventions, --non-decimal-data option: Nondecimal Data.
@@ -35483,7 +35480,7 @@ Index
* QuikTrim Awk: Other Versions. (line 143)
* quit debugger command: Miscellaneous Debugger Commands.
(line 100)
-* QUIT signal (MS-Windows): Profiling. (line 212)
+* QUIT signal (MS-Windows): Profiling. (line 214)
* quoting in gawk command lines: Long. (line 26)
* quoting in gawk command lines, tricks for: Quoting. (line 91)
* quoting, for small awk programs: Comments. (line 27)
@@ -35773,15 +35770,15 @@ Index
(line 130)
* sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps.
(line 58)
-* SIGHUP signal, for dynamic profiling: Profiling. (line 209)
-* SIGINT signal (MS-Windows): Profiling. (line 212)
-* signals, HUP/SIGHUP, for profiling: Profiling. (line 209)
-* signals, INT/SIGINT (MS-Windows): Profiling. (line 212)
-* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 212)
-* signals, USR1/SIGUSR1, for profiling: Profiling. (line 186)
+* SIGHUP signal, for dynamic profiling: Profiling. (line 211)
+* SIGINT signal (MS-Windows): Profiling. (line 214)
+* signals, HUP/SIGHUP, for profiling: Profiling. (line 211)
+* signals, INT/SIGINT (MS-Windows): Profiling. (line 214)
+* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 214)
+* signals, USR1/SIGUSR1, for profiling: Profiling. (line 188)
* signature program: Signature Program. (line 6)
-* SIGQUIT signal (MS-Windows): Profiling. (line 212)
-* SIGUSR1 signal, for dynamic profiling: Profiling. (line 186)
+* SIGQUIT signal (MS-Windows): Profiling. (line 214)
+* SIGUSR1 signal, for dynamic profiling: Profiling. (line 188)
* silent debugger command: Debugger Execution Control.
(line 10)
* sin: Numeric Functions. (line 75)
@@ -36062,7 +36059,7 @@ Index
* user-modifiable variables: User-modified. (line 6)
* users, information about, printing: Id Program. (line 6)
* users, information about, retrieving: Passwd Functions. (line 16)
-* USR1 signal, for dynamic profiling: Profiling. (line 186)
+* USR1 signal, for dynamic profiling: Profiling. (line 188)
* values, numeric: Basic Data Typing. (line 13)
* values, string: Basic Data Typing. (line 13)
* variable assignments and input files: Other Arguments. (line 26)
@@ -36530,218 +36527,217 @@ Ref: Two-way I/O-Footnote-1836301
Ref: Two-way I/O-Footnote-2836488
Node: TCP/IP Networking836570
Node: Profiling839688
-Ref: Profiling-Footnote-1848360
-Node: Advanced Features Summary848683
-Node: Internationalization850527
-Node: I18N and L10N852007
-Node: Explaining gettext852694
-Ref: Explaining gettext-Footnote-1858586
-Ref: Explaining gettext-Footnote-2858771
-Node: Programmer i18n858936
-Ref: Programmer i18n-Footnote-1863885
-Node: Translator i18n863934
-Node: String Extraction864728
-Ref: String Extraction-Footnote-1865860
-Node: Printf Ordering865946
-Ref: Printf Ordering-Footnote-1868732
-Node: I18N Portability868796
-Ref: I18N Portability-Footnote-1871252
-Node: I18N Example871315
-Ref: I18N Example-Footnote-1874121
-Node: Gawk I18N874194
-Node: I18N Summary874839
-Node: Debugger876180
-Node: Debugging877203
-Node: Debugging Concepts877644
-Node: Debugging Terms879453
-Node: Awk Debugging882028
-Node: Sample Debugging Session882934
-Node: Debugger Invocation883468
-Node: Finding The Bug884854
-Node: List of Debugger Commands891332
-Node: Breakpoint Control892665
-Node: Debugger Execution Control896359
-Node: Viewing And Changing Data899721
-Node: Execution Stack903095
-Node: Debugger Info904732
-Node: Miscellaneous Debugger Commands908803
-Node: Readline Support913865
-Node: Limitations914761
-Node: Debugging Summary916870
-Node: Arbitrary Precision Arithmetic918149
-Node: Computer Arithmetic919634
-Ref: table-numeric-ranges923400
-Ref: table-floating-point-ranges923893
-Ref: Computer Arithmetic-Footnote-1924551
-Node: Math Definitions924608
-Ref: table-ieee-formats927924
-Ref: Math Definitions-Footnote-1928527
-Node: MPFR features928632
-Node: FP Math Caution930350
-Ref: FP Math Caution-Footnote-1931422
-Node: Inexactness of computations931791
-Node: Inexact representation932751
-Node: Comparing FP Values934111
-Node: Errors accumulate935352
-Node: Getting Accuracy936785
-Node: Try To Round939495
-Node: Setting precision940394
-Ref: table-predefined-precision-strings941091
-Node: Setting the rounding mode942921
-Ref: table-gawk-rounding-modes943295
-Ref: Setting the rounding mode-Footnote-1947226
-Node: Arbitrary Precision Integers947405
-Ref: Arbitrary Precision Integers-Footnote-1950580
-Node: Checking for MPFR950729
-Node: POSIX Floating Point Problems952203
-Ref: POSIX Floating Point Problems-Footnote-1956488
-Node: Floating point summary956526
-Node: Dynamic Extensions958716
-Node: Extension Intro960269
-Node: Plugin License961535
-Node: Extension Mechanism Outline962332
-Ref: figure-load-extension962771
-Ref: figure-register-new-function964336
-Ref: figure-call-new-function965428
-Node: Extension API Description967490
-Node: Extension API Functions Introduction969132
-Node: General Data Types974672
-Ref: General Data Types-Footnote-1983033
-Node: Memory Allocation Functions983332
-Ref: Memory Allocation Functions-Footnote-1987542
-Node: Constructor Functions987641
-Node: Registration Functions991227
-Node: Extension Functions991912
-Node: Exit Callback Functions997127
-Node: Extension Version String998377
-Node: Input Parsers999040
-Node: Output Wrappers1011761
-Node: Two-way processors1016273
-Node: Printing Messages1018538
-Ref: Printing Messages-Footnote-11019709
-Node: Updating ERRNO1019862
-Node: Requesting Values1020601
-Ref: table-value-types-returned1021338
-Node: Accessing Parameters1022274
-Node: Symbol Table Access1023509
-Node: Symbol table by name1024021
-Node: Symbol table by cookie1025810
-Ref: Symbol table by cookie-Footnote-11029995
-Node: Cached values1030059
-Ref: Cached values-Footnote-11033595
-Node: Array Manipulation1033748
-Ref: Array Manipulation-Footnote-11034839
-Node: Array Data Types1034876
-Ref: Array Data Types-Footnote-11037534
-Node: Array Functions1037626
-Node: Flattening Arrays1042124
-Node: Creating Arrays1049100
-Node: Redirection API1053867
-Node: Extension API Variables1056700
-Node: Extension Versioning1057411
-Ref: gawk-api-version1057840
-Node: Extension GMP/MPFR Versioning1059571
-Node: Extension API Informational Variables1061199
-Node: Extension API Boilerplate1062272
-Node: Changes from API V11066246
-Node: Finding Extensions1067818
-Node: Extension Example1068377
-Node: Internal File Description1069175
-Node: Internal File Ops1073255
-Ref: Internal File Ops-Footnote-11084605
-Node: Using Internal File Ops1084745
-Ref: Using Internal File Ops-Footnote-11087128
-Node: Extension Samples1087402
-Node: Extension Sample File Functions1088931
-Node: Extension Sample Fnmatch1096580
-Node: Extension Sample Fork1098067
-Node: Extension Sample Inplace1099285
-Node: Extension Sample Ord1102502
-Node: Extension Sample Readdir1103338
-Ref: table-readdir-file-types1104227
-Node: Extension Sample Revout1105032
-Node: Extension Sample Rev2way1105621
-Node: Extension Sample Read write array1106361
-Node: Extension Sample Readfile1108303
-Node: Extension Sample Time1109398
-Node: Extension Sample API Tests1110746
-Node: gawkextlib1111238
-Node: Extension summary1114156
-Node: Extension Exercises1117858
-Node: Language History1119356
-Node: V7/SVR3.11121012
-Node: SVR41123164
-Node: POSIX1124598
-Node: BTL1125978
-Node: POSIX/GNU1126707
-Node: Feature History1132485
-Node: Common Extensions1148531
-Node: Ranges and Locales1149814
-Ref: Ranges and Locales-Footnote-11154430
-Ref: Ranges and Locales-Footnote-21154457
-Ref: Ranges and Locales-Footnote-31154692
-Node: Contributors1154913
-Node: History summary1160858
-Node: Installation1162238
-Node: Gawk Distribution1163182
-Node: Getting1163666
-Node: Extracting1164629
-Node: Distribution contents1166267
-Node: Unix Installation1172747
-Node: Quick Installation1173429
-Node: Shell Startup Files1175843
-Node: Additional Configuration Options1176932
-Node: Configuration Philosophy1179097
-Node: Non-Unix Installation1181466
-Node: PC Installation1181926
-Node: PC Binary Installation1182764
-Node: PC Compiling1183199
-Node: PC Using1184316
-Node: Cygwin1187869
-Node: MSYS1188968
-Node: VMS Installation1189469
-Node: VMS Compilation1190260
-Ref: VMS Compilation-Footnote-11191489
-Node: VMS Dynamic Extensions1191547
-Node: VMS Installation Details1193232
-Node: VMS Running1195485
-Node: VMS GNV1199764
-Node: VMS Old Gawk1200499
-Node: Bugs1200970
-Node: Bug address1201633
-Node: Usenet1204615
-Node: Maintainers1205619
-Node: Other Versions1206880
-Node: Installation summary1213794
-Node: Notes1214996
-Node: Compatibility Mode1215790
-Node: Additions1216572
-Node: Accessing The Source1217497
-Node: Adding Code1218934
-Node: New Ports1225153
-Node: Derived Files1229641
-Ref: Derived Files-Footnote-11235287
-Ref: Derived Files-Footnote-21235322
-Ref: Derived Files-Footnote-31235920
-Node: Future Extensions1236034
-Node: Implementation Limitations1236692
-Node: Extension Design1237875
-Node: Old Extension Problems1239019
-Ref: Old Extension Problems-Footnote-11240537
-Node: Extension New Mechanism Goals1240594
-Ref: Extension New Mechanism Goals-Footnote-11243958
-Node: Extension Other Design Decisions1244147
-Node: Extension Future Growth1246260
-Node: Notes summary1247096
-Node: Basic Concepts1248271
-Node: Basic High Level1248952
-Ref: figure-general-flow1249234
-Ref: figure-process-flow1249919
-Ref: Basic High Level-Footnote-11253220
-Node: Basic Data Typing1253405
-Node: Glossary1256733
-Node: Copying1288571
-Node: GNU Free Documentation License1326114
-Node: Index1351234
+Node: Advanced Features Summary848693
+Node: Internationalization850537
+Node: I18N and L10N852017
+Node: Explaining gettext852704
+Ref: Explaining gettext-Footnote-1858596
+Ref: Explaining gettext-Footnote-2858781
+Node: Programmer i18n858946
+Ref: Programmer i18n-Footnote-1863895
+Node: Translator i18n863944
+Node: String Extraction864738
+Ref: String Extraction-Footnote-1865870
+Node: Printf Ordering865956
+Ref: Printf Ordering-Footnote-1868742
+Node: I18N Portability868806
+Ref: I18N Portability-Footnote-1871262
+Node: I18N Example871325
+Ref: I18N Example-Footnote-1874131
+Node: Gawk I18N874204
+Node: I18N Summary874849
+Node: Debugger876190
+Node: Debugging877213
+Node: Debugging Concepts877654
+Node: Debugging Terms879463
+Node: Awk Debugging882038
+Node: Sample Debugging Session882944
+Node: Debugger Invocation883478
+Node: Finding The Bug884864
+Node: List of Debugger Commands891342
+Node: Breakpoint Control892675
+Node: Debugger Execution Control896369
+Node: Viewing And Changing Data899731
+Node: Execution Stack903105
+Node: Debugger Info904742
+Node: Miscellaneous Debugger Commands908813
+Node: Readline Support913875
+Node: Limitations914771
+Node: Debugging Summary916880
+Node: Arbitrary Precision Arithmetic918159
+Node: Computer Arithmetic919644
+Ref: table-numeric-ranges923410
+Ref: table-floating-point-ranges923903
+Ref: Computer Arithmetic-Footnote-1924561
+Node: Math Definitions924618
+Ref: table-ieee-formats927934
+Ref: Math Definitions-Footnote-1928537
+Node: MPFR features928642
+Node: FP Math Caution930360
+Ref: FP Math Caution-Footnote-1931432
+Node: Inexactness of computations931801
+Node: Inexact representation932761
+Node: Comparing FP Values934121
+Node: Errors accumulate935362
+Node: Getting Accuracy936795
+Node: Try To Round939505
+Node: Setting precision940404
+Ref: table-predefined-precision-strings941101
+Node: Setting the rounding mode942931
+Ref: table-gawk-rounding-modes943305
+Ref: Setting the rounding mode-Footnote-1947236
+Node: Arbitrary Precision Integers947415
+Ref: Arbitrary Precision Integers-Footnote-1950590
+Node: Checking for MPFR950739
+Node: POSIX Floating Point Problems952213
+Ref: POSIX Floating Point Problems-Footnote-1956498
+Node: Floating point summary956536
+Node: Dynamic Extensions958726
+Node: Extension Intro960279
+Node: Plugin License961545
+Node: Extension Mechanism Outline962342
+Ref: figure-load-extension962781
+Ref: figure-register-new-function964346
+Ref: figure-call-new-function965438
+Node: Extension API Description967500
+Node: Extension API Functions Introduction969142
+Node: General Data Types974682
+Ref: General Data Types-Footnote-1983043
+Node: Memory Allocation Functions983342
+Ref: Memory Allocation Functions-Footnote-1987552
+Node: Constructor Functions987651
+Node: Registration Functions991237
+Node: Extension Functions991922
+Node: Exit Callback Functions997137
+Node: Extension Version String998387
+Node: Input Parsers999050
+Node: Output Wrappers1011771
+Node: Two-way processors1016283
+Node: Printing Messages1018548
+Ref: Printing Messages-Footnote-11019719
+Node: Updating ERRNO1019872
+Node: Requesting Values1020611
+Ref: table-value-types-returned1021348
+Node: Accessing Parameters1022284
+Node: Symbol Table Access1023519
+Node: Symbol table by name1024031
+Node: Symbol table by cookie1025820
+Ref: Symbol table by cookie-Footnote-11030005
+Node: Cached values1030069
+Ref: Cached values-Footnote-11033605
+Node: Array Manipulation1033758
+Ref: Array Manipulation-Footnote-11034849
+Node: Array Data Types1034886
+Ref: Array Data Types-Footnote-11037544
+Node: Array Functions1037636
+Node: Flattening Arrays1042134
+Node: Creating Arrays1049110
+Node: Redirection API1053877
+Node: Extension API Variables1056710
+Node: Extension Versioning1057421
+Ref: gawk-api-version1057850
+Node: Extension GMP/MPFR Versioning1059581
+Node: Extension API Informational Variables1061209
+Node: Extension API Boilerplate1062282
+Node: Changes from API V11066256
+Node: Finding Extensions1067828
+Node: Extension Example1068387
+Node: Internal File Description1069185
+Node: Internal File Ops1073265
+Ref: Internal File Ops-Footnote-11084615
+Node: Using Internal File Ops1084755
+Ref: Using Internal File Ops-Footnote-11087138
+Node: Extension Samples1087412
+Node: Extension Sample File Functions1088941
+Node: Extension Sample Fnmatch1096590
+Node: Extension Sample Fork1098077
+Node: Extension Sample Inplace1099295
+Node: Extension Sample Ord1102512
+Node: Extension Sample Readdir1103348
+Ref: table-readdir-file-types1104237
+Node: Extension Sample Revout1105042
+Node: Extension Sample Rev2way1105631
+Node: Extension Sample Read write array1106371
+Node: Extension Sample Readfile1108313
+Node: Extension Sample Time1109408
+Node: Extension Sample API Tests1110756
+Node: gawkextlib1111248
+Node: Extension summary1114166
+Node: Extension Exercises1117868
+Node: Language History1119366
+Node: V7/SVR3.11121022
+Node: SVR41123174
+Node: POSIX1124608
+Node: BTL1125988
+Node: POSIX/GNU1126717
+Node: Feature History1132495
+Node: Common Extensions1148541
+Node: Ranges and Locales1149824
+Ref: Ranges and Locales-Footnote-11154440
+Ref: Ranges and Locales-Footnote-21154467
+Ref: Ranges and Locales-Footnote-31154702
+Node: Contributors1154923
+Node: History summary1160868
+Node: Installation1162248
+Node: Gawk Distribution1163192
+Node: Getting1163676
+Node: Extracting1164639
+Node: Distribution contents1166277
+Node: Unix Installation1172757
+Node: Quick Installation1173439
+Node: Shell Startup Files1175853
+Node: Additional Configuration Options1176942
+Node: Configuration Philosophy1179107
+Node: Non-Unix Installation1181476
+Node: PC Installation1181936
+Node: PC Binary Installation1182774
+Node: PC Compiling1183209
+Node: PC Using1184326
+Node: Cygwin1187879
+Node: MSYS1188978
+Node: VMS Installation1189479
+Node: VMS Compilation1190270
+Ref: VMS Compilation-Footnote-11191499
+Node: VMS Dynamic Extensions1191557
+Node: VMS Installation Details1193242
+Node: VMS Running1195495
+Node: VMS GNV1199774
+Node: VMS Old Gawk1200509
+Node: Bugs1200980
+Node: Bug address1201643
+Node: Usenet1204625
+Node: Maintainers1205629
+Node: Other Versions1206890
+Node: Installation summary1213804
+Node: Notes1215006
+Node: Compatibility Mode1215800
+Node: Additions1216582
+Node: Accessing The Source1217507
+Node: Adding Code1218944
+Node: New Ports1225163
+Node: Derived Files1229651
+Ref: Derived Files-Footnote-11235297
+Ref: Derived Files-Footnote-21235332
+Ref: Derived Files-Footnote-31235930
+Node: Future Extensions1236044
+Node: Implementation Limitations1236702
+Node: Extension Design1237885
+Node: Old Extension Problems1239029
+Ref: Old Extension Problems-Footnote-11240547
+Node: Extension New Mechanism Goals1240604
+Ref: Extension New Mechanism Goals-Footnote-11243968
+Node: Extension Other Design Decisions1244157
+Node: Extension Future Growth1246270
+Node: Notes summary1247106
+Node: Basic Concepts1248281
+Node: Basic High Level1248962
+Ref: figure-general-flow1249244
+Ref: figure-process-flow1249929
+Ref: Basic High Level-Footnote-11253230
+Node: Basic Data Typing1253415
+Node: Glossary1256743
+Node: Copying1288581
+Node: GNU Free Documentation License1326124
+Node: Index1351244

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 3443aeec..70ab0de3 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -29122,6 +29122,7 @@ of the program and the precedence rules.
For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
+However, explicit parentheses in the source program are retained.
@ignore
@item
@@ -29160,12 +29161,14 @@ come out as:
@example
/foo/ @{
- print $0
+ print
@}
@end example
@noindent
which is correct, but possibly unexpected.
+(If a program uses both @samp{print $0} and plain
+@samp{print}, that distinction is retained.)
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -29250,12 +29253,10 @@ There is a significant difference between the output created when
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.@footnote{@command{gawk} does the best it can to preserve
+source code. However, no comments should be lost.
+Also, @command{gawk} does the best it can to preserve
the distinction between comments at the end of a statement and comments
-on lines by themselves. Due to implementation constraints, it does not
-always do so correctly, particularly for @code{switch} statements. The
-@command{gawk} maintainers hope to improve this in a subsequent
-release.}
+on lines by themselves. This isn't always perfect, though.
However, as a deliberate design decision, profiling output @emph{omits}
the original program's comments. This allows you to focus on the
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index cc667534..091b786d 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -28135,6 +28135,7 @@ of the program and the precedence rules.
For example, @samp{(3 + 5) * 4} means add three and five, then multiply
the total by four. However, @samp{3 + 5 * 4} has no parentheses, and
means @samp{3 + (5 * 4)}.
+However, explicit parentheses in the source program are retained.
@ignore
@item
@@ -28173,12 +28174,14 @@ come out as:
@example
/foo/ @{
- print $0
+ print
@}
@end example
@noindent
which is correct, but possibly unexpected.
+(If a program uses both @samp{print $0} and plain
+@samp{print}, that distinction is retained.)
@cindex profiling @command{awk} programs, dynamically
@cindex @command{gawk} program, dynamic profiling
@@ -28263,12 +28266,10 @@ There is a significant difference between the output created when
profiling, and that created when pretty-printing. Pretty-printed output
preserves the original comments that were in the program, although their
placement may not correspond exactly to their original locations in the
-source code.@footnote{@command{gawk} does the best it can to preserve
+source code. However, no comments should be lost.
+Also, @command{gawk} does the best it can to preserve
the distinction between comments at the end of a statement and comments
-on lines by themselves. Due to implementation constraints, it does not
-always do so correctly, particularly for @code{switch} statements. The
-@command{gawk} maintainers hope to improve this in a subsequent
-release.}
+on lines by themselves. This isn't always perfect, though.
However, as a deliberate design decision, profiling output @emph{omits}
the original program's comments. This allows you to focus on the
diff --git a/profile.c b/profile.c
index ac08a61d..3041545a 100644
--- a/profile.c
+++ b/profile.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1999-2017 the Free Software Foundation, Inc.
+ * Copyright (C) 1999-2018 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -37,7 +37,7 @@ static char *pp_typed_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);
-static void pp_push(int type, char *s, int flag);
+static void pp_push(int type, char *s, int flag, INSTRUCTION *comment);
static NODE *pp_pop(void);
static void print_comment(INSTRUCTION *pc, long in);
const char *redir2str(int redirtype);
@@ -45,6 +45,7 @@ const char *redir2str(int redirtype);
#define pp_str vname
#define pp_len sub.nodep.reserved
#define pp_next rnode
+#define pp_comment sub.nodep.x.cmnt
#define DONT_FREE 1
#define CAN_FREE 2
@@ -60,6 +61,15 @@ static FILE *prof_fp; /* where to send the profile */
static long indent_level = 0;
+static const char tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+static const size_t tabs_len = sizeof(tabs) - 1;
+
+#define check_indent_level() \
+ if (indent_level + 1 > tabs_len) \
+ /* We're allowed to be snarky, occasionally. */ \
+ fatal(_("Program indentation level too deep. Consider refactoring your code"));
+
+
#define SPACEOVER 0
#define NO_PPRINT_FLAGS 0
@@ -159,7 +169,7 @@ indent_out(void)
/* pp_push --- push a pretty printed string onto the stack */
static void
-pp_push(int type, char *s, int flag)
+pp_push(int type, char *s, int flag, INSTRUCTION *comment)
{
NODE *n;
getnode(n);
@@ -168,6 +178,7 @@ pp_push(int type, char *s, int flag)
n->flags = flag;
n->type = type;
n->pp_next = pp_stack;
+ n->pp_comment = comment;
pp_stack = n;
}
@@ -238,9 +249,9 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
if (rule != Rule) {
/* Allow for pre-non-rule-block comment */
- if (pc->nexti != (pc +1)->firsti
+ if (pc->nexti != (pc+1)->firsti
&& pc->nexti->opcode == Op_comment
- && pc->nexti->memory->comment_type == FULL_COMMENT)
+ && pc->nexti->memory->comment_type == BLOCK_COMMENT)
print_comment(pc->nexti, -1);
ip1 = (pc + 1)->firsti;
ip2 = (pc + 1)->lasti;
@@ -302,9 +313,9 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
case Op_push_i:
m = pc->memory;
if (m == Nnull_string) /* optional return or exit value; don't print 0 or "" */
- pp_push(pc->opcode, m->stptr, DONT_FREE);
+ pp_push(pc->opcode, m->stptr, DONT_FREE, pc->comment);
else if ((m->flags & NUMBER) != 0)
- pp_push(pc->opcode, pp_number(m), CAN_FREE);
+ pp_push(pc->opcode, pp_number(m), CAN_FREE, pc->comment);
else {
str = pp_string(m->stptr, m->stlen, '"');
if ((m->flags & INTLSTR) != 0) {
@@ -312,13 +323,13 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
str = pp_group3("_", tmp, "");
efree(tmp);
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
case Op_store_var:
if (pc->initval != NULL)
- pp_push(Op_push_i, pp_node(pc->initval), CAN_FREE);
+ pp_push(Op_push_i, pp_node(pc->initval), CAN_FREE, pc->comment);
/* fall through */
case Op_store_sub:
case Op_assign_concat:
@@ -331,14 +342,14 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int flags)
m = pc->memory;
switch (m->type) {
case Node_param_list:
- pp_push(pc->opcode, func_params[m->param_cnt].param, DONT_FREE);
+ pp_push(pc->opcode, func_params[m->param_cnt].param, DONT_FREE, pc->comment);
break;
case Node_var:
case Node_var_new:
case Node_var_array:
if (m->vname != NULL)
- pp_push(pc->opcode, m->vname, DONT_FREE);
+ pp_push(pc->opcode, m->vname, DONT_FREE, pc->comment);
else
fatal(_("internal error: %s with null vname"),
nodetype2str(m->type));
@@ -390,7 +401,7 @@ cleanup:
str = pp_group3(t1->pp_str, tmp, "");
efree(tmp);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_and:
@@ -399,10 +410,24 @@ cleanup:
t2 = pp_pop();
t1 = pp_pop();
parenthesize(pc->opcode, t1, t2);
- str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
+ if (pc->comment == NULL)
+ str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
+ else {
+ check_indent_level();
+
+ size_t len = strlen(t1->pp_str)
+ + strlen(op2str(pc->opcode)) + strlen(t2->pp_str) // foo && bar
+ + indent_level + 1 // indent
+ + pc->comment->memory->stlen + 3; // tab comment
+
+ emalloc(str, char *, len, "pprint");
+ sprintf(str, "%s%s%s%.*s %s", t1->pp_str, op2str(pc->opcode),
+ pc->comment->memory->stptr,
+ (int) (indent_level + 1), tabs, t2->pp_str);
+ }
pp_free(t1);
pp_free(t2);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
pc = pc->target_jmp;
break;
@@ -424,14 +449,14 @@ cleanup:
str = pp_group3(t1->pp_str, op2str(pc->opcode), tmp);
efree(tmp);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_parens:
t1 = pp_pop();
str = pp_group3("(", t1->pp_str, ")");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_plus:
@@ -452,7 +477,7 @@ cleanup:
str = pp_group3(t1->pp_str, op2str(pc->opcode), t2->pp_str);
pp_free(t1);
pp_free(t2);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_preincrement:
@@ -465,7 +490,7 @@ cleanup:
else
str = pp_group3(t1->pp_str, op2str(pc->opcode), "");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_field_spec:
@@ -483,7 +508,7 @@ cleanup:
/* optypes table (eval.c) includes space after ! */
str = pp_group3(op2str(pc->opcode), t1->pp_str, "");
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_assign:
@@ -498,7 +523,7 @@ cleanup:
str = pp_group3(t2->pp_str, op2str(pc->opcode), t1->pp_str);
pp_free(t2);
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_store_field:
@@ -515,7 +540,7 @@ cleanup:
case Op_concat:
str = pp_concat(pc->expr_count);
- pp_push(Op_concat, str, CAN_FREE);
+ pp_push(Op_concat, str, CAN_FREE, pc->comment);
break;
case Op_K_delete:
@@ -560,7 +585,7 @@ cleanup:
pp_free(t2);
}
pp_free(t1);
- pp_push(Op_in_array, str, CAN_FREE);
+ pp_push(Op_in_array, str, CAN_FREE, pc->comment);
}
break;
@@ -595,7 +620,7 @@ cleanup:
tmp = pp_list(pc->expr_count, "()", ", ");
str = pp_group3(fname, tmp, "");
efree(tmp);
- pp_push(Op_sub_builtin, str, CAN_FREE);
+ pp_push(Op_sub_builtin, str, CAN_FREE, pc->comment);
}
break;
@@ -614,7 +639,7 @@ cleanup:
efree(tmp);
} else
str = pp_group3(fname, "()", "");
- pp_push(Op_builtin, str, CAN_FREE);
+ pp_push(Op_builtin, str, CAN_FREE, pc->comment);
} else
fatal(_("internal error: builtin with null fname"));
}
@@ -624,7 +649,8 @@ cleanup:
case Op_K_printf:
case Op_K_print_rec:
if (pc->opcode == Op_K_print_rec)
- tmp = pp_group3(" ", op2str(Op_field_spec), "0");
+ // instead of `print $0', just `print'
+ tmp = strdup("");
else if (pc->redir_type != 0)
tmp = pp_list(pc->expr_count, "()", ", ");
else {
@@ -660,7 +686,7 @@ cleanup:
assert((pc->memory->flags & REGEX) != 0);
str = pp_typed_regex(pc->memory->stptr, pc->memory->stlen, '/');
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -692,7 +718,7 @@ cleanup:
efree(restr);
}
pp_free(t1);
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -720,7 +746,7 @@ cleanup:
pp_free(t2);
} else
str = tmp;
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
break;
case Op_indirect_func_call:
@@ -745,7 +771,7 @@ cleanup:
t1 = pp_pop(); /* indirect var */
pp_free(t1);
}
- pp_push(pc->opcode, str, CAN_FREE);
+ pp_push(pc->opcode, str, CAN_FREE, pc->comment);
}
break;
@@ -786,7 +812,7 @@ cleanup:
str = pp_group3(t1->pp_str, ", ", t2->pp_str);
pp_free(t1);
pp_free(t2);
- pp_push(Op_line_range, str, CAN_FREE);
+ pp_push(Op_line_range, str, CAN_FREE, pc->comment);
pc = ip1->condpair_right;
break;
@@ -820,13 +846,34 @@ cleanup:
indent(SPACEOVER);
t1 = pp_pop();
fprintf(prof_fp, "} %s (%s)", op2str(Op_K_while), t1->pp_str);
+ if (pc->comment)
+ fprintf(prof_fp, "\t%s", pc->comment->memory->stptr);
+ else {
+ end_line(pc->target_break);
+ skip_comment = true;
+ }
pp_free(t1);
- end_line(pc->target_break);
- skip_comment = true;
pc = pc->target_break;
break;
case Op_K_for:
+ {
+ INSTRUCTION *comment1 = NULL, *comment2 = NULL;
+
+ if (pc->comment != NULL) {
+ comment1 = pc->comment;
+ pc->comment = NULL;
+ if (comment1 != NULL && comment1->comment != NULL) {
+ comment2 = comment1->comment;
+ comment1->comment = NULL;
+ }
+ if (comment2 == NULL && comment1->memory->comment_type == FOR_COMMENT) {
+ comment2 = comment1;
+ comment2->memory->comment_type = EOL_COMMENT;
+ comment1 = NULL;
+ }
+ }
+
ip1 = pc + 1;
indent(ip1->forloop_body->exec_count);
fprintf(prof_fp, "%s (", op2str(pc->opcode));
@@ -834,12 +881,19 @@ cleanup:
/* If empty for looop header, print it a little more nicely. */
if ( pc->nexti->opcode == Op_no_op
&& ip1->forloop_cond == pc->nexti
- && pc->target_continue->opcode == Op_jmp) {
+ && pc->target_continue->opcode == Op_jmp
+ && comment1 == NULL && comment2 == NULL) {
fprintf(prof_fp, ";;");
} else {
pprint(pc->nexti, ip1->forloop_cond, IN_FOR_HEADER);
fprintf(prof_fp, "; ");
+ if (comment1 != NULL) {
+ print_comment(comment1, 0);
+ indent(ip1->forloop_body->exec_count);
+ indent(1);
+ }
+
if (ip1->forloop_cond->opcode == Op_no_op &&
ip1->forloop_cond->nexti == ip1->forloop_body)
fprintf(prof_fp, "; ");
@@ -850,6 +904,12 @@ cleanup:
pp_free(t1);
}
+ if (comment2 != NULL) {
+ print_comment(comment2, 0);
+ indent(ip1->forloop_body->exec_count);
+ indent(1);
+ }
+
pprint(pc->target_continue, pc->target_break, IN_FOR_HEADER);
}
fprintf(prof_fp, ") {");
@@ -863,6 +923,7 @@ cleanup:
end_line(pc->target_break);
skip_comment = true;
pc = pc->target_break;
+ }
break;
case Op_K_arrayfor:
@@ -901,10 +962,14 @@ cleanup:
pprint(pc->nexti, ip1->switch_start, NO_PPRINT_FLAGS);
t1 = pp_pop();
fprintf(prof_fp, "%s) {\n", t1->pp_str);
+ if (pc->comment)
+ print_comment(pc->comment, 0);
pp_free(t1);
pprint(ip1->switch_start, ip1->switch_end, NO_PPRINT_FLAGS);
indent(SPACEOVER);
fprintf(prof_fp, "}\n");
+ if (ip1->switch_end->comment)
+ print_comment(ip1->switch_end->comment, 0);
pc = pc->target_break;
break;
@@ -914,13 +979,20 @@ cleanup:
if (pc->opcode == Op_K_case) {
t1 = pp_pop();
fprintf(prof_fp, "%s %s:", op2str(pc->opcode), t1->pp_str);
- pc = end_line(pc);
pp_free(t1);
- } else {
+ } else
fprintf(prof_fp, "%s:", op2str(pc->opcode));
- pc = end_line(pc);
- }
+
indent_in();
+ if (pc->comment != NULL) {
+ if (pc->comment->memory->comment_type == EOL_COMMENT)
+ fprintf(prof_fp, "\t%s", pc->comment->memory->stptr);
+ else {
+ fprintf(prof_fp, "\n");
+ print_comment(pc->comment, indent_level);
+ }
+ } else
+ fprintf(prof_fp, "\n");
pprint(pc->stmt_start->nexti, pc->stmt_end->nexti, NO_PPRINT_FLAGS);
indent_out();
break;
@@ -937,6 +1009,8 @@ cleanup:
fprintf(prof_fp, " # %ld", ip1->exec_count);
ip1 = end_line(ip1);
indent_in();
+ if (pc->comment != NULL)
+ print_comment(pc->comment, indent_level);
pprint(ip1->nexti, pc->branch_else, NO_PPRINT_FLAGS);
indent_out();
pc = pc->branch_else;
@@ -944,7 +1018,7 @@ cleanup:
indent(SPACEOVER);
fprintf(prof_fp, "}");
if (pc->nexti->nexti->opcode != Op_comment
- || pc->nexti->nexti->memory->comment_type == FULL_COMMENT)
+ || pc->nexti->nexti->memory->comment_type == BLOCK_COMMENT)
fprintf(prof_fp, "\n");
/* else
It will be printed at the top. */
@@ -980,6 +1054,8 @@ cleanup:
end_line(pc);
skip_comment = true;
indent_in();
+ if (pc->comment != NULL)
+ print_comment(pc->comment, indent_level);
pprint(pc->nexti, pc->branch_end, NO_PPRINT_FLAGS);
indent_out();
indent(SPACEOVER);
@@ -999,6 +1075,9 @@ cleanup:
{
NODE *f, *t, *cond;
size_t len;
+ INSTRUCTION *qm_comment = NULL, *colon_comment = NULL;
+
+ qm_comment = pc->comment;
pprint(pc->nexti, pc->branch_if, NO_PPRINT_FLAGS);
ip1 = pc->branch_if;
@@ -1006,6 +1085,7 @@ cleanup:
ip1 = pc->branch_else->nexti;
pc = ip1->nexti;
+ colon_comment = pc->comment;
assert(pc->opcode == Op_cond_exp);
pprint(pc->nexti, pc->branch_end, NO_PPRINT_FLAGS);
@@ -1013,14 +1093,77 @@ cleanup:
t = pp_pop();
cond = pp_pop();
- len = f->pp_len + t->pp_len + cond->pp_len + 12;
- emalloc(str, char *, len, "pprint");
- sprintf(str, "%s ? %s : %s", cond->pp_str, t->pp_str, f->pp_str);
+ /*
+ * This stuff handles comments that come after a ?, :, or both.
+ * Allowing newlines after ? and : is a gawk extension.
+ * Theoretically this is fragile, since ?: expressions can be nested.
+ * In practice, it's not, since if there was a comment following ? or :
+ * in the original code, then it wasn't nested.
+ */
+
+ len = f->pp_len + t->pp_len + cond->pp_len + 12;
+ if (qm_comment == NULL && colon_comment == NULL) {
+ // easy case
+ emalloc(str, char *, len, "pprint");
+ sprintf(str, "%s ? %s : %s", cond->pp_str, t->pp_str, f->pp_str);
+ } else if (qm_comment != NULL && colon_comment != NULL) {
+ check_indent_level();
+ len += qm_comment->memory->stlen + // comments
+ colon_comment->memory->stlen +
+ 2 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 6;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? comment
+ "%.*s %s" // indent true-part
+ " : %s" // : comment
+ "%.*s %s", // indent false-part
+ cond->pp_str, // condition
+ qm_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ t->pp_str, // true part
+ colon_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ f->pp_str // false part
+ );
+ } else if (qm_comment != NULL) {
+ check_indent_level();
+ len += qm_comment->memory->stlen + // comment
+ 1 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 3;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? comment
+ "%.*s %s" // indent true-part
+ " : %s", // : false-part
+ cond->pp_str, // condition
+ qm_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ t->pp_str, // true part
+ f->pp_str // false part
+ );
+ } else {
+ check_indent_level();
+ len += colon_comment->memory->stlen + // comment
+ 1 * (indent_level + 1) + 3 + // indentation
+ t->pp_len + 3;
+ emalloc(str, char *, len, "pprint");
+ sprintf(str,
+ "%s ? %s" // cond ? true-part
+ " : %s" // : comment
+ "%.*s %s", // indent false-part
+ cond->pp_str, // condition
+ t->pp_str, // true part
+ colon_comment->memory->stptr, // comment
+ (int) (indent_level + 1), tabs, // indent
+ f->pp_str // false part
+ );
+ }
pp_free(cond);
pp_free(t);
pp_free(f);
- pp_push(Op_cond_exp, str, CAN_FREE);
+ pp_push(Op_cond_exp, str, CAN_FREE, pc->comment);
pc = pc->branch_end;
}
break;
@@ -1065,7 +1208,7 @@ end_line(INSTRUCTION *ip)
return ret;
}
-/* pp_string_fp --- printy print a string to the fp */
+/* pp_string_fp --- pretty print a string to the fp */
/*
* This routine concentrates string pretty printing in one place,
@@ -1124,17 +1267,59 @@ print_lib_list(FILE *prof_fp)
{
SRCFILE *s;
static bool printed_header = false;
+ const char *indent = "";
+ bool found = false;
+
+ if (do_profile)
+ indent = "\t";
for (s = srcfiles->next; s != srcfiles; s = s->next) {
if (s->stype == SRC_EXTLIB) {
+ if (do_profile && ! printed_header) {
+ printed_header = true;
+ fprintf(prof_fp, _("%s# Loaded extensions (-l and/or @load)\n\n"), indent);
+ }
+ found = true;
+ fprintf(prof_fp, "%s@load \"%s\"", indent, s->src);
+ if (s->comment != NULL) {
+ fprintf(prof_fp, "\t");
+ print_comment(s->comment, indent_level + 1);
+ } else
+ fprintf(prof_fp, "\n");
+ }
+ }
+ if (found) /* we found some */
+ fprintf(prof_fp, "\n");
+}
+
+/* print_include_list --- print a list of all files included */
+
+static void
+print_include_list(FILE *prof_fp)
+{
+ SRCFILE *s;
+ static bool printed_header = false;
+ bool found = false;
+
+ if (do_profile)
+ return;
+
+ for (s = srcfiles->next; s != srcfiles; s = s->next) {
+ if (s->stype == SRC_INC) {
if (! printed_header) {
printed_header = true;
- fprintf(prof_fp, _("\t# Loaded extensions (-l and/or @load)\n\n"));
+ fprintf(prof_fp, _("\n# Included files (-i and/or @include)\n\n"));
}
- fprintf(prof_fp, "\t@load \"%s\"\n", s->src);
+ found = true;
+ fprintf(prof_fp, "# @include \"%s\"", s->src);
+ if (s->comment != NULL) {
+ fprintf(prof_fp, "\t");
+ print_comment(s->comment, indent_level + 1);
+ } else
+ fprintf(prof_fp, "\n");
}
}
- if (printed_header) /* we found some */
+ if (found) /* we found some */
fprintf(prof_fp, "\n");
}
@@ -1158,8 +1343,17 @@ print_comment(INSTRUCTION* pc, long in)
after_newline = false;
}
putc(*text, prof_fp);
- if (*text == '\n')
- after_newline = true;
+ after_newline = (*text == '\n');
+ }
+
+ if (pc->comment) {
+ // chaining should only be two deep
+ assert(pc->comment->comment == NULL);
+ // if first was EOL comment, next must be block comment,
+ // it needs to be indented.
+ if (pc->memory->comment_type == EOL_COMMENT)
+ in++;
+ print_comment(pc->comment, in);
}
}
@@ -1181,6 +1375,7 @@ dump_prog(INSTRUCTION *code)
fprintf(prof_fp, _("\t# gawk profile, created %s\n"), ctime(& now));
print_lib_list(prof_fp);
pprint(code, NULL, NO_PPRINT_FLAGS);
+ print_include_list(prof_fp);
}
/* prec_level --- return the precedence of an operator, for paren tests */
@@ -1535,6 +1730,7 @@ pp_list(int nargs, const char *paren, const char *delim)
size_t len;
size_t delimlen;
int i;
+ INSTRUCTION *comment = NULL;
if (pp_args == NULL) {
npp_args = nargs;
@@ -1552,12 +1748,17 @@ pp_list(int nargs, const char *paren, const char *delim)
for (i = 1; i <= nargs; i++) {
r = pp_args[i] = pp_pop();
len += r->pp_len + delimlen;
+ if (r->pp_comment != NULL) {
+ comment = (INSTRUCTION *) r->pp_comment;
+ len += comment->memory->stlen + indent_level + 1; // comment\n ident
+ }
}
if (paren != NULL) {
assert(strlen(paren) == 2);
len += 2;
}
}
+ comment = NULL;
emalloc(str, char *, len + 1, "pp_list");
s = str;
@@ -1573,6 +1774,14 @@ pp_list(int nargs, const char *paren, const char *delim)
memcpy(s, delim, delimlen);
s += delimlen;
}
+ if (r->pp_comment != NULL) {
+ check_indent_level();
+ comment = (INSTRUCTION *) r->pp_comment;
+ memcpy(s, comment->memory->stptr, comment->memory->stlen);
+ s += comment->memory->stlen;
+ memcpy(s, tabs, indent_level + 1);
+ s += indent_level + 1;
+ }
r = pp_args[i];
memcpy(s, r->pp_str, r->pp_len);
s += r->pp_len;
@@ -1736,10 +1945,8 @@ pp_func(INSTRUCTION *pc, void *data ATTRIBUTE_UNUSED)
fprintf(prof_fp, "\n");
/* print any function comment */
- if (fp->opcode == Op_comment && fp->source_line == 0) {
- print_comment(fp, -1); /* -1 ==> don't indent */
- fp = fp->nexti;
- }
+ if (pc->comment != NULL)
+ print_comment(pc->comment, -1); /* -1 ==> don't indent */
indent(pc->nexti->exec_count);
fprintf(prof_fp, "%s %s(", op2str(Op_K_function), func->vname);
diff --git a/test/ChangeLog b/test/ChangeLog
index 96375390..cd6626e6 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,9 +1,29 @@
+2018-11-28 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile11.ok: Updated after code change.
+
+2018-11-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile11.awk: Disambiguate some comments.
+ * profile5.ok, profile11.ok: Updated after code change.
+
+2018-11-26 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile5.ok: Updated after code change.
+ * Makefile.am (GAWK_EXT_TESTS): New test, profile11.ok. Add
+ to the other relevant macros.
+ * profile11.awk, profile11.ok: New files.
+
2018-11-25 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (GAWK_EXT_TESTS): Fix layout of the list.
2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+ * profile5.ok: Updated after code change.
+
+2018-11-24 Arnold D. Robbins <arnold@skeeve.com>
+
* spacere.awk: Move setting of LC_ALL=C out to ...
* Makefile.am (spacere): ... here. Added test.
Per request from Eli Zaretskii to help porting to MinGW.
@@ -13,6 +33,14 @@
* Makefile.am (EXTRA_DIST): New test: typedregex4.
* typedregex4.awk, typedregex4.ok: New files.
+2018-11-11 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile10.ok: Updated after code change.
+
+2018-10-14 Arnold D. Robbins <arnold@skeeve.com>
+
+ * profile0.ok: Updated after code change.
+
2018-10-10 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (profile1): Add minus to ignore errors on final
diff --git a/test/Makefile.am b/test/Makefile.am
index a44a1944..98406a59 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -899,6 +899,8 @@ EXTRA_DIST = \
profile9.ok \
profile10.awk \
profile10.ok \
+ profile11.awk \
+ profile11.ok \
prt1eval.awk \
prt1eval.ok \
prtoeval.awk \
@@ -1307,7 +1309,7 @@ GAWK_EXT_TESTS = \
nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \
procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \
- profile7 profile8 profile9 profile10 pty1 pty2 \
+ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \
rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline rsglstdin \
rsstart1 rsstart2 rsstart3 rstest6 \
shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit split_after_fpat \
@@ -1364,7 +1366,7 @@ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum
NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix
# List of tests that need --pretty-print
-NEED_PRETTY = profile4 profile5 profile8 profile9 profile10
+NEED_PRETTY = profile4 profile5 profile8 profile9 profile10 profile11
# List of tests that need --re-interval
NEED_RE_INTERVAL = gsubtst3 reint reint2
diff --git a/test/Makefile.in b/test/Makefile.in
index 4c195884..54c6b986 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1157,6 +1157,8 @@ EXTRA_DIST = \
profile9.ok \
profile10.awk \
profile10.ok \
+ profile11.awk \
+ profile11.ok \
prt1eval.awk \
prt1eval.ok \
prtoeval.awk \
@@ -1565,7 +1567,7 @@ GAWK_EXT_TESTS = \
nastyparm negtime next nondec nondec2 nonfatal1 nonfatal2 nonfatal3 \
patsplit posix printfbad1 printfbad2 printfbad3 printfbad4 printhuge \
procinfs profile0 profile1 profile2 profile3 profile4 profile5 profile6 \
- profile7 profile8 profile9 profile10 pty1 pty2 \
+ profile7 profile8 profile9 profile10 profile11 pty1 pty2 \
rebuf regnul1 regnul2 regx8bit reginttrad reint reint2 rsgetline rsglstdin \
rsstart1 rsstart2 rsstart3 rstest6 \
shadow shadowbuiltin sortfor sortfor2 sortu sourcesplit split_after_fpat \
@@ -1621,7 +1623,7 @@ NEED_NONDEC = mpfrbigint2 nondec2 intarray forcenum
NEED_POSIX = printf0 posix2008sub paramasfunc1 paramasfunc2 muldimposix
# List of tests that need --pretty-print
-NEED_PRETTY = profile4 profile5 profile8 profile9 profile10
+NEED_PRETTY = profile4 profile5 profile8 profile9 profile10 profile11
# List of tests that need --re-interval
NEED_RE_INTERVAL = gsubtst3 reint reint2
@@ -4395,6 +4397,11 @@ profile10:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --pretty-print=_$@ >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+profile11:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --pretty-print=_$@ >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
regnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 65f0197c..067854e3 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1724,6 +1724,11 @@ profile10:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk --pretty-print=_$@ >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+profile11:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --pretty-print=_$@ >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
regnul1:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/profile0.ok b/test/profile0.ok
index 2e3c5728..42c464ba 100644
--- a/test/profile0.ok
+++ b/test/profile0.ok
@@ -1,6 +1,6 @@
# Rule(s)
2 NR == 1 { # 1
- 1 print $0
+ 1 print
}
diff --git a/test/profile10.ok b/test/profile10.ok
index 13f0b67b..0f77bd38 100644
--- a/test/profile10.ok
+++ b/test/profile10.ok
@@ -17,14 +17,12 @@ BEGIN { # Comment 0
print "MNO" # Comment 16
} # Comment 17
switch (q) {
- case "a":
- # Comment 18
+ # Comment 18
+ case "a": # Comment 19
case "b":
- # Comment 19
- break # Comment 20
- # Comment 21
- default:
- # Comment 22
+ # Comment 20
+ break # Comment 21
+ default: # Comment 22
break # Comment 23
}
# Comment 24
diff --git a/test/profile11.awk b/test/profile11.awk
new file mode 100644
index 00000000..06ede8ac
--- /dev/null
+++ b/test/profile11.awk
@@ -0,0 +1,321 @@
+
+# comments/for.awk
+BEGIN {
+ for (i = 1; i <= 10; i++) print i
+
+ for (i = 1; i <= 10; i++) # comment 0
+ print i
+
+ for (i = 1; # comment 1a
+ i <= 10; i++) print i
+
+ for (i = 1; i <= 10; # comment 2a
+ i++) print i
+
+ for (i = 1; # comment 1b
+ i <= 10; # comment 2b
+ i++) print i
+
+ for (i = 1; # comment 1c
+ i <= 10; # comment 2c
+ i++) # comment 3c
+ print i
+}
+
+# comments/for0.awk
+BEGIN {
+ for (iggy in foo) # comment 5
+ # comment 6
+ ;
+}
+
+# comments/for1.awk
+BEGIN {
+ for (iggy in foo) # comment 1
+ # comment 2
+ {
+ print iggy
+ }
+
+ for (iggy in foo) # comment 3
+ # comment 4
+ print iggy
+
+ for (iggy in foo) # comment 5
+ # comment 6
+ ;
+}
+
+# comments/for2.awk
+BEGIN {
+ for (;;) print i
+
+ for (;;) # comment 0
+ print i
+
+ for (; # comment 1a
+ ;) print i
+
+ for (; ; # comment 2a
+ ) print i
+
+ for (; # comment 1b
+ ; # comment 2b
+ ) print i
+
+ for (; # comment 1c
+ ; # comment 2c
+ ) # comment 3c
+ print i
+}
+
+# comments/for_del.awk
+BEGIN { for (iggy in foo) delete foo[iggy] }
+
+# comments/do.awk
+BEGIN {
+ do # DO comment
+ { # LBRACE comment
+ # block comment
+ print 42
+ } # rbrace comment
+ while (0) # WHILE comment
+}
+
+# comments/do2.awk
+BEGIN {
+ do # DO comment
+ { # LBRACE comment
+ # block comment
+ print 42
+ } # rbrace comment
+ while (0)
+}
+
+# comments2/do.awk
+BEGIN {
+ do # do comment
+ { # lbrace comment
+ # block comment
+ print 42
+ } # rbace EOL comment
+ # rbrace block comment
+ while (1) # while comment
+}
+
+# comments2/if.awk
+BEGIN {
+ if (a) # IF comment
+ print "foo" # print comment
+
+ if (a) # IF comment 2
+ { # lbrace comment
+ print "bar"
+ }
+ else # ELSE comment
+ print "baz"
+}
+
+# comments/if0.awk
+BEGIN {
+ if (a)
+ ; # nothing
+ else
+ print "b"
+}
+
+# comments/switch.awk
+BEGIN {
+ a = 5
+ switch (a) # switch EOL comment
+ # switch block comment
+ { # lbrace EOL comment
+ # lbrace block comment
+ case 5: # comment after case
+ print "five!"
+ break
+ # block comment after case
+ default: # comment after default
+ print "default" # print comment
+ break
+ } # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch.awk
+BEGIN {
+ a = 5
+ switch (a) # switch EOL comment
+ # switch block comment
+ { # lbrace EOL comment
+ # lbrace block comment
+ case 5:
+ print "five!"
+ break;
+ # block comment after case
+ } # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch0.awk
+BEGIN {
+ a = 5
+ switch (a)
+ {
+ case 5: # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/switch1.awk
+BEGIN {
+ a = 5
+ switch (a)
+ {
+ case 5:
+ # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/while.awk
+BEGIN {
+ while (1) # while comment
+ { # lbrace comment
+ # block comment
+ print 42
+ }
+}
+
+# comments2/while2.awk
+BEGIN {
+ while (1) # while comment
+ { # lbrace comment
+ # block comment
+ }
+}
+
+# comments2/f.awk
+function bar(p1,
+ p2)
+{
+ print "foo"
+} # rbrace eol bar
+ # rbrace block bar
+
+# comments2/function.awk
+function baz(p1, # comment
+ p2)
+ # comment before braces
+{ # lbrace eol
+ # lbrace block
+ print "foo"
+} # rbrace eol baz
+ # rbrace block baz
+
+# comments/function.awk
+function funny(param1, # param comment 1
+ param2, param3, # param comment 2
+ param4)
+ # Comment between header and body
+{ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+} # rbrace EOL comment funny
+ # rbrace block comment funny
+
+# comments/function2.awk
+function funnyhaha(param1,
+ param2, param3,
+ param4)
+{ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+} # rbrace EOL comment funnyhaha
+ # rbrace block comment funnyhaha
+
+# comments/callcoma.awk
+function callme(a, b, c)
+{
+ printf("a = %s, b = %s, c = %s\n", # format comment
+ a, # a2 comment
+ b, # b2 comment
+ c)
+}
+
+BEGIN {
+ callme(1, # 1 comment
+ 2, # 2 comment
+ 3)
+}
+
+# comments/exp.awk
+/foo/, # range comment
+ # range comment 2
+
+# range comment b
+
+# range comment c
+/bar/ { print }
+
+# comments/load.awk
+@load "filefuncs" # get file functions
+
+BEGIN {
+ stat("/etc/passwd", data)
+ for (i in data)
+ print i, data[i]
+}
+
+# comments/andor.awk
+BEGIN {
+ if (a && # and comment
+ b || # or comment
+ c)
+ print "foo"
+}
+
+# comments/qmcol-qm.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 :
+ 3
+ print a
+}
+
+# comments/qmcol-colon.awk
+BEGIN {
+ a = 1 ?
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# comments/qmcolboth.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# test beginning of line block comments (com2.awk)
+BEGIN {
+ print "hi" # comment 1
+# comment 2
+ print "there"
+
+ if (foo) {
+ print "hello" # comment 3
+# comment 4
+ print "world"
+ }
+}
diff --git a/test/profile11.ok b/test/profile11.ok
new file mode 100644
index 00000000..77f4dd7f
--- /dev/null
+++ b/test/profile11.ok
@@ -0,0 +1,371 @@
+@load "filefuncs" # get file functions
+
+# comments/for.awk
+BEGIN {
+ for (i = 1; i <= 10; i++) {
+ print i
+ }
+ for (i = 1; i <= 10; i++) { # comment 0
+ print i
+ }
+ for (i = 1; # comment 1a
+ i <= 10; i++) {
+ print i
+ }
+ for (i = 1; i <= 10; # comment 2a
+ i++) {
+ print i
+ }
+ for (i = 1; # comment 1b
+ i <= 10; # comment 2b
+ i++) {
+ print i
+ }
+ for (i = 1; # comment 1c
+ i <= 10; # comment 2c
+ i++) { # comment 3c
+ print i
+ }
+}
+
+# comments/for0.awk
+BEGIN {
+ for (iggy in foo) {
+ # comment 5
+
+ # comment 6
+ }
+}
+
+# comments/for1.awk
+BEGIN {
+ for (iggy in foo) {
+ # comment 1
+
+ # comment 2
+ print iggy
+ }
+ for (iggy in foo) {
+ # comment 3
+
+ # comment 4
+ print iggy
+ }
+ for (iggy in foo) {
+ # comment 5
+
+ # comment 6
+ }
+}
+
+# comments/for2.awk
+BEGIN {
+ for (;;) {
+ print i
+ }
+ for (;;) { # comment 0
+ print i
+ }
+ for (; # comment 1a
+ ; ) {
+ print i
+ }
+ for (; ; # comment 2a
+ ) {
+ print i
+ }
+ for (; # comment 1b
+ ; # comment 2b
+ ) {
+ print i
+ }
+ for (; # comment 1c
+ ; # comment 2c
+ ) { # comment 3c
+ print i
+ }
+}
+
+# comments/for_del.awk
+BEGIN {
+ for (iggy in foo) {
+ delete foo[iggy]
+ }
+}
+
+# comments/do.awk
+BEGIN {
+ do { # DO comment
+ # LBRACE comment
+ # block comment
+ print 42
+ } while (0) # WHILE comment
+ # rbrace comment
+}
+
+# comments/do2.awk
+BEGIN {
+ do { # DO comment
+ # LBRACE comment
+ # block comment
+ print 42
+ } while (0) # rbrace comment
+}
+
+# comments2/do.awk
+BEGIN {
+ do { # do comment
+ # lbrace comment
+ # block comment
+ print 42
+ } while (1) # while comment
+ # rbace EOL comment
+ # rbrace block comment
+}
+
+# comments2/if.awk
+BEGIN {
+ if (a) {
+ # IF comment
+ print "foo" # print comment
+ }
+ if (a) { # lbrace comment
+ # IF comment 2
+ print "bar"
+ } else {
+ # ELSE comment
+ print "baz"
+ }
+}
+
+# comments/if0.awk
+BEGIN {
+ if (a) {
+ # nothing
+ } else {
+ print "b"
+ }
+}
+
+# comments/switch.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ # switch EOL comment
+
+ # switch block comment
+
+ # lbrace EOL comment
+
+ # lbrace block comment
+ case 5: # comment after case
+ print "five!"
+ break
+ # block comment after case
+ default: # comment after default
+ print "default" # print comment
+ break
+ }
+ # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ # switch EOL comment
+
+ # switch block comment
+
+ # lbrace EOL comment
+
+ # lbrace block comment
+ case 5:
+ print "five!"
+ break
+ # block comment after case
+ }
+ # rbrace EOL comment
+ # rbrace block comment
+}
+
+# comments2/switch0.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ case 5: # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/switch1.awk
+BEGIN {
+ a = 5
+ switch (a) {
+ case 5:
+ # case comment
+ print "five!"
+ break
+ default: # default comment
+ print "default"
+ break
+ }
+}
+
+# comments2/while.awk
+BEGIN {
+ while (1) {
+ # while comment
+ # lbrace comment
+ # block comment
+ print 42
+ }
+}
+
+# comments2/while2.awk
+BEGIN {
+ while (1) {
+ # while comment
+ # lbrace comment
+ # block comment
+ }
+}
+
+BEGIN {
+ callme(1, # 1 comment
+ 2, # 2 comment
+ 3)
+}
+
+# comments/load.awk
+BEGIN {
+ stat("/etc/passwd", data)
+ for (i in data) {
+ print i, data[i]
+ }
+}
+
+# comments/andor.awk
+BEGIN {
+ if (a && # and comment
+ b || # or comment
+ c) {
+ print "foo"
+ }
+}
+
+# comments/qmcol-qm.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : 3
+ print a
+}
+
+# comments/qmcol-colon.awk
+BEGIN {
+ a = 1 ? 2 : # colon comment
+ 3
+ print a
+}
+
+# comments/qmcolboth.awk
+BEGIN {
+ a = 1 ? # qm comment
+ 2 : # colon comment
+ 3
+ print a
+}
+
+# test beginning of line block comments (com2.awk)
+BEGIN {
+ print "hi" # comment 1
+ # comment 2
+ print "there"
+ if (foo) {
+ print "hello" # comment 3
+ # comment 4
+ print "world"
+ }
+}
+
+# comments/exp.awk
+# range comment
+# range comment 2
+
+# range comment b
+
+# range comment c
+/foo/, /bar/ {
+ print
+}
+
+
+# comments2/f.awk
+function bar(p1, p2)
+{
+ print "foo"
+}
+
+# rbrace eol bar
+
+# rbrace block bar
+
+# comments2/function.awk
+
+# comment
+
+# comment before braces
+function baz(p1, p2)
+{
+ # lbrace eol
+ # lbrace block
+ print "foo"
+}
+
+# rbrace EOL comment funnyhaha
+
+# rbrace block comment funnyhaha
+
+# comments/callcoma.awk
+function callme(a, b, c)
+{
+ printf "a = %s, b = %s, c = %s\n", # format comment
+ a, # a2 comment
+ b, # b2 comment
+ c
+}
+
+# rbrace eol baz
+
+# rbrace block baz
+
+# comments/function.awk
+
+# param comment 1
+
+# param comment 2
+
+# Comment between header and body
+function funny(param1, param2, param3, param4)
+{
+ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+}
+
+# rbrace EOL comment funny
+
+# rbrace block comment funny
+
+# comments/function2.awk
+function funnyhaha(param1, param2, param3, param4)
+{
+ # lbrace EOL comment
+ # lbrace block comment
+ print "funny"
+}
diff --git a/test/profile5.ok b/test/profile5.ok
index c8abf1fb..e15e96a2 100644
--- a/test/profile5.ok
+++ b/test/profile5.ok
@@ -3,7 +3,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { ############################################################################
BINMODE = "rw"
SUBSEP = "\000"
_NULARR[""]
@@ -24,7 +24,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
_delay_perfmsdelay = 11500
}
@@ -36,12 +36,13 @@ BEGIN {
BEGIN {
}
-BEGIN { ###########################################################################
+###########################################################################
+BEGIN {
_addlib("_EXTFN")
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
delete _XCHR
delete _ASC
delete _CHR
@@ -101,7 +102,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
_SYS_STDCON = "CON"
_CON_WIDTH = match(_cmd("MODE " _SYS_STDCON " 2>NUL"), /Columns:[ \t]*([0-9]+)/, A) ? strtonum(A[1]) : 80
}
@@ -111,7 +112,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
if (_SYS_STDOUT == "") {
_SYS_STDOUT = "/dev/stdout"
}
@@ -133,7 +134,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
_tInBy = "\212._tInBy"
_tgenuid_init()
_UIDS[""]
@@ -165,7 +166,7 @@ BEGIN {
}
#___________________________________________________________________________________
-BEGIN {
+BEGIN { #############################################################################
if (_gawk_scriptlevel < 1) {
_ERRLOG_TF = 1
_ERRLOG_VF = 1
@@ -186,7 +187,8 @@ BEGIN {
_shortcut_init()
}
-BEGIN { #########################################################
+#########################################################
+BEGIN {
_addlib("_eXTFN")
}
@@ -195,7 +197,8 @@ BEGIN {
_extfn_init()
}
-BEGIN { ############################################################
+############################################################
+BEGIN {
_addlib("_sHARE")
}
@@ -282,7 +285,7 @@ BEGIN {
#BootDevice BuildNumber BuildType Caption CodeSet CountryCode CreationClassName CSCreationClassName CSDVersion CSName CurrentTimeZone DataExecutionPrevention_32BitApplications DataExecutionPrevention_Available DataExecutionPrevention_Drivers DataExecutionPrevention_SupportPolicy Debug Description Distributed EncryptionLevel ForegroundApplicationBoost FreePhysicalMemory FreeSpaceInPagingFiles FreeVirtualMemory InstallDate LargeSystemCache LastBootUpTime LocalDateTime Locale Manufacturer MaxNumberOfProcesses MaxProcessMemorySize MUILanguages Name NumberOfLicensedUsers NumberOfProcesses NumberOfUsers OperatingSystemSKU Organization OSArchitecture OSLanguage OSProductSuite OSType OtherTypeDescription PAEEnabled PlusProductID PlusVersionNumber Primary ProductType RegisteredUser SerialNumber ServicePackMajorVersion ServicePackMinorVersion SizeStoredInPagingFiles Status SuiteMask SystemDevice SystemDirectory SystemDrive TotalSwapSpaceSize TotalVirtualMemorySize TotalVisibleMemorySize Version WindowsDirectory
#\Device\HarddiskVolume1 7601 Multiprocessor Free Microsoft Windows Server 2008 R2 Enterprise 1252 1 Win32_OperatingSystem Win32_ComputerSystem Service Pack 1 CPU 180 TRUE TRUE TRUE 3 FALSE FALSE 256 0 6925316 33518716 41134632 20110502192745.000000+180 20130426120425.497469+180 20130510134606.932000+180 0409 Microsoft Corporation -1 8589934464 {"en-US"} Microsoft Windows Server 2008 R2 Enterprise |C:\Windows|\Device\Harddisk0\Partition2 0 116 2 10 64-bit 1033 274 18 TRUE 3 Windows User 55041-507-2389175-84833 1 0 33554432 OK 274 \Device\HarddiskVolume2 C:\Windows\system32 C: 50311020 16758448 6.1.7601 C:\Windows
-BEGIN {
+BEGIN { ############################################################################
a = ENVIRON["EGAWK_CMDLINE"]
gsub(/^[ \t]*/, "", a)
a = _lib_CMDLN(a)
@@ -302,13 +305,13 @@ BEGIN {
}
#_____________________________________________________________________________
-END {
+END { ########################################################################
_EXIT()
}
#_______________________________________________________________________
########################################################################
-END {
+END { ###############################################################################
if (_gawk_scriptlevel < 1) {
close(_errlog_file)
p = _Zimport(_rdfile(_errlog_file), _N())
@@ -329,7 +332,7 @@ END {
#_____________________________________________________________________________
# _rQBRO(ptr) - Returns brothers total quantity. [TESTED]
# If !ptr then returns "".
-END {
+END { ###############################################################################
if (_gawk_scriptlevel < 1) {
if (! _fileio_notdeltmpflag) {
_FILEIO_TMPATHS[_FILEIO_TMPRD]
@@ -629,7 +632,7 @@ END {
# var _gawk_scriptlevel
#___________________________________________________________________________________
####################################################################################
-END {
+END { ###############################################################################
if (_constatstrln > 0) {
_constat()
}
@@ -757,8 +760,8 @@ function _DS(c, t, P, a, A)
{
######################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #___________________________________________________________
return t
#_____________________________________________________
case "_lib_APPLY":
@@ -922,14 +925,15 @@ function _FILEIO(c, t, P, A)
}
############################################################
+
+#_____________________________________________________________________________
function _FILEVER(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -1494,11 +1498,13 @@ function _addlist(A, v)
}
############################################
+
+#_______________________________________________________________________
function _bearray(A)
{
- #_______________________________________________________________________
+ ####################################################
if (isarray(A) || (A == 0 && A == "")) {
- return 1 ####################################################
+ return 1
}
}
@@ -2534,10 +2540,12 @@ function _ffaccr(A, t, p, P)
}
##################
+
+#_______________________________________________________________________
function _fframe(A, t, p)
{
- #_______________________________________________________________________
- return _fframe_i0(A, t, p, A[""]) #################################################
+ #################################################
+ return _fframe_i0(A, t, p, A[""])
}
#___________________________________________________________
@@ -2874,14 +2882,15 @@ function _formatstrd_init()
}
#__________________________________________________________________________________
+
+####################################################################################
+
+
+
+
+#___________________________________________________________________________________
function _formatstrs(t)
{
- ####################################################################################
-
-
-
-
- #___________________________________________________________________________________
_formatstrq0 = split(t, _FORMATSTRA, /['\x00-\x1F\x80-\xFF]/, _FORMATSTRB)
_formatstrs0 = ""
for (t = 1; t < _formatstrq0; t++) {
@@ -3026,8 +3035,8 @@ function _getchrln(s, w)
#################################################
if (s == "") {
return
+ #if ( w!=w+0 || w<0 ) w=_CON_WIDTH
}
- #if ( w!=w+0 || w<0 ) w=_CON_WIDTH
if (length(s) < w) {
if (s in _GETCHRLN) {
if (length(_getchrlnt0 = _GETCHRLN[s]) >= w) {
@@ -3453,9 +3462,10 @@ function _insframe(A, f)
}
########################
+
+#_________________________________________________________________
function _inspass(A, f)
{
- #_________________________________________________________________
A[f] = A[""]
A[""] = f
}
@@ -3782,9 +3792,10 @@ function _newdir(f)
}
##############################
+
+#_______________________________________________________________________
function _nop(p0, p1, p2, p3)
{
- #_______________________________________________________________________
}
#_____________________________________________________
@@ -4202,14 +4213,15 @@ function _qstrq(t)
}
################################################################
+
+#_____________________________________________________________________________
function _rEG(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #####################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #####################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -4255,10 +4267,12 @@ function _rFCHLD(p)
}
######################## p="", !v
+
+#_______________________________________________________________________
function _rLBRO(p)
{
- #_______________________________________________________________________
- if (p) { ######################################################
+ ######################################################
+ if (p) {
if (p in _tPARENT) {
return _tLCHLD[_tPARENT[p]]
}
@@ -4271,10 +4285,12 @@ function _rLBRO(p)
}
######################## p=""
+
+#_______________________________________________________________________
function _rLCHLD(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tLCHLD)) { #####################################################
+ #####################################################
+ if ((p) && (p in _tLCHLD)) {
return _tLCHLD[p]
}
return ""
@@ -4288,40 +4304,48 @@ function _rLINK(p)
}
######################## p=""
+
+#_______________________________________________________________________
function _rNEXT(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tNEXT)) { ######################################################
+ ######################################################
+ if ((p) && (p in _tNEXT)) {
return _tNEXT[p]
}
return ""
}
######################## p=""
+
+#_______________________________________________________________________
function _rPARENT(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tPARENT)) { ####################################################
+ ####################################################
+ if ((p) && (p in _tPARENT)) {
return _tPARENT[p]
}
return ""
}
######################## p=""
+
+#_______________________________________________________________________
function _rPREV(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tPREV)) { ######################################################
+ ######################################################
+ if ((p) && (p in _tPREV)) {
return _tPREV[p]
}
return ""
}
######################## p=""
+
+#_______________________________________________________________________
function _rQBRO(p, c, p1)
{
- #_______________________________________________________________________
- if (p) { ################################################
+ ################################################
+ if (p) {
if (p in _tPARENT) {
return _tQCHLD[_tPARENT[p]]
}
@@ -4341,10 +4365,12 @@ function _rQBRO(p, c, p1)
}
######################## p=""
+
+#_______________________________________________________________________
function _rQCHLD(p)
{
- #_______________________________________________________________________
- if ((p) && (p in _tQCHLD)) { #####################################################
+ #####################################################
+ if ((p) && (p in _tQCHLD)) {
return _tQCHLD[p]
}
return ""
@@ -4909,14 +4935,15 @@ function _rxpfn(R, t, p, i, f, A)
}
##############################################################
+
+#_____________________________________________________________________________
function _sHARE(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ ###################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- ###################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -4936,14 +4963,15 @@ function _sHARE(c, t, P, a, A)
}
################################################################
+
+#_____________________________________________________________________________
function _sYS(c, t, P, a, A)
{
- #_____________________________________________________________________________
+ #####################################################
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #####################################################
return t
- #___________________________________________________________
#_____________________________________________________
case "_lib_APPLY":
return
@@ -5004,9 +5032,9 @@ function _setmpath(p, a)
if ((p) && (a = _filerd(p))) {
if (_FILEIO_TMPRD) {
_FILEIO_TMPATHS[_FILEIO_TMPRD]
+ #if ( _filexist(a) ) _del(a)
+ #_cmd("rd " a " /S /Q 2>NUL"); _cmd("del " a " /Q 2>NUL")
}
- #if ( _filexist(a) ) _del(a)
- #_cmd("rd " a " /S /Q 2>NUL"); _cmd("del " a " /Q 2>NUL")
return (_FILEIO_TMPRD = a)
} else {
return _warning("`" p "': cannot set temporary folder" (ERRNO ? (": " ERRNO) : ""))
@@ -5051,27 +5079,26 @@ function _shortcut(D, S)
if (isarray(D)) {
if (isarray(S)) {
_addarrmask(D, S, _SHORTCUTWSTRUC)
- } else if (S == 0 && S == "") { # array,array2* - copy from array2 to array shorcut-specific elements
- _addarrmask(D, _SHORTCUTDEFAULT, _SHORTCUTWSTRUC)
- } else if (_isnotfileptr(S)) { # array* - define shortcut-specific elements in array by default values
- _addarrmask(D, _[S], _SHORTCUTWSTRUC)
+ } else if (S == 0 && S == "") {
+ _addarrmask(D, _SHORTCUTDEFAULT, _SHORTCUTWSTRUC) # array,array2* - copy from array2 to array shorcut-specific elements
+ } else if (_isnotfileptr(S)) {
+ _addarrmask(D, _[S], _SHORTCUTWSTRUC) # array* - define shortcut-specific elements in array by default values
} else if (_rd_shortcut(D, S)) {
- return # array,ptr* - copy from array _[ptr] to array shorcut-specific elements
- }
+ return
+ } # array,ptr* - copy from array _[ptr] to array shorcut-specific elements
} else if (D == 0 && D == "") {
- return _NOP # array,filepath* - define in array shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
- # -* - no action(return -)
+ return _NOP # -* - no action(return -)
} else if (_isnotfileptr(D)) {
if (isarray(S)) {
- _addarrmask(_[D], S, _SHORTCUTWSTRUC)
- } else if (S == 0 && S == "") { # ptr,array* - copy from array to array _[ptr] shorcut-specific elements
- _addarrmask(_[D], _SHORTCUTDEFAULT, _SHORTCUTWSTRUC)
- } else if (_isnotfileptr(S)) { # ptr* - define shortcut-specifc elements in array _[ptr] by default values
- _addarrmask(_[D], _[S], _SHORTCUTWSTRUC)
+ _addarrmask(_[D], S, _SHORTCUTWSTRUC) # array,filepath* - define in array shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ } else if (S == 0 && S == "") {
+ _addarrmask(_[D], _SHORTCUTDEFAULT, _SHORTCUTWSTRUC) # ptr,array* - copy from array to array _[ptr] shorcut-specific elements
+ } else if (_isnotfileptr(S)) {
+ _addarrmask(_[D], _[S], _SHORTCUTWSTRUC) # ptr* - define shortcut-specifc elements in array _[ptr] by default values
} else if (_rd_shortcut(_[D], S)) {
- return # ptr,ptr2* - copy from array _[ptr2] to array _[ptr] shorcut-specific elements
- }
- } else { # ptr,filepath* - define in array _[ptr] shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ return
+ } # ptr,ptr2* - copy from array _[ptr2] to array _[ptr] shorcut-specific elements
+ } else {
if (isarray(S) && _wr_shortcut(D, S)) {
return # filepath,array* - [over]write shorcut file filepath; shortcut parameters will be defined by shortcut-specific elements in array(save shortcut)
} else if (S == 0 && S == "" && _wr_shortcut(D, _SHORTCUTDEFAULT)) {
@@ -5080,7 +5107,8 @@ function _shortcut(D, S)
return # filepath,ptr* - [over]write shorcut file filepath; shortcut parameters will be defined by shortcut-specific elements in array _[ptr](save shortcut)
} else if (_rd_shortcut(_SHRTCUTA1, S) || _wr_shortcut(D, _SHRTCUTA1)) {
return
- } } # filepath,filepath2* - [over]write shorcut file filepath; shortcut parameters will be defined from shortcut file filepath2(copy shortcut)
+ } # ptr,filepath* - define in array _[ptr] shortcut-specific elements by reading its from shortcut file filepath(load shortcut)
+ } # filepath,filepath2* - [over]write shorcut file filepath; shortcut parameters will be defined from shortcut file filepath2(copy shortcut)
return 1
}
@@ -5433,8 +5461,8 @@ function _sysinfo(D, h)
function _tOBJ(c, t, P)
{
switch (c) {
+ #___________________________________________________________
case "_lib_CMDLN":
- #___________________________________________________________
return t
#___________________________________________________________
case "_lib_APPLY":
@@ -6291,30 +6319,34 @@ function _th0(p, p1, p2, p3)
}
##########################################
+
+#_________________________________________________________________
function _th1(p0, p, p2, p3)
{
- #_________________________________________________________________
return p
}
##############################
+
+#_________________________________________________________________
function _th10(p0, p1)
{
- #_________________________________________________________________
return (p1 p0)
}
##############################
+
+#_________________________________________________________________
function _th2(p0, p1, r, p3)
{
- #_________________________________________________________________
return p
}
##############################
+
+#_________________________________________________________________
function _th3(p0, p1, p2, r)
{
- #_________________________________________________________________
return p
}
@@ -7234,10 +7266,10 @@ function _wFBRO(p, v, a)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7325,10 +7357,10 @@ function _wFCHLD(p, v, a)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v="" > ignore action
return v
}
}
@@ -7436,10 +7468,10 @@ function _wLBRO(p, v, a)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7527,10 +7559,10 @@ function _wLCHLD(p, v, a)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v="" > ignore action
return v
}
}
@@ -7606,10 +7638,10 @@ function _wNEXT(p, v, a, b)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7688,10 +7720,10 @@ function _wPREV(p, v, a, b)
} ######################## p=ptr, v=0
return v
}
- } else { ######################## p=ptr, v=""
+ } else {
if (p == 0) {
return v ######################## p=0
- }
+ } ######################## p=ptr, v=""
if (v) {
return _texclude(v) ######################## p="", v=ptr - exclude v
}
@@ -7712,10 +7744,10 @@ function _wQCHLD(p, v)
#############################################
if (p) {
if (v) {
- } else { ######################## p=ptr, v=ptr
+ } else {
if (v == 0) {
if (p in _tFCHLD) { ######################## p=ptr, v=0 > delete all chld
- v = _tFCHLD[p]
+ v = _tFCHLD[p] ######################## p=ptr, v=ptr
delete _tFCHLD[p]
delete _tLCHLD[p]
delete _tQCHLD[p]
@@ -7726,9 +7758,9 @@ function _wQCHLD(p, v)
}
return v
}
- } else { ######################## p=ptr, v="" > ignore action
+ } else {
if (p == 0) {
- return v
+ return v ######################## p=ptr, v="" > ignore action
} ######################## p=0
return v
}