Adds parsing continue and break.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
09023d6337
commit
0c8b9f3943
|
@ -893,4 +893,24 @@ namespace MalachScript::Parser {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool Parser::ParseContinue(const ParsedStatement*& out, const LexToken*& currentToken) {
|
||||
if (currentToken->GetKind() == LexTokenKind::ContinueKeyword) {
|
||||
return false;
|
||||
}
|
||||
auto start = currentToken->GetSpan().GetStart();
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
EXPECT_TOKEN(currentToken, SemicolonSymbol);
|
||||
out = new ParsedContinueStatement(TextSpan(start, currentToken->GetSpan().GetEnd()));
|
||||
return true;
|
||||
}
|
||||
bool Parser::ParseBreak(const ParsedStatement*& out, const LexToken*& currentToken) {
|
||||
if (currentToken->GetKind() == LexTokenKind::BreakKeyword) {
|
||||
return false;
|
||||
}
|
||||
auto start = currentToken->GetSpan().GetStart();
|
||||
PROGRESS_TOKEN(currentToken);
|
||||
EXPECT_TOKEN(currentToken, SemicolonSymbol);
|
||||
out = new ParsedBreakStatement(TextSpan(start, currentToken->GetSpan().GetEnd()));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -146,8 +146,8 @@ namespace MalachScript::Parser {
|
|||
|
||||
bool ParseReturn(const ParsedStatement*& out, const LexToken*& currentToken);
|
||||
bool ParseExprStat(const ParsedStatement*& out, const LexToken*& currentToken);
|
||||
// Continue
|
||||
// Break
|
||||
bool ParseContinue(const ParsedStatement*& out, const LexToken*& currentToken);
|
||||
bool ParseBreak(const ParsedStatement*& out, const LexToken*& currentToken);
|
||||
|
||||
bool ParseIfStatement(const ParsedStatement*& out, const LexToken*& currentToken);
|
||||
// For
|
||||
|
|
|
@ -359,6 +359,17 @@ namespace MalachScript::Parser {
|
|||
private:
|
||||
std::unique_ptr<const ParsedStatement> _statement;
|
||||
};
|
||||
|
||||
class ParsedContinueStatement : public ParsedStatementImpl<ParsedStatementKind::Continue> {
|
||||
public:
|
||||
ParsedContinueStatement(const TextSpan& span) : ParsedStatementImpl(span) {}
|
||||
};
|
||||
|
||||
class ParsedBreakStatement : public ParsedStatementImpl<ParsedStatementKind::Continue> {
|
||||
public:
|
||||
ParsedBreakStatement(const TextSpan& span) : ParsedStatementImpl(span) {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MALACHSCRIPT_PARSEDSTATEMENT_HPP
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace MalachScript::Parser {
|
|||
VarAccess,
|
||||
Increment,
|
||||
Decrement,
|
||||
Continue,
|
||||
Break,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue