summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControlReference/ExpressionParser.h
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2019-03-02 14:47:26 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2019-10-11 18:12:18 -0500
commitca7ce674500b7664ed049ac1019a2e40636187dc (patch)
tree6cd8f5563ce9ee43a645ebbf43b13ee9eee6989f /Source/Core/InputCommon/ControlReference/ExpressionParser.h
parentc8b2188e1972f14aec24ac66908a641dbdbd106f (diff)
ExpressionParser/DolphinQt: Added parse results to UI.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.h')
-rw-r--r--Source/Core/InputCommon/ControlReference/ExpressionParser.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.h b/Source/Core/InputCommon/ControlReference/ExpressionParser.h
index 8e3e6cc1a9..3dac67e9db 100644
--- a/Source/Core/InputCommon/ControlReference/ExpressionParser.h
+++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.h
@@ -6,6 +6,7 @@
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include "InputCommon/ControllerInterface/Device.h"
@@ -49,7 +50,7 @@ public:
std::size_t string_position = 0;
std::size_t string_length = 0;
- Token(TokenType type_);
+ explicit Token(TokenType type_);
Token(TokenType type_, std::string data_);
bool IsBinaryOperator() const;
@@ -166,5 +167,26 @@ public:
virtual operator std::string() const = 0;
};
-std::pair<ParseStatus, std::unique_ptr<Expression>> ParseExpression(const std::string& expr);
+class ParseResult
+{
+public:
+ static ParseResult MakeEmptyResult();
+ static ParseResult MakeSuccessfulResult(std::unique_ptr<Expression>&& expr);
+ static ParseResult MakeErrorResult(Token token, std::string description);
+
+ ParseStatus status;
+ std::unique_ptr<Expression> expr;
+
+ // Used for parse errors:
+ // TODO: This should probably be moved elsewhere:
+ std::optional<Token> token;
+ std::optional<std::string> description;
+
+private:
+ ParseResult() = default;
+};
+
+ParseResult ParseExpression(const std::string& expr);
+ParseResult ParseTokens(const std::vector<Token>& tokens);
+
} // namespace ciface::ExpressionParser