mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-06 00:37:26 +00:00
Add MenuMatcherFactory with extensions for Numeric and Text token types
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
#include "SequenceName.h"
|
||||
|
||||
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
|
||||
#include "Parsing/Menu/MenuMatcherFactory.h"
|
||||
|
||||
using namespace menu;
|
||||
|
||||
SequenceName::SequenceName()
|
||||
{
|
||||
const SimpleMatcherFactory create(this);
|
||||
const MenuMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.KeywordIgnoreCase("name"),
|
||||
create.Or({create.String(), create.Identifier()}).Capture(CAPTURE_NAME)
|
||||
create.Text().Capture(CAPTURE_NAME)
|
||||
});
|
||||
}
|
||||
|
||||
void SequenceName::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const
|
||||
{
|
||||
assert(state->m_current_item || state->m_current_menu || state->m_current_function);
|
||||
|
||||
const auto& nameToken = result.NextCapture(CAPTURE_NAME);
|
||||
const auto nameValue = nameToken.m_type == SimpleParserValueType::IDENTIFIER ? nameToken.IdentifierValue() : nameToken.StringValue();
|
||||
|
||||
const auto nameValue = MenuMatcherFactory::TokenTextValue(result.NextCapture(CAPTURE_NAME));
|
||||
|
||||
if (state->m_current_item)
|
||||
state->m_current_item->m_name = nameValue;
|
||||
|
Reference in New Issue
Block a user