favor return over return _ (void return); newline/closing terminates
This commit is contained in:
@@ -262,15 +262,13 @@ module.exports = grammar({
|
||||
|
||||
expression_statement: $ => $.expression,
|
||||
|
||||
return_statement: $ => seq(
|
||||
return_statement: $ => prec.right(seq(
|
||||
'return',
|
||||
repeat($._newline),
|
||||
field('value', $._value),
|
||||
),
|
||||
optional(field('value', $._value)),
|
||||
)),
|
||||
|
||||
yield_statement: $ => seq(
|
||||
'yield',
|
||||
repeat($._newline),
|
||||
optional(seq(':', field('label', $.identifier))),
|
||||
field('value', $._value),
|
||||
),
|
||||
|
||||
@@ -1714,28 +1714,33 @@
|
||||
"name": "expression"
|
||||
},
|
||||
"return_statement": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "return"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "return"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "value",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "value",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_value"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"yield_statement": {
|
||||
"type": "SEQ",
|
||||
@@ -1744,13 +1749,6 @@
|
||||
"type": "STRING",
|
||||
"value": "yield"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
||||
@@ -1667,7 +1667,7 @@
|
||||
"fields": {
|
||||
"value": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
|
||||
+92004
-94856
File diff suppressed because it is too large
Load Diff
@@ -154,3 +154,56 @@ work func() i32 ! Failure {
|
||||
(return_statement
|
||||
(expression
|
||||
(integer)))))))
|
||||
|
||||
==================
|
||||
Bare return and value yield
|
||||
==================
|
||||
|
||||
done func() void {
|
||||
return
|
||||
}
|
||||
|
||||
inline func() void { return }
|
||||
|
||||
choose func() i32 {
|
||||
result :: { yield 1 }
|
||||
return result
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(function_declaration
|
||||
(identifier)
|
||||
(parameter_list)
|
||||
(type
|
||||
(builtin_type))
|
||||
(block
|
||||
(statement
|
||||
(return_statement))))
|
||||
(function_declaration
|
||||
(identifier)
|
||||
(parameter_list)
|
||||
(type
|
||||
(builtin_type))
|
||||
(block
|
||||
(statement
|
||||
(return_statement))))
|
||||
(function_declaration
|
||||
(identifier)
|
||||
(parameter_list)
|
||||
(type
|
||||
(builtin_type))
|
||||
(block
|
||||
(statement
|
||||
(constant_declaration
|
||||
(identifier)
|
||||
(block
|
||||
(statement
|
||||
(yield_statement
|
||||
(expression
|
||||
(integer)))))))
|
||||
(statement
|
||||
(return_statement
|
||||
(expression
|
||||
(identifier)))))))
|
||||
|
||||
Reference in New Issue
Block a user