Slight performance improvements for parsing statements.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-01-01 13:17:53 +01:00
parent a9c3a9e0c4
commit 037470a0ce
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 11 additions and 6 deletions

View File

@ -547,12 +547,17 @@ namespace MalachScript::Parser {
}
bool Parser::ParseStatement(ScopedPtr<const ParsedStatement>& out, const LexToken*& currentToken) {
// TODO: All the other statements.
return ParseIfStatement(out, currentToken) || ParseForStatement(out, currentToken) ||
ParseWhileStatement(out, currentToken) || ParseReturn(out, currentToken) ||
ParseStatBlock(out, currentToken) || ParseBreak(out, currentToken) || ParseContinue(out, currentToken) ||
ParseExprStat(out, currentToken);
// TODO: All the other statements. (dowhile | switch | try );
switch (currentToken->GetKind()) {
case LexTokenKind::IfKeyword: return ParseIfStatement(out, currentToken);
case LexTokenKind::ForKeyword: return ParseForStatement(out, currentToken);
case LexTokenKind::WhileKeyword: return ParseWhileStatement(out, currentToken);
case LexTokenKind::ReturnKeyword: return ParseReturn(out, currentToken);
case LexTokenKind::BreakKeyword: return ParseBreak(out, currentToken);
case LexTokenKind::ContinueKeyword: return ParseContinue(out, currentToken);
default: return ParseStatBlock(out, currentToken) || ParseExprStat(out, currentToken);
}
return false;
}
bool Parser::ParseVar([[maybe_unused]] ScopedPtr<const ParsedStatement>& out, const LexToken*& currentToken) {