Add support for 'select' loops.
This commit is contained in:
parent
af9646bad9
commit
c79d2377d4
|
@ -125,6 +125,41 @@ done
|
||||||
name: (variable_name)
|
name: (variable_name)
|
||||||
value: (raw_string)))))
|
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
|
C-style for statements
|
||||||
====================================
|
====================================
|
||||||
|
|
|
@ -114,7 +114,7 @@ module.exports = grammar({
|
||||||
)),
|
)),
|
||||||
|
|
||||||
for_statement: $ => seq(
|
for_statement: $ => seq(
|
||||||
'for',
|
choice('for', 'select'),
|
||||||
field('variable', $._simple_variable_name),
|
field('variable', $._simple_variable_name),
|
||||||
optional(seq(
|
optional(seq(
|
||||||
'in',
|
'in',
|
||||||
|
|
Loading…
Reference in New Issue