Add async statements
This commit is contained in:
parent
0f58ea5a7a
commit
cf22950b7e
171
corpus/async.txt
171
corpus/async.txt
@ -10,14 +10,13 @@ async { (output 'Whaddup') }
|
||||
(item
|
||||
(statement
|
||||
(async
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
Complex Async Statements
|
||||
@ -25,7 +24,7 @@ Complex Async Statements
|
||||
|
||||
async {
|
||||
if 1 % 2 == 0 {
|
||||
(output 'true')
|
||||
(output 'true')
|
||||
} else {
|
||||
(output 'false')
|
||||
}
|
||||
@ -39,44 +38,132 @@ async {
|
||||
(item
|
||||
(statement
|
||||
(async
|
||||
(item
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
Simple Async Await Statements
|
||||
==================
|
||||
|
||||
x = async {
|
||||
1
|
||||
}
|
||||
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(async
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))
|
||||
|
||||
==================
|
||||
Complex Async Await Statements
|
||||
==================
|
||||
|
||||
x = async {
|
||||
i = 0
|
||||
while i < 5 {
|
||||
(output i)
|
||||
i += 1
|
||||
}
|
||||
(read "examples/assets/faithful.csv")
|
||||
}
|
||||
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(async
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(tool)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(value
|
||||
(string))))))))))))
|
||||
|
@ -236,6 +236,12 @@ module.exports = grammar({
|
||||
),
|
||||
)),
|
||||
|
||||
async: $ => seq('async', '{', $.item, '}'),
|
||||
async: $ => seq(
|
||||
'async',
|
||||
'{',
|
||||
repeat($.statement),
|
||||
'}'
|
||||
),
|
||||
|
||||
}
|
||||
});
|
@ -959,8 +959,11 @@
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "item"
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -32,11 +32,11 @@
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "item",
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
7673
src/parser.c
7673
src/parser.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user