mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
#include "SequenceReusable.h"
|
|
|
|
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
|
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
|
|
|
SequenceReusable::SequenceReusable()
|
|
{
|
|
const CommandsMatcherFactory create(this);
|
|
|
|
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
|
AddMatchers({
|
|
create.Keyword("set"),
|
|
create.Keyword("reusable"),
|
|
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
|
create.Char(';')
|
|
});
|
|
}
|
|
|
|
void SequenceReusable::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
|
{
|
|
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
|
|
|
StructureInformation* type;
|
|
std::vector<MemberInformation*> members;
|
|
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), type, members))
|
|
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
|
|
|
if (members.empty())
|
|
throw ParsingException(typeNameToken.GetPos(), "Need to specify a member when trying to mark as reusable.");
|
|
|
|
members.back()->m_is_reusable = true;
|
|
}
|