aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.y
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-10-09 22:50:25 +0300
committerArnold D. Robbins <arnold@skeeve.com>2018-10-09 22:50:25 +0300
commit8e09dc452d7d365e13db28d1c6ca2b392f6df6ce (patch)
treeb5204624ced26d383d698a7d062d2302844ba50c /awkgram.y
parentd8234e1784bfbfd4d72dccc1412b962d38fec549 (diff)
downloadegawk-8e09dc452d7d365e13db28d1c6ca2b392f6df6ce.tar.gz
egawk-8e09dc452d7d365e13db28d1c6ca2b392f6df6ce.tar.bz2
egawk-8e09dc452d7d365e13db28d1c6ca2b392f6df6ce.zip
Fix empty statement handling.
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y17
1 files changed, 16 insertions, 1 deletions
diff --git a/awkgram.y b/awkgram.y
index 5ecb054c..8c358c92 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -1,3 +1,6 @@
+/* ALSO TODO:
+ * Fix debug.c
+ */
/* working on statement_term */
/*
TODO:
@@ -585,7 +588,16 @@ statement_term
statement
: semi opt_nls
- { $$ = $2; }
+ {
+ 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; }
| if_statement
@@ -6300,6 +6312,9 @@ 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;