Files
o3de/Gems/ExpressionEvaluation/Code/Source/ExpressionEngine/ExpressionPrimitive.h
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

81 lines
2.2 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/std/string/regex.h>
#include <AzCore/RTTI/RTTI.h>
#include <ExpressionEvaluation/ExpressionEngine/ExpressionTree.h>
#include <ExpressionEngine/ExpressionElementParser.h>
#include <ExpressionEngine/InternalTypes.h>
namespace ExpressionEvaluation
{
// Shared interface for pushing Primitives onto the evaluation stack. Does not handle parsing.
class PrimitiveParser
: public ExpressionElementParser
{
public:
AZ_CLASS_ALLOCATOR(PrimitiveParser, AZ::SystemAllocator, 0);
PrimitiveParser() = default;
void EvaluateToken(const ElementInformation& parseResult, ExpressionResultStack& evaluationStack) const override;
};
namespace Primitive
{
template<typename T>
ElementInformation GetPrimitiveElement(const T& valueType)
{
ElementInformation primitiveInformation;
primitiveInformation.m_allowOnOperatorStack = false;
primitiveInformation.m_id = InternalTypes::Primitive;
primitiveInformation.m_extraStore = valueType;
return primitiveInformation;
}
}
// Parser for basic numeric types
class NumericPrimitiveParser
: public PrimitiveParser
{
public:
AZ_CLASS_ALLOCATOR(NumericPrimitiveParser, AZ::SystemAllocator, 0);
NumericPrimitiveParser();
ExpressionParserId GetParserId() const override;
ParseResult ParseElement(const AZStd::string& inputText, size_t offset) const override;
private:
AZStd::regex m_regex;
};
// Parser for basic boolean types
class BooleanPrimitiveParser
: public PrimitiveParser
{
public:
AZ_CLASS_ALLOCATOR(BooleanPrimitiveParser, AZ::SystemAllocator, 0);
BooleanPrimitiveParser();
ExpressionParserId GetParserId() const override;
ParseResult ParseElement(const AZStd::string& inputText, size_t offset) const override;
private:
AZStd::regex m_regex;
};
}