ExpressionParser: Show error message with expected arguments.

This commit is contained in:
Jordan Woyak
2019-10-11 19:38:18 -05:00
parent b57178d246
commit 4d41bd64c8
3 changed files with 102 additions and 34 deletions

View File

@ -6,6 +6,7 @@
#include <memory>
#include <string>
#include <variant>
#include <vector>
#include "InputCommon/ControlReference/ExpressionParser.h"
@ -18,15 +19,27 @@ namespace ExpressionParser
class FunctionExpression : public Expression
{
public:
struct ArgumentsAreValid
{
};
struct ExpectedArguments
{
std::string text;
};
using ArgumentValidation = std::variant<ArgumentsAreValid, ExpectedArguments>;
int CountNumControls() const override;
void UpdateReferences(ControlEnvironment& env) override;
bool SetArguments(std::vector<std::unique_ptr<Expression>>&& args);
ArgumentValidation SetArguments(std::vector<std::unique_ptr<Expression>>&& args);
void SetValue(ControlState value) override;
protected:
virtual bool ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) = 0;
virtual ArgumentValidation
ValidateArguments(const std::vector<std::unique_ptr<Expression>>& args) = 0;
Expression& GetArg(u32 number);
const Expression& GetArg(u32 number) const;