1
0

Move return syntax node to option for statements

This commit is contained in:
Jeff 2024-02-16 10:38:51 -05:00
parent 172a6fa860
commit 1ce2178af5
5 changed files with 24500 additions and 23987 deletions

View File

@ -39,12 +39,10 @@ Block with Return
(expression (expression
(value (value
(integer)))) (integer))))
(statement
(return
(statement (statement
(expression (expression
(value (value
(integer)))))) (integer))))
(statement (statement
(expression (expression
(value (value

View File

@ -14,6 +14,7 @@ module.exports = grammar({
statement: $ => statement: $ =>
prec.left( prec.left(
seq( seq(
optional('return'),
choice( choice(
$.assignment, $.assignment,
$.block, $.block,
@ -22,7 +23,6 @@ module.exports = grammar({
$.if_else, $.if_else,
$.index_assignment, $.index_assignment,
$.match, $.match,
$.return,
$.pipe, $.pipe,
$.while, $.while,
$.type_definition, $.type_definition,
@ -336,11 +336,6 @@ module.exports = grammar({
$.block, $.block,
), ),
return: $ =>
prec.right(
seq('return', $.statement),
),
type_specification: $ => type_specification: $ =>
seq('<', $.type, '>'), seq('<', $.type, '>'),

View File

@ -23,6 +23,18 @@
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "return"
},
{
"type": "BLANK"
}
]
},
{ {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
@ -54,10 +66,6 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "match" "name": "match"
}, },
{
"type": "SYMBOL",
"name": "return"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "pipe" "name": "pipe"
@ -1004,23 +1012,6 @@
} }
] ]
}, },
"return": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "return"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
}
},
"type_specification": { "type_specification": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -1199,27 +1190,6 @@
] ]
} }
] ]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "option"
},
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "type"
},
{
"type": "STRING",
"value": ")"
}
]
} }
] ]
} }

View File

@ -587,21 +587,6 @@
] ]
} }
}, },
{
"type": "return",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "statement",
"named": true
}
]
}
},
{ {
"type": "root", "type": "root",
"named": true, "named": true,
@ -657,10 +642,6 @@
"type": "pipe", "type": "pipe",
"named": true "named": true
}, },
{
"type": "return",
"named": true
},
{ {
"type": "type_definition", "type": "type_definition",
"named": true "named": true
@ -1054,10 +1035,6 @@
"type": "num", "type": "num",
"named": false "named": false
}, },
{
"type": "option",
"named": false
},
{ {
"type": "range", "type": "range",
"named": true "named": true

File diff suppressed because it is too large Load Diff