diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-10-06 22:59:50 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-10-06 22:59:50 +0300 |
commit | a6c1a66946657f06b1bae08c9ea596befed5be2f (patch) | |
tree | 48f5d8e681684eadfb7f31ffc85b35ce84b50090 /awkgram.y | |
parent | 57e001a46bf4bb712a5a7bc835bde33dacf6a92a (diff) | |
download | egawk-a6c1a66946657f06b1bae08c9ea596befed5be2f.tar.gz egawk-a6c1a66946657f06b1bae08c9ea596befed5be2f.tar.bz2 egawk-a6c1a66946657f06b1bae08c9ea596befed5be2f.zip |
Improve handling of comments on braces for action rule.
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -415,14 +415,25 @@ action else ip = $2; - if ($1 != NULL) + if ($1 != NULL) { + INSTRUCTION *comment2 = $1->comment; + if (comment2 != NULL) { + ip = list_prepend(ip, comment2); + $1->comment = NULL; + } ip = list_prepend(ip, $1); + } /* Tack any comment onto the end. */ - if ($3 != NULL) + if ($3 != NULL) { ip = list_append(ip, $3); + if ($3->memory->comment_type == EOL_COMMENT) + $3->memory->comment_type = FULL_COMMENT; + } + if ($5 != NULL) ip = list_append(ip, $5); + $$ = ip; } ; @@ -459,9 +470,9 @@ function_prologue // with the function as one block comment. if ($5 != NULL && $5->comment != NULL) { if ($7 != NULL) { - merge_comments($5, $7); + merge_comments($5->comment, $7); } - func_comment = $5; + func_comment = $5->comment; } else if ($7 != NULL) { func_comment = $7; } @@ -1335,9 +1346,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; } |