Continue parsing paramslist until we've found the closing parenthesis
This commit is contained in:
parent
ad8a0ce1b4
commit
a7c7fc3e28
|
@ -353,8 +353,14 @@ namespace MalachScript::Parser {
|
||||||
}
|
}
|
||||||
PROGRESS_TOKEN(currentToken);
|
PROGRESS_TOKEN(currentToken);
|
||||||
}
|
}
|
||||||
if (currentToken->GetKind() != LexTokenKind::CloseParenthesisSymbol) {
|
while (currentToken->GetKind() != LexTokenKind::CloseParenthesisSymbol) {
|
||||||
LogError(Diagnostics::DiagnosticType::UnexpectedToken, currentToken->GetSpan());
|
LogError(Diagnostics::DiagnosticType::UnexpectedToken, currentToken->GetSpan());
|
||||||
|
if (currentToken->GetKind() == LexTokenKind::EndOfFile) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (currentToken->GetKind() == LexTokenKind::SemicolonSymbol) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out = new ParsedParamListStatement(TextSpan(start, currentToken->GetSpan().GetEnd()), parameters);
|
out = new ParsedParamListStatement(TextSpan(start, currentToken->GetSpan().GetEnd()), parameters);
|
||||||
PROGRESS_TOKEN(currentToken);
|
PROGRESS_TOKEN(currentToken);
|
||||||
|
|
|
@ -26,3 +26,9 @@ PARSE_TEST("Parse class with empty definition", "class foobar {}", {
|
||||||
REQUIRE(script->GetStatements().size() == 1);
|
REQUIRE(script->GetStatements().size() == 1);
|
||||||
REQUIRE(script->GetStatements()[0].get()->GetKind() == Parser::ParsedStatementKind::Class);
|
REQUIRE(script->GetStatements()[0].get()->GetKind() == Parser::ParsedStatementKind::Class);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
PARSE_TEST("Parse function without definition", "void foobar(int8 par1, bool &in x);", {
|
||||||
|
REQUIRE(diags.GetMessages().empty());
|
||||||
|
REQUIRE(script->GetStatements().size() == 1);
|
||||||
|
REQUIRE(script->GetStatements()[0].get()->GetKind() == Parser::ParsedStatementKind::Func);
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue