Skip to content
Permalink
Browse files

ExpressionParser: cleanup.

  • Loading branch information...
jordan-woyak committed Dec 30, 2018
1 parent 58efc93 commit 2c89b6029809f720e9233b3510c625766f466529
Showing with 9 additions and 7 deletions.
  1. +9 −7 Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
@@ -106,7 +106,7 @@ class Token
case TOK_OR:
return "|";
case TOK_UNARY:
return "!" + data;
return '!' + data;
case TOK_ADD:
return "+";
case TOK_MUL:
@@ -124,7 +124,7 @@ class Token
case TOK_COND:
return "?";
case TOK_CONTROL:
return "Device(" + data + ")";
return "Device(" + data + ')';
case TOK_LITERAL:
return '\'' + data + '\'';
case TOK_VARIABLE:
@@ -422,7 +422,7 @@ class UnaryExpression : public Expression

operator std::string() const override
{
return "!" + GetFuncName() + "(" + (std::string)(*inner) + ")";
return '!' + GetFuncName() + '(' + static_cast<std::string>(*inner) + ')';
}

protected:
@@ -493,7 +493,7 @@ class UnarySinExpression : public UnaryExpression
public:
UnarySinExpression(std::unique_ptr<Expression>&& inner_) : UnaryExpression(std::move(inner_)) {}

ControlState GetValue() const override { return std::cos(inner->GetValue()); }
ControlState GetValue() const override { return std::sin(inner->GetValue()); }
void SetValue(ControlState value) override {}
std::string GetFuncName() const override { return "Sin"; }
};
@@ -502,9 +502,10 @@ std::unique_ptr<UnaryExpression> MakeUnaryExpression(std::string name,
std::unique_ptr<Expression>&& inner_)
{
// Case insensitive matching.
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
std::transform(name.begin(), name.end(), name.begin(),
[](char c) { return std::tolower(c, std::locale::classic()); });

if ("" == name)
if (name.empty())
return std::make_unique<UnaryNotExpression>(std::move(inner_));
else if ("toggle" == name)
return std::make_unique<UnaryToggleExpression>(std::move(inner_));
@@ -569,7 +570,8 @@ class LiteralTimer : public LiteralExpression
std::unique_ptr<LiteralExpression> MakeLiteralExpression(std::string name)
{
// Case insensitive matching.
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
std::transform(name.begin(), name.end(), name.begin(),
[](char c) { return std::tolower(c, std::locale::classic()); });

// Check for named literals:
if ("timer" == name)

0 comments on commit 2c89b60

Please sign in to comment.
You can’t perform that action at this time.