Fix some parsing issues for MatchExpression

This commit is contained in:
Sam Vervaeck 2023-05-21 17:13:47 +02:00
parent b6706dd801
commit fb5a9df48b
Signed by: samvv
SSH key fingerprint: SHA256:dIg0ywU1OP+ZYifrYxy8c5esO72cIKB+4/9wkZj1VaY

View file

@ -241,10 +241,12 @@ after_constraints:
{ {
Tokens.get(); Tokens.get();
auto T1 = Tokens.peek(); auto T1 = Tokens.peek();
Expression* Value = nullptr; Expression* Value;
BlockStart* BlockStart; BlockStart* BlockStart;
if (llvm::isa<class BlockStart>(T1)) { if (llvm::isa<class BlockStart>(T1)) {
Value = nullptr;
BlockStart = static_cast<class BlockStart*>(T1); BlockStart = static_cast<class BlockStart*>(T1);
Tokens.get();
} else { } else {
Value = parseExpression(); Value = parseExpression();
BlockStart = expectToken<class BlockStart>(); BlockStart = expectToken<class BlockStart>();
@ -269,7 +271,7 @@ after_constraints:
Tokens.get(); Tokens.get();
return new ConstantExpression(T0); return new ConstantExpression(T0);
default: default:
throw UnexpectedTokenDiagnostic(File, T0, std::vector { NodeKind::Identifier, NodeKind::IntegerLiteral, NodeKind::StringLiteral }); throw UnexpectedTokenDiagnostic(File, T0, { NodeKind::MatchKeyword, NodeKind::Identifier, NodeKind::IdentifierAlt, NodeKind::IntegerLiteral, NodeKind::StringLiteral });
} }
} }