diff options
| author | Mat M <mathew1800@gmail.com> | 2019-10-23 20:18:39 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-23 20:18:39 -0400 |
| commit | 6991b3928933d2cb276e137255c761d7883ffda6 (patch) | |
| tree | 65e984592124bda0bc7818ce6089c037cb0f8539 /Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | |
| parent | 291c056c073fb474ab9fcbc7c57709f37c869404 (diff) | |
| parent | 1fe44238b1d64f18d9366710f16ae062290d5b0c (diff) | |
Merge pull request #8419 from jordan-woyak/xor-op
ExpressionParser: Add XOR operator.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index 00afc5e036..8e9b154bf7 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -136,6 +136,8 @@ Token Lexer::NextToken() return Token(TOK_GTHAN); case ',': return Token(TOK_COMMA); + case '^': + return Token(TOK_XOR); case '\'': return GetDelimitedLiteral(); case '$': @@ -278,6 +280,12 @@ public: lhs->GetValue(); return rhs->GetValue(); } + case TOK_XOR: + { + const auto lval = lhs->GetValue(); + const auto rval = rhs->GetValue(); + return std::max(std::min(1 - lval, rval), std::min(lval, 1 - rval)); + } default: assert(false); return 0; @@ -621,12 +629,14 @@ private: return 3; case TOK_AND: return 4; - case TOK_OR: + case TOK_XOR: return 5; - case TOK_ASSIGN: + case TOK_OR: return 6; - case TOK_COMMA: + case TOK_ASSIGN: return 7; + case TOK_COMMA: + return 8; default: assert(false); return 0; |
