mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
27 lines
1.1 KiB
C++
27 lines
1.1 KiB
C++
#include "MenuFileCommonOperations.h"
|
|
|
|
#include "Parsing/ParsingException.h"
|
|
|
|
using namespace menu;
|
|
|
|
void MenuFileCommonOperations::EnsureIsNumericExpression(const MenuFileParserState* state, const TokenPos& pos, const ISimpleExpression& expression)
|
|
{
|
|
if (!state->m_permissive_mode && expression.IsStatic())
|
|
{
|
|
const auto staticValue = expression.EvaluateStatic();
|
|
|
|
if (staticValue.m_type != SimpleExpressionValue::Type::INT && staticValue.m_type != SimpleExpressionValue::Type::DOUBLE)
|
|
throw ParsingException(pos, "Expression is expected to be numeric. Use permissive mode to compile anyway.");
|
|
}
|
|
}
|
|
|
|
void MenuFileCommonOperations::EnsureIsStringExpression(const MenuFileParserState* state, const TokenPos& pos, const ISimpleExpression& expression)
|
|
{
|
|
if (!state->m_permissive_mode && expression.IsStatic())
|
|
{
|
|
const auto staticValue = expression.EvaluateStatic();
|
|
|
|
if (staticValue.m_type != SimpleExpressionValue::Type::STRING)
|
|
throw ParsingException(pos, "Expression is expected to be string. Use permissive mode to compile anyway.");
|
|
}
|
|
} |