Merge pull request #111 from tree-sitter/mj-select

Support for 'select' loops
This commit is contained in:
Martin Jambon 2021-10-10 01:14:12 -07:00 committed by GitHub
commit 30d369ba45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 105316 additions and 105017 deletions

View File

@ -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
====================================

View File

@ -114,7 +114,7 @@ module.exports = grammar({
)),
for_statement: $ => seq(
'for',
choice('for', 'select'),
field('variable', $._simple_variable_name),
optional(seq(
'in',

13
src/grammar.json vendored
View File

@ -265,8 +265,17 @@
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "for"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "for"
},
{
"type": "STRING",
"value": "select"
}
]
},
{
"type": "FIELD",

4
src/node-types.json vendored
View File

@ -1611,6 +1611,10 @@
"type": "regex",
"named": true
},
{
"type": "select",
"named": false
},
{
"type": "special_variable_name",
"named": true

210279
src/parser.c vendored

File diff suppressed because it is too large Load Diff