mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
Fix techset parsing naming issues
This commit is contained in:
parent
d8f490ec94
commit
99d5caf1f2
@ -15,7 +15,7 @@ using namespace IW4;
|
|||||||
|
|
||||||
namespace IW4
|
namespace IW4
|
||||||
{
|
{
|
||||||
class TechniqueZoneLoadingState final : IZoneAssetLoaderState
|
class TechniqueZoneLoadingState final : public IZoneAssetLoaderState
|
||||||
{
|
{
|
||||||
std::map<std::string, MaterialTechnique*> m_loaded_techniques;
|
std::map<std::string, MaterialTechnique*> m_loaded_techniques;
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ bool AssetLoaderTechniqueSet::LoadFromRaw(const std::string& assetName, ISearchP
|
|||||||
if (!file.IsOpen())
|
if (!file.IsOpen())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
const techset::TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
||||||
const auto techsetDefinition = reader.ReadTechsetDefinition();
|
const auto techsetDefinition = reader.ReadTechsetDefinition();
|
||||||
|
|
||||||
if (techsetDefinition)
|
if (techsetDefinition)
|
||||||
|
@ -6,7 +6,7 @@ using namespace techset;
|
|||||||
|
|
||||||
namespace techset
|
namespace techset
|
||||||
{
|
{
|
||||||
class SequenceTechniqueTypeName final : public Parser::sequence_t
|
class SequenceTechniqueTypeName final : public TechsetParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_TYPE_NAME = 1;
|
static constexpr auto CAPTURE_TYPE_NAME = 1;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ namespace techset
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(ParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
void ProcessMatch(TechsetParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||||
{
|
{
|
||||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE_NAME);
|
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE_NAME);
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace techset
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SequenceTechniqueName final : public Parser::sequence_t
|
class SequenceTechniqueName final : public TechsetParser::sequence_t
|
||||||
{
|
{
|
||||||
static constexpr auto CAPTURE_NAME = 1;
|
static constexpr auto CAPTURE_NAME = 1;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace techset
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ProcessMatch(ParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
void ProcessMatch(TechsetParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||||
{
|
{
|
||||||
assert(!state->m_current_technique_types.empty());
|
assert(!state->m_current_technique_types.empty());
|
||||||
|
|
||||||
@ -69,12 +69,12 @@ namespace techset
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Parser::Parser(SimpleLexer* lexer, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
TechsetParser::TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
||||||
: AbstractParser(lexer, std::make_unique<ParserState>(validTechniqueTypeNames, validTechniqueTypeNameCount))
|
: AbstractParser(lexer, std::make_unique<TechsetParserState>(validTechniqueTypeNames, validTechniqueTypeNameCount))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Parser::sequence_t*>& Parser::GetTestsForState()
|
const std::vector<TechsetParser::sequence_t*>& TechsetParser::GetTestsForState()
|
||||||
{
|
{
|
||||||
static std::vector<sequence_t*> allTests({
|
static std::vector<sequence_t*> allTests({
|
||||||
new SequenceTechniqueTypeName(),
|
new SequenceTechniqueTypeName(),
|
||||||
@ -87,7 +87,7 @@ const std::vector<Parser::sequence_t*>& Parser::GetTestsForState()
|
|||||||
return m_state->m_current_technique_types.empty() ? techniqueTypeNameOnlyTests : allTests;
|
return m_state->m_current_technique_types.empty() ? techniqueTypeNameOnlyTests : allTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<TechsetDefinition> Parser::GetTechsetDefinition() const
|
std::unique_ptr<TechsetDefinition> TechsetParser::GetTechsetDefinition() const
|
||||||
{
|
{
|
||||||
return std::move(m_state->m_definition);
|
return std::move(m_state->m_definition);
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
namespace techset
|
namespace techset
|
||||||
{
|
{
|
||||||
class Parser final : public AbstractParser<SimpleParserValue, ParserState>
|
class TechsetParser final : public AbstractParser<SimpleParserValue, TechsetParserState>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Parser(SimpleLexer* lexer, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||||
_NODISCARD std::unique_ptr<TechsetDefinition> GetTechsetDefinition() const;
|
_NODISCARD std::unique_ptr<TechsetDefinition> GetTechsetDefinition() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
using namespace techset;
|
using namespace techset;
|
||||||
|
|
||||||
ParserState::ParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount)
|
TechsetParserState::TechsetParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount)
|
||||||
: m_definition(std::make_unique<TechsetDefinition>(validTechniqueTypeNameCount))
|
: m_definition(std::make_unique<TechsetDefinition>(validTechniqueTypeNameCount))
|
||||||
{
|
{
|
||||||
for(auto i = 0u; i < validTechniqueTypeNameCount; i++)
|
for (auto i = 0u; i < validTechniqueTypeNameCount; i++)
|
||||||
{
|
{
|
||||||
m_valid_technique_type_names.emplace(std::make_pair(std::string(validTechniqueTypeNames[i]), i));
|
m_valid_technique_type_names.emplace(std::make_pair(std::string(validTechniqueTypeNames[i]), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserState::FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const
|
bool TechsetParserState::FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const
|
||||||
{
|
{
|
||||||
const auto foundTechniqueType = m_valid_technique_type_names.find(techniqueTypeName);
|
const auto foundTechniqueType = m_valid_technique_type_names.find(techniqueTypeName);
|
||||||
|
|
||||||
if(foundTechniqueType != m_valid_technique_type_names.end())
|
if (foundTechniqueType != m_valid_technique_type_names.end())
|
||||||
{
|
{
|
||||||
techniqueTypeIndex = foundTechniqueType->second;
|
techniqueTypeIndex = foundTechniqueType->second;
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
namespace techset
|
namespace techset
|
||||||
{
|
{
|
||||||
class ParserState
|
class TechsetParserState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::map<std::string, size_t> m_valid_technique_type_names;
|
std::map<std::string, size_t> m_valid_technique_type_names;
|
||||||
std::unique_ptr<TechsetDefinition> m_definition;
|
std::unique_ptr<TechsetDefinition> m_definition;
|
||||||
std::vector<size_t> m_current_technique_types;
|
std::vector<size_t> m_current_technique_types;
|
||||||
|
|
||||||
ParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
TechsetParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||||
|
|
||||||
bool FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const;
|
bool FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const;
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||||
|
|
||||||
|
using namespace techset;
|
||||||
|
|
||||||
TechsetFileReader::TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
TechsetFileReader::TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
||||||
: m_file_name(std::move(fileName)),
|
: m_file_name(std::move(fileName)),
|
||||||
m_valid_technique_type_names(validTechniqueTypeNames),
|
m_valid_technique_type_names(validTechniqueTypeNames),
|
||||||
@ -23,7 +25,7 @@ std::unique_ptr<techset::TechsetDefinition> TechsetFileReader::ReadTechsetDefini
|
|||||||
lexerConfig.m_read_numbers = false;
|
lexerConfig.m_read_numbers = false;
|
||||||
const auto lexer = std::make_unique<SimpleLexer>(m_comment_proxy.get(), std::move(lexerConfig));
|
const auto lexer = std::make_unique<SimpleLexer>(m_comment_proxy.get(), std::move(lexerConfig));
|
||||||
|
|
||||||
const auto parser = std::make_unique<techset::Parser>(lexer.get(), m_valid_technique_type_names, m_valid_technique_type_name_count);
|
const auto parser = std::make_unique<techset::TechsetParser>(lexer.get(), m_valid_technique_type_names, m_valid_technique_type_name_count);
|
||||||
|
|
||||||
const auto success = parser->Parse();
|
const auto success = parser->Parse();
|
||||||
if (success)
|
if (success)
|
||||||
|
@ -7,16 +7,19 @@
|
|||||||
#include "TechsetDefinition.h"
|
#include "TechsetDefinition.h"
|
||||||
#include "Parsing/IParserLineStream.h"
|
#include "Parsing/IParserLineStream.h"
|
||||||
|
|
||||||
class TechsetFileReader
|
namespace techset
|
||||||
{
|
{
|
||||||
|
class TechsetFileReader
|
||||||
|
{
|
||||||
std::string m_file_name;
|
std::string m_file_name;
|
||||||
const char** m_valid_technique_type_names;
|
const char** m_valid_technique_type_names;
|
||||||
size_t m_valid_technique_type_name_count;
|
size_t m_valid_technique_type_name_count;
|
||||||
std::unique_ptr<IParserLineStream> m_base_stream;
|
std::unique_ptr<IParserLineStream> m_base_stream;
|
||||||
std::unique_ptr<IParserLineStream> m_comment_proxy;
|
std::unique_ptr<IParserLineStream> m_comment_proxy;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||||
|
|
||||||
_NODISCARD std::unique_ptr<techset::TechsetDefinition> ReadTechsetDefinition() const;
|
_NODISCARD std::unique_ptr<techset::TechsetDefinition> ReadTechsetDefinition() const;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user