1
0

Add yield to grammar

This commit is contained in:
Jeff 2023-11-10 18:44:56 -05:00
parent 020ebd8833
commit 71c169a1cf
4 changed files with 78464 additions and 77576 deletions

View File

@ -6,7 +6,6 @@ module.exports = grammar({
extras: $ => [ /\s/, $._comment ], extras: $ => [ /\s/, $._comment ],
conflicts: $ => [ conflicts: $ => [
[$.block],
[$.map, $.assignment_operator], [$.map, $.assignment_operator],
], ],
@ -15,10 +14,10 @@ module.exports = grammar({
_comment: $ => /[#][^#\n]*[#|\n]/, _comment: $ => /[#][^#\n]*[#|\n]/,
block: $ => choice( block: $ => prec.right(choice(
repeat1($.statement), repeat1($.statement),
seq('{', repeat1($.statement), '}'), seq('{', repeat1($.statement), '}'),
), )),
statement: $ => prec.right(seq( statement: $ => prec.right(seq(
choice( choice(
@ -52,6 +51,7 @@ module.exports = grammar({
$.logic, $.logic,
$.math, $.math,
$.value, $.value,
$.yield,
)), )),
_expression_list: $ => repeat1(prec.right(seq($.expression, optional(',')))), _expression_list: $ => repeat1(prec.right(seq($.expression, optional(',')))),
@ -287,6 +287,12 @@ module.exports = grammar({
$.expression, $.expression,
)), )),
yield: $ => prec.left(seq(
$.expression,
'->',
$.function_call,
)),
function: $ => seq( function: $ => seq(
field('parameters', optional($.identifier_list)), field('parameters', optional($.identifier_list)),
'=>', '=>',

View File

@ -14,6 +14,9 @@
"value": "[#][^#\\n]*[#|\\n]" "value": "[#][^#\\n]*[#|\\n]"
}, },
"block": { "block": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -44,6 +47,7 @@
] ]
} }
] ]
}
}, },
"statement": { "statement": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -186,6 +190,10 @@
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "value" "name": "value"
},
{
"type": "SYMBOL",
"name": "yield"
} }
] ]
} }
@ -1208,6 +1216,27 @@
] ]
} }
}, },
"yield": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "->"
},
{
"type": "SYMBOL",
"name": "function_call"
}
]
}
},
"function": { "function": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -1445,9 +1474,6 @@
} }
], ],
"conflicts": [ "conflicts": [
[
"block"
],
[ [
"map", "map",
"assignment_operator" "assignment_operator"

View File

@ -142,6 +142,10 @@
{ {
"type": "value", "type": "value",
"named": true "named": true
},
{
"type": "yield",
"named": true
} }
] ]
} }
@ -734,6 +738,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
@ -778,6 +801,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