summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-10-20 09:51:19 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2019-10-20 09:51:52 -0500
commit1fe44238b1d64f18d9366710f16ae062290d5b0c (patch)
tree24108c031ad1e2a1b8a976c733d65bf159e95e46 /Source/Core/InputCommon/ControlReference/ExpressionParser.cpp
parent6282b0d83e775a87116e728a9da140f34594f17e (diff)
ExpressionParser: Add XOR operator.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.cpp')
-rw-r--r--Source/Core/InputCommon/ControlReference/ExpressionParser.cpp16
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;