aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-10-17 21:42:34 +0300
committerArnold D. Robbins <arnold@skeeve.com>2018-10-17 21:42:34 +0300
commit6e1521ee04ea12f551f8c98d669b13ab13a25a8c (patch)
treea7db3116704ba2edac5804e418d89101cd5f8fc5 /awkgram.y
parent5c7402f68fb31d70f78243c4d6d9c30a8e8aa9da (diff)
downloadegawk-6e1521ee04ea12f551f8c98d669b13ab13a25a8c.tar.gz
egawk-6e1521ee04ea12f551f8c98d669b13ab13a25a8c.tar.bz2
egawk-6e1521ee04ea12f551f8c98d669b13ab13a25a8c.zip
Handle comments after the `;' in for loops.
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y28
1 files changed, 28 insertions, 0 deletions
diff --git a/awkgram.y b/awkgram.y
index 5aad5afa..208fe62b 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -924,6 +924,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--;
@@ -931,6 +945,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--;