1
0

Add yield syntax

This commit is contained in:
Jeff 2023-11-14 22:26:32 -05:00
parent 60013f34da
commit 1d6b49ba25
5 changed files with 12906 additions and 11861 deletions

View File

@ -0,0 +1,15 @@
================================================================================
Simple Yield
================================================================================
1 -> (output)
--------------------------------------------------------------------------------
================================================================================
Yield Chain
================================================================================
x -> (foo) -> (bar) -> (abc)
--------------------------------------------------------------------------------

View File

@ -42,6 +42,12 @@ module.exports = grammar({
optional(';'), optional(';'),
)), )),
yield: $ => prec.left(seq(
$.expression,
'->',
$.function_call,
)),
expression: $ => prec.right(choice( expression: $ => prec.right(choice(
$._expression_kind, $._expression_kind,
seq('(', $._expression_kind, ')'), seq('(', $._expression_kind, ')'),
@ -54,6 +60,7 @@ module.exports = grammar({
$.logic, $.logic,
$.math, $.math,
$.value, $.value,
$.yield,
), ),
_expression_list: $ => repeat1(prec.right(seq( _expression_list: $ => repeat1(prec.right(seq(

View File

@ -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": { "expression": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
"value": 0, "value": 0,
@ -191,6 +212,10 @@
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "value" "name": "value"
},
{
"type": "SYMBOL",
"name": "yield"
} }
] ]
}, },

View File

@ -127,6 +127,10 @@
{ {
"type": "value", "type": "value",
"named": true "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": "!=", "type": "!=",
"named": false "named": false
@ -790,6 +813,10 @@
"type": "-=", "type": "-=",
"named": false "named": false
}, },
{
"type": "->",
"named": false
},
{ {
"type": "..", "type": "..",
"named": false "named": false

File diff suppressed because it is too large Load Diff