mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
ExpressionParser: Remove RemoveInertTokens.
This commit is contained in:
@ -191,7 +191,6 @@ void ControlExpressionSyntaxHighlighter::highlightBlock(const QString&)
|
|||||||
// This doesn't need to be run for every "block", but it works.
|
// This doesn't need to be run for every "block", but it works.
|
||||||
if (ciface::ExpressionParser::ParseStatus::Successful == tokenize_status)
|
if (ciface::ExpressionParser::ParseStatus::Successful == tokenize_status)
|
||||||
{
|
{
|
||||||
ciface::ExpressionParser::RemoveInertTokens(&tokens);
|
|
||||||
const auto parse_status = ciface::ExpressionParser::ParseTokens(tokens);
|
const auto parse_status = ciface::ExpressionParser::ParseTokens(tokens);
|
||||||
|
|
||||||
if (ciface::ExpressionParser::ParseStatus::Successful != parse_status.status)
|
if (ciface::ExpressionParser::ParseStatus::Successful != parse_status.status)
|
||||||
|
@ -671,6 +671,11 @@ ParseResult ParseResult::MakeErrorResult(Token token, std::string description)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsInertToken(const Token& tok)
|
||||||
|
{
|
||||||
|
return tok.type == TOK_COMMENT || tok.type == TOK_WHITESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -700,7 +705,12 @@ private:
|
|||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token Peek() { return *m_it; }
|
Token Peek()
|
||||||
|
{
|
||||||
|
while (IsInertToken(*m_it))
|
||||||
|
++m_it;
|
||||||
|
return *m_it;
|
||||||
|
}
|
||||||
|
|
||||||
bool Expects(TokenType type)
|
bool Expects(TokenType type)
|
||||||
{
|
{
|
||||||
@ -959,18 +969,9 @@ static ParseResult ParseComplexExpression(const std::string& str)
|
|||||||
if (tokenize_status != ParseStatus::Successful)
|
if (tokenize_status != ParseStatus::Successful)
|
||||||
return ParseResult::MakeErrorResult(Token(TOK_INVALID),
|
return ParseResult::MakeErrorResult(Token(TOK_INVALID),
|
||||||
Common::GetStringT("Tokenizing failed."));
|
Common::GetStringT("Tokenizing failed."));
|
||||||
|
|
||||||
RemoveInertTokens(&tokens);
|
|
||||||
return ParseTokens(tokens);
|
return ParseTokens(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveInertTokens(std::vector<Token>* tokens)
|
|
||||||
{
|
|
||||||
std::erase_if(*tokens, [](const Token& tok) {
|
|
||||||
return tok.type == TOK_COMMENT || tok.type == TOK_WHITESPACE;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::unique_ptr<Expression> ParseBarewordExpression(const std::string& str)
|
static std::unique_ptr<Expression> ParseBarewordExpression(const std::string& str)
|
||||||
{
|
{
|
||||||
ControlQualifier qualifier;
|
ControlQualifier qualifier;
|
||||||
|
@ -195,6 +195,5 @@ private:
|
|||||||
|
|
||||||
ParseResult ParseExpression(const std::string& expr);
|
ParseResult ParseExpression(const std::string& expr);
|
||||||
ParseResult ParseTokens(const std::vector<Token>& tokens);
|
ParseResult ParseTokens(const std::vector<Token>& tokens);
|
||||||
void RemoveInertTokens(std::vector<Token>* tokens);
|
|
||||||
|
|
||||||
} // namespace ciface::ExpressionParser
|
} // namespace ciface::ExpressionParser
|
||||||
|
Reference in New Issue
Block a user