Merge pull request #111 from tree-sitter/mj-select
Support for 'select' loops
This commit is contained in:
commit
30d369ba45
|
@ -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
|
||||
====================================
|
||||
|
|
|
@ -114,7 +114,7 @@ module.exports = grammar({
|
|||
)),
|
||||
|
||||
for_statement: $ => seq(
|
||||
'for',
|
||||
choice('for', 'select'),
|
||||
field('variable', $._simple_variable_name),
|
||||
optional(seq(
|
||||
'in',
|
||||
|
|
|
@ -263,11 +263,20 @@
|
|||
},
|
||||
"for_statement": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "for"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "select"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "variable",
|
||||
|
|
|
@ -1611,6 +1611,10 @@
|
|||
"type": "regex",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "special_variable_name",
|
||||
"named": true
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue