diff --git a/corpus/control_flow.txt b/corpus/control_flow.txt index a77f47e..5891288 100644 --- a/corpus/control_flow.txt +++ b/corpus/control_flow.txt @@ -16,6 +16,24 @@ done (command (command_name (word)) (word)) (command (command_name (word)) (word))))) +==================================== +While statements with IO redirects +==================================== + +while read line; do + echo $line +done < <(cat file) + +--- + +(program + (while_statement + (command (command_name (word)) (word)) + (do_group + (command (command_name (word)) (simple_expansion (variable_name)))) + (file_redirect (process_substitution + (command (command_name (word)) (word)))))) + ==================================== For statements ==================================== diff --git a/grammar.js b/grammar.js index 2db3d08..dea9244 100644 --- a/grammar.js +++ b/grammar.js @@ -78,7 +78,12 @@ module.exports = grammar({ while_statement: $ => seq( 'while', $._terminated_statement, - $.do_group + $.do_group, + repeat(choice( + $.file_redirect, + $.heredoc_redirect, + $.herestring_redirect + )) ), do_group: $ => seq(