Shell: Add support for enumerating lists in for loops

With some odd syntax to boot:
```sh
$ for index i x in $whatever {}
```
This commit is contained in:
AnotherTest 2021-03-05 18:25:09 +03:30 committed by Andreas Kling
commit 13b65b632a
Notes: sideshowbarker 2024-07-18 21:39:42 +09:00
8 changed files with 133 additions and 23 deletions

View file

@ -207,7 +207,7 @@ control_structure[c] :: for_expr
continuation_control :: 'break'
| 'continue'
for_expr :: 'for' ws+ (identifier ' '+ 'in' ws*)? expression ws+ '{' [c] toplevel '}'
for_expr :: 'for' ws+ (('index' ' '+ identifier ' '+)? identifier ' '+ 'in' ws*)? expression ws+ '{' [c] toplevel '}'
loop_expr :: 'loop' ws* '{' [c] toplevel '}'