Add support for 'select' loops.

This commit is contained in:
Martin Jambon 2021-10-09 02:44:05 -07:00
parent af9646bad9
commit c79d2377d4
2 changed files with 36 additions and 1 deletions

View File

@ -125,6 +125,41 @@ done
name: (variable_name)
value: (raw_string)))))
====================================
Select statements
====================================
select choice in X Y $(ls); do
echo $choice
break
done
select ARG; do
echo $ARG
ARG=''
done
---
(program
(for_statement
(variable_name)
(word)
(word)
(command_substitution (command (command_name (word))))
(do_group
(command
(command_name (word))
(simple_expansion (variable_name)))
(command (command_name (word)))))
(for_statement
(variable_name)
(do_group
(command
(command_name (word))
(simple_expansion (variable_name)))
(variable_assignment (variable_name) (raw_string)))))
====================================
C-style for statements
====================================

View File

@ -114,7 +114,7 @@ module.exports = grammar({
)),
for_statement: $ => seq(
'for',
choice('for', 'select'),
field('variable', $._simple_variable_name),
optional(seq(
'in',