bug fix
This commit is contained in:
@@ -39,6 +39,7 @@ module.exports = grammar({
|
||||
[$.field_initializer, $.expression],
|
||||
[$.capture_list, $.expression],
|
||||
[$.match_capture, $.expression],
|
||||
[$.statement, $.labeled_block],
|
||||
],
|
||||
|
||||
rules: {
|
||||
@@ -366,8 +367,8 @@ module.exports = grammar({
|
||||
seq('(', repeat($._newline), choice($.assignment_statement, $.expression_statement), repeat($._newline), ')'),
|
||||
)))),
|
||||
repeat($._newline),
|
||||
optional(seq(field('label', $.identifier), ':', repeat($._newline))),
|
||||
field('body', $.block),
|
||||
optional(prec(1, seq(field('label', $.identifier), ':', repeat($._newline)))),
|
||||
field('body', $._branch_body),
|
||||
),
|
||||
|
||||
for_statement: $ => seq(
|
||||
@@ -378,8 +379,8 @@ module.exports = grammar({
|
||||
repeat($._newline),
|
||||
$._for_capture_bar,
|
||||
optional('@'),
|
||||
field('item', $.identifier),
|
||||
optional(seq(',', field('index', $.identifier))),
|
||||
field('item', choice($.identifier, $.sink)),
|
||||
optional(seq(',', field('index', choice($.identifier, $.sink)))),
|
||||
$._for_capture_bar,
|
||||
repeat($._newline),
|
||||
optional(seq(field('label', $.identifier), ':', repeat($._newline))),
|
||||
|
||||
@@ -2581,28 +2581,32 @@
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "label",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "label",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_newline"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
@@ -2614,7 +2618,7 @@
|
||||
"name": "body",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
"name": "_branch_body"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -2680,8 +2684,17 @@
|
||||
"type": "FIELD",
|
||||
"name": "item",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sink"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2698,8 +2711,17 @@
|
||||
"type": "FIELD",
|
||||
"name": "index",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sink"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -5520,6 +5542,10 @@
|
||||
[
|
||||
"match_capture",
|
||||
"expression"
|
||||
],
|
||||
[
|
||||
"statement",
|
||||
"labeled_block"
|
||||
]
|
||||
],
|
||||
"precedences": [],
|
||||
|
||||
@@ -994,6 +994,10 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sink",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1004,6 +1008,10 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sink",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2469,7 +2477,7 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
|
||||
+1873105
-998460
File diff suppressed because it is too large
Load Diff
@@ -800,3 +800,43 @@ clear func($K, $V type) void {
|
||||
(identifier)))
|
||||
(expression
|
||||
(integer))))))))))
|
||||
|
||||
==================
|
||||
Sink for captures and braceless while
|
||||
==================
|
||||
|
||||
main func() void {
|
||||
for [1] |_, _| {}
|
||||
while (true) _ = 1
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(function_declaration
|
||||
(identifier)
|
||||
(parameter_list)
|
||||
(type
|
||||
(builtin_type))
|
||||
(block
|
||||
(statement
|
||||
(for_statement
|
||||
(expression
|
||||
(array_literal
|
||||
(expression
|
||||
(integer))))
|
||||
(sink)
|
||||
(sink)
|
||||
(block)))
|
||||
(statement
|
||||
(while_statement
|
||||
(expression
|
||||
(parenthesized_expression
|
||||
(expression
|
||||
(boolean))))
|
||||
(statement
|
||||
(assignment_statement
|
||||
(expression
|
||||
(sink))
|
||||
(expression
|
||||
(integer)))))))))
|
||||
|
||||
Reference in New Issue
Block a user