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

View File

@ -14,36 +14,40 @@
"value": "[#][^#\\n]*[#|\\n]"
},
"block": {
"type": "CHOICE",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
},
{
"type": "STRING",
"value": "}"
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
},
{
"type": "STRING",
"value": "}"
}
]
}
]
}
},
"statement": {
"type": "PREC_RIGHT",
@ -186,6 +190,10 @@
{
"type": "SYMBOL",
"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": {
"type": "SEQ",
"members": [
@ -1445,9 +1474,6 @@
}
],
"conflicts": [
[
"block"
],
[
"map",
"assignment_operator"

View File

@ -142,6 +142,10 @@
{
"type": "value",
"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": "!=",
"named": false
@ -778,6 +801,10 @@
"type": "-=",
"named": false
},
{
"type": "->",
"named": false
},
{
"type": "..",
"named": false

File diff suppressed because it is too large Load Diff