mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-15 01:07:58 -05:00
implement set block sequence
This commit is contained in:
@ -9,7 +9,7 @@ SequenceSetBlock::SequenceSetBlock()
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddMatchers({
|
||||
create.Keyword("set"),
|
||||
create.Keyword("set").Capture(CAPTURE_START),
|
||||
create.Keyword("block"),
|
||||
create.Or({
|
||||
create.And({
|
||||
@ -24,4 +24,29 @@ SequenceSetBlock::SequenceSetBlock()
|
||||
|
||||
void SequenceSetBlock::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
{
|
||||
StructureInformation* information;
|
||||
std::vector<MemberInformation*> memberChain;
|
||||
|
||||
if (result.HasNextCapture(CAPTURE_TYPE))
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), information, memberChain))
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
||||
}
|
||||
else if (state->GetInUse() != nullptr)
|
||||
{
|
||||
information = state->GetInUse();
|
||||
}
|
||||
else
|
||||
throw ParsingException(result.NextCapture(CAPTURE_START).GetPos(), "No type is used. Therefore one needs to be specified directly.");
|
||||
|
||||
const auto& blockNameToken = result.NextCapture(CAPTURE_BLOCK_ENUM_ENTRY);
|
||||
auto* fastFileBlock = state->GetRepository()->GetFastFileBlockByName(blockNameToken.IdentifierValue());
|
||||
if (fastFileBlock == nullptr)
|
||||
throw ParsingException(blockNameToken.GetPos(), "Unknown block");
|
||||
|
||||
if (!memberChain.empty())
|
||||
memberChain.back()->m_fast_file_block = fastFileBlock;
|
||||
else
|
||||
information->m_block = fastFileBlock;
|
||||
}
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
class SequenceSetBlock final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 2;
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 3;
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
Reference in New Issue
Block a user