mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
Parse menu function values
This commit is contained in:
parent
7ea53808b7
commit
d4154d0cc2
@ -2,11 +2,14 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
||||
|
||||
namespace menu
|
||||
{
|
||||
class CommonFunctionDef
|
||||
{
|
||||
public:
|
||||
std::string m_name;
|
||||
std::unique_ptr<ISimpleExpression> m_value;
|
||||
};
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Generic/GenericExpressionPropertySequence.h"
|
||||
#include "Generic/GenericStringPropertySequence.h"
|
||||
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
|
||||
|
||||
@ -19,7 +20,7 @@ namespace menu::function_scope_sequences
|
||||
const MenuMatcherFactory create(this);
|
||||
|
||||
AddMatchers({
|
||||
create.Char('}')
|
||||
create.Char('}').Capture(CAPTURE_TOKEN)
|
||||
});
|
||||
}
|
||||
|
||||
@ -35,7 +36,7 @@ namespace menu::function_scope_sequences
|
||||
else
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Function with name \"" << state->m_current_menu->m_name << "\" already exists";
|
||||
ss << "Function with name \"" << state->m_current_function->m_name << "\" already exists";
|
||||
throw ParsingException(result.NextCapture(CAPTURE_TOKEN).GetPos(), ss.str());
|
||||
}
|
||||
}
|
||||
@ -56,4 +57,8 @@ void FunctionScopeSequences::AddSequences(FeatureLevel featureLevel, bool permis
|
||||
{
|
||||
state->m_current_function->m_name = value;
|
||||
}));
|
||||
AddSequence(GenericExpressionPropertySequence::WithKeyword("value", [](const MenuFileParserState* state, const TokenPos&, std::unique_ptr<ISimpleExpression> value)
|
||||
{
|
||||
state->m_current_function->m_value = std::move(value);
|
||||
}));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user