2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-10-24 15:25:52 +00:00

Move Menu Expression to Simple Namespace to have generic configurable expressions

This commit is contained in:
Jan
2021-11-24 17:44:14 +01:00
parent 4f2a8454a6
commit 38f3d7d10e
21 changed files with 619 additions and 407 deletions

View File

@@ -7,6 +7,8 @@
#include "MatcherAnd.h"
#include "MatcherLabel.h"
#include "MatcherLoop.h"
#include "MatcherFalse.h"
#include "MatcherTrue.h"
#include "MatcherOptional.h"
#include "MatcherOr.h"
#include "Parsing/IParserValue.h"
@@ -85,6 +87,16 @@ public:
{
}
_NODISCARD MatcherFactoryWrapper<TokenType> False() const
{
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherFalse<TokenType>>());
}
_NODISCARD MatcherFactoryWrapper<TokenType> True() const
{
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherTrue<TokenType>>());
}
_NODISCARD MatcherFactoryWrapper<TokenType> And(std::initializer_list<Movable<std::unique_ptr<AbstractMatcher<TokenType>>>> matchers) const
{
return MatcherFactoryWrapper<TokenType>(std::make_unique<MatcherAnd<TokenType>>(matchers));

View File

@@ -0,0 +1,23 @@
#pragma once
#include <memory>
#include "Parsing/IParserValue.h"
#include "AbstractMatcher.h"
template <typename TokenType>
class MatcherFalse final : public AbstractMatcher<TokenType>
{
// TokenType must inherit IParserValue
static_assert(std::is_base_of<IParserValue, TokenType>::value);
protected:
MatcherResult<TokenType> CanMatch(ILexer<TokenType>* lexer, unsigned tokenOffset) override
{
return MatcherResult<TokenType>::NoMatch();
}
public:
MatcherFalse()
= default;
};

View File

@@ -0,0 +1,23 @@
#pragma once
#include <memory>
#include "Parsing/IParserValue.h"
#include "AbstractMatcher.h"
template <typename TokenType>
class MatcherTrue final : public AbstractMatcher<TokenType>
{
// TokenType must inherit IParserValue
static_assert(std::is_base_of<IParserValue, TokenType>::value);
protected:
MatcherResult<TokenType> CanMatch(ILexer<TokenType>* lexer, unsigned tokenOffset) override
{
return MatcherResult<TokenType>::Match(0);
}
public:
MatcherTrue()
= default;
};