From 92037a32a65b89b977d012047fc19255757f699b Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 22 Aug 2023 00:13:41 -0400 Subject: [PATCH] fix: (()) is allowed as a null value, a number's base might be an expansion --- grammar.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grammar.js b/grammar.js index 16f1741cf..91cdf7b75 100644 --- a/grammar.js +++ b/grammar.js @@ -353,7 +353,7 @@ module.exports = grammar({ choice( seq('[', choice($._expression, $.redirected_statement), ']'), seq('[[', $._expression, ']]'), - seq('(', '(', $._expression, '))'), + seq('(', '(', optional($._expression), '))'), ), ), @@ -661,7 +661,11 @@ module.exports = grammar({ ansi_c_string: _ => /\$'([^']|\\')*'/, - number: _ => /-?(0x)?[0-9]+(#[0-9A-Za-z@_]+)?/, + number: $ => choice( + /-?(0x)?[0-9]+(#[0-9A-Za-z@_]+)?/, + // the base can be an expansion + seq(/-?(0x)?[0-9]+#/, $.expansion), + ), simple_expansion: $ => seq( '$',