Add yield syntax
This commit is contained in:
parent
60013f34da
commit
1d6b49ba25
15
tree-sitter-dust/corpus/yield.txt
Normal file
15
tree-sitter-dust/corpus/yield.txt
Normal file
@ -0,0 +1,15 @@
|
||||
================================================================================
|
||||
Simple Yield
|
||||
================================================================================
|
||||
|
||||
1 -> (output)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
================================================================================
|
||||
Yield Chain
|
||||
================================================================================
|
||||
|
||||
x -> (foo) -> (bar) -> (abc)
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -42,6 +42,12 @@ module.exports = grammar({
|
||||
optional(';'),
|
||||
)),
|
||||
|
||||
yield: $ => prec.left(seq(
|
||||
$.expression,
|
||||
'->',
|
||||
$.function_call,
|
||||
)),
|
||||
|
||||
expression: $ => prec.right(choice(
|
||||
$._expression_kind,
|
||||
seq('(', $._expression_kind, ')'),
|
||||
@ -54,6 +60,7 @@ module.exports = grammar({
|
||||
$.logic,
|
||||
$.math,
|
||||
$.value,
|
||||
$.yield,
|
||||
),
|
||||
|
||||
_expression_list: $ => repeat1(prec.right(seq(
|
||||
|
@ -135,6 +135,27 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"yield": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "->"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "function_call"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
@ -191,6 +212,10 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "yield"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -127,6 +127,10 @@
|
||||
{
|
||||
"type": "value",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "yield",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -746,6 +750,25 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "yield",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "function_call",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "!=",
|
||||
"named": false
|
||||
@ -790,6 +813,10 @@
|
||||
"type": "-=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "->",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "..",
|
||||
"named": false
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user