mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Add asset loader for localize files
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include "SimpleMatcherAnyCharacterBesides.h"
|
||||
#include "SimpleMatcherCharacter.h"
|
||||
#include "SimpleMatcherKeyword.h"
|
||||
#include "SimpleMatcherKeywordPrefix.h"
|
||||
#include "SimpleMatcherValueType.h"
|
||||
|
||||
SimpleMatcherFactory::SimpleMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier)
|
||||
@ -20,11 +21,21 @@ MatcherFactoryWrapper<SimpleParserValue> SimpleMatcherFactory::Keyword(std::stri
|
||||
return MatcherFactoryWrapper<SimpleParserValue>(std::make_unique<SimpleMatcherKeyword>(std::move(value)));
|
||||
}
|
||||
|
||||
MatcherFactoryWrapper<SimpleParserValue> SimpleMatcherFactory::KeywordPrefix(std::string value) const
|
||||
{
|
||||
return MatcherFactoryWrapper<SimpleParserValue>(std::make_unique<SimpleMatcherKeywordPrefix>(std::move(value)));
|
||||
}
|
||||
|
||||
MatcherFactoryWrapper<SimpleParserValue> SimpleMatcherFactory::Identifier() const
|
||||
{
|
||||
return MatcherFactoryWrapper<SimpleParserValue>(std::make_unique<SimpleMatcherValueType>(SimpleParserValueType::IDENTIFIER));
|
||||
}
|
||||
|
||||
MatcherFactoryWrapper<SimpleParserValue> SimpleMatcherFactory::String() const
|
||||
{
|
||||
return MatcherFactoryWrapper<SimpleParserValue>(std::make_unique<SimpleMatcherValueType>(SimpleParserValueType::STRING));
|
||||
}
|
||||
|
||||
MatcherFactoryWrapper<SimpleParserValue> SimpleMatcherFactory::Integer() const
|
||||
{
|
||||
return MatcherFactoryWrapper<SimpleParserValue>(std::make_unique<SimpleMatcherValueType>(SimpleParserValueType::INTEGER));
|
||||
|
@ -12,7 +12,9 @@ public:
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Type(SimpleParserValueType type) const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Keyword(std::string value) const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> KeywordPrefix(std::string value) const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Identifier() const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> String() const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Integer() const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> FloatingPoint() const;
|
||||
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Char(char c) const;
|
||||
|
@ -0,0 +1,14 @@
|
||||
#include "SimpleMatcherKeywordPrefix.h"
|
||||
|
||||
SimpleMatcherKeywordPrefix::SimpleMatcherKeywordPrefix(std::string value)
|
||||
: m_value(std::move(value))
|
||||
{
|
||||
}
|
||||
|
||||
MatcherResult<SimpleParserValue> SimpleMatcherKeywordPrefix::CanMatch(ILexer<SimpleParserValue>* lexer, const unsigned tokenOffset)
|
||||
{
|
||||
const auto& token = lexer->GetToken(tokenOffset);
|
||||
return token.m_type == SimpleParserValueType::IDENTIFIER && token.IdentifierValue().compare(0, m_value.size(), m_value) == 0
|
||||
? MatcherResult<SimpleParserValue>::Match(1)
|
||||
: MatcherResult<SimpleParserValue>::NoMatch();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Parsing/Simple/SimpleParserValue.h"
|
||||
#include "Parsing/Matcher/AbstractMatcher.h"
|
||||
|
||||
class SimpleMatcherKeywordPrefix final : public AbstractMatcher<SimpleParserValue>
|
||||
{
|
||||
std::string m_value;
|
||||
|
||||
protected:
|
||||
MatcherResult<SimpleParserValue> CanMatch(ILexer<SimpleParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit SimpleMatcherKeywordPrefix(std::string value);
|
||||
};
|
Reference in New Issue
Block a user