Begin implementing while loops

This commit is contained in:
Jeff 2023-10-06 22:45:27 -04:00
parent a3dbb19ecc
commit b55420d51b
5 changed files with 9896 additions and 5057 deletions

52
corpus/while.txt Normal file
View File

@ -0,0 +1,52 @@
==================
While Loop
==================
while true {
(output "This is a bad idea...")
}
---
(root
(item
(statement
(while
(expression
(value
(boolean)))
(statement
(expression
(tool_call
(output
(expression
(value
(string)))))))))))
==================
While Assignment
==================
foo = while true {
42
}
---
(root
(item
(statement
(assignment
(identifier)
(statement
(while
(expression
(value
(boolean)))
(statement
(expression
(tool_call
(output
(expression
(value
(string)))))))))))))

View File

@ -22,6 +22,7 @@ module.exports = grammar({
$.select,
$.loop,
$.match,
$.while,
),
yield: $ => seq(

View File

@ -69,6 +69,10 @@
{
"type": "SYMBOL",
"name": "match"
},
{
"type": "SYMBOL",
"name": "while"
}
]
},

View File

@ -382,6 +382,10 @@
"type": "select",
"named": true
},
{
"type": "while",
"named": true
},
{
"type": "yield",
"named": true
@ -470,6 +474,25 @@
]
}
},
{
"type": "while",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "statement",
"named": true
}
]
}
},
{
"type": "yield",
"named": true,

14873
src/parser.c

File diff suppressed because it is too large Load Diff