Fix statement recovery infinite loop
This commit is contained in:
@@ -1,17 +1,12 @@
|
|||||||
import c
|
import c
|
||||||
|
|
||||||
// Test
|
/// # Documentation
|
||||||
// Test2
|
/// ## Documentation subtitle
|
||||||
// Test3
|
|
||||||
// Test4
|
|
||||||
global func main(args: []string) {
|
global func main(args: []string) {
|
||||||
i = 0
|
i = 0
|
||||||
printf("%d\n", args.count)
|
printf("%d\n", args.count)
|
||||||
while i < args.count {
|
while i < args.count {
|
||||||
// Test
|
|
||||||
printf("%s\n", args[i])
|
printf("%s\n", args[i])
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
i: string = "test"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,20 +82,17 @@ public class Parser
|
|||||||
|
|
||||||
ExpectSymbol(Symbol.OpenParen);
|
ExpectSymbol(Symbol.OpenParen);
|
||||||
|
|
||||||
if (!TryExpectSymbol(Symbol.CloseParen))
|
while (!TryExpectSymbol(Symbol.CloseParen))
|
||||||
{
|
{
|
||||||
while (!TryExpectSymbol(Symbol.CloseParen))
|
parameters.Add(ParseFuncParameter());
|
||||||
{
|
|
||||||
parameters.Add(ParseFuncParameter());
|
|
||||||
|
|
||||||
if (!TryExpectSymbol(Symbol.Comma) && Peek().TryGetValue(out var token) && token is not SymbolToken { Symbol: Symbol.CloseParen })
|
if (!TryExpectSymbol(Symbol.Comma) && Peek().TryGetValue(out var token) && token is not SymbolToken { Symbol: Symbol.CloseParen })
|
||||||
{
|
{
|
||||||
_diagnostics.Add(Diagnostic
|
_diagnostics.Add(Diagnostic
|
||||||
.Warning("Missing comma between function parameters")
|
.Warning("Missing comma between function parameters")
|
||||||
.WithHelp("Add a ',' to separate parameters")
|
.WithHelp("Add a ',' to separate parameters")
|
||||||
.At(token)
|
.At(token)
|
||||||
.Build());
|
.Build());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +526,7 @@ public class Parser
|
|||||||
var startIndex = _index;
|
var startIndex = _index;
|
||||||
ExpectSymbol(Symbol.OpenBrace);
|
ExpectSymbol(Symbol.OpenBrace);
|
||||||
List<StatementNode> statements = [];
|
List<StatementNode> statements = [];
|
||||||
while (!TryExpectSymbol(Symbol.CloseBrace))
|
while (Peek().HasValue && !TryExpectSymbol(Symbol.CloseBrace))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user