From f00e74ffc73f6ba6fe74fb7a26319770b8c3792c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Apr 2022 07:00:15 -0700 Subject: @let: allow trailing comma. We allow forms like @let(x,) and @let(x, y=1,) with the trailing comma. This is helpful for code generators and macros, which can then treat temporary variables as comma-terminated items. * awkgram.y (let_var_list_opt): Add a production which matches a trailing comma after let_var_list. * test/let1.awk, test/let1.ok: Test cases. * doc/gawkt.texi, doc/gawktexi.in: Trailing comma documented. * awkgram.c: Regenerated with Bison 3.8. --- test/let1.awk | 14 ++++++++++++++ test/let1.ok | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'test') diff --git a/test/let1.awk b/test/let1.awk index 413b6e1e..268222df 100644 --- a/test/let1.awk +++ b/test/let1.awk @@ -157,3 +157,17 @@ BEGIN { @let (x = 1, y = 2) { print "b6", x, y } @let (x = 1, y = 2, z = 3) { print "b6", x, y, z } } + +function f6() +{ + @let (x = 1) { print "f6", x } + @let (x = 1, y = 2,) { print "f6", x, y } + @let (x = 1, y = 2, z = 3,) { print "f6", x, y, z } +} + +BEGIN { + f6() + @let (x = 1) { print "b7", x } + @let (x = 1, y = 2,) { print "b7", x, y } + @let (x = 1, y = 2, z = 3,) { print "b7", x, y, z } +} diff --git a/test/let1.ok b/test/let1.ok index f3336775..70de9024 100644 --- a/test/let1.ok +++ b/test/let1.ok @@ -9,3 +9,9 @@ f5 1 2 3 b6 1 b6 1 2 b6 1 2 3 +f6 1 +f6 1 2 +f6 1 2 3 +b7 1 +b7 1 2 +b7 1 2 3 -- cgit v1.2.3