diff --git a/corpus/statements.txt b/corpus/statements.txt index 4c9de32..8ed98aa 100644 --- a/corpus/statements.txt +++ b/corpus/statements.txt @@ -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 ==================================== diff --git a/grammar.js b/grammar.js index 458b044..92036a0 100644 --- a/grammar.js +++ b/grammar.js @@ -114,7 +114,7 @@ module.exports = grammar({ )), for_statement: $ => seq( - 'for', + choice('for', 'select'), field('variable', $._simple_variable_name), optional(seq( 'in',