Merge pull request #112 from tree-sitter/mj-until
Add support for 'until' loops
This commit is contained in:
commit
7fb8506cbe
|
@ -53,6 +53,26 @@ done
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(while_statement
|
||||||
|
condition: (command
|
||||||
|
name: (command_name (word))
|
||||||
|
argument: (word))
|
||||||
|
body: (do_group
|
||||||
|
(command name: (command_name (word)) argument: (word))
|
||||||
|
(command name: (command_name (word)) argument: (word)))))
|
||||||
|
|
||||||
|
====================================
|
||||||
|
Until statements
|
||||||
|
====================================
|
||||||
|
|
||||||
|
until something happens; do
|
||||||
|
echo a
|
||||||
|
echo b
|
||||||
|
done
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
(program
|
(program
|
||||||
(while_statement
|
(while_statement
|
||||||
condition: (command
|
condition: (command
|
||||||
|
|
|
@ -141,7 +141,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
while_statement: $ => seq(
|
while_statement: $ => seq(
|
||||||
'while',
|
choice('while', 'until'),
|
||||||
field('condition', $._terminated_statement),
|
field('condition', $._terminated_statement),
|
||||||
field('body', $.do_group)
|
field('body', $.do_group)
|
||||||
),
|
),
|
||||||
|
|
|
@ -431,11 +431,20 @@
|
||||||
},
|
},
|
||||||
"while_statement": {
|
"while_statement": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "while"
|
"value": "while"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "until"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
"type": "FIELD",
|
||||||
"name": "condition",
|
"name": "condition",
|
||||||
|
|
|
@ -1639,6 +1639,10 @@
|
||||||
"type": "unsetenv",
|
"type": "unsetenv",
|
||||||
"named": false
|
"named": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "until",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "variable_name",
|
"type": "variable_name",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue