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)
|
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',
|
||||||
|
|
|
@ -265,8 +265,17 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "CHOICE",
|
||||||
"value": "for"
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "for"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "select"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
|
|
|
@ -1611,6 +1611,10 @@
|
||||||
"type": "regex",
|
"type": "regex",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "special_variable_name",
|
"type": "special_variable_name",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue