UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ExpressionParser Namespace Reference

Typedefs

template<typename CharType >
using TLexResultType = TValueOrError< TArray< TExpressionToken< CharType > >, FExpressionError >
 
template<typename CharType >
using TCompileResultType = TValueOrError< TArray< TCompiledToken< CharType > >, FExpressionError >
 
using LexResultType = TLexResultType< TCHAR >
 
using CompileResultType = TCompileResultType< TCHAR >
 

Functions

const FDecimalNumberFormattingRulesGetLocalizedNumberFormattingRules ()
 
TOptional< FStringTokenParseNumberWithFallback (const FTokenStream &InStream, const FDecimalNumberFormattingRules &InPrimaryFormattingRules, const FDecimalNumberFormattingRules &InFallbackFormattingRules, FStringToken *Accumulate, double *OutValue)
 
TOptional< FStringTokenParseNumberWithRules (const FTokenStream &InStream, const FDecimalNumberFormattingRules &InFormattingRules, FStringToken *Accumulate, double *OutValue)
 
TOptional< FStringTokenParseLocalizedNumberWithAgnosticFallback (const FTokenStream &InStream, FStringToken *Accumulate, double *OutValue)
 
TOptional< FStringTokenParseLocalizedNumber (const FTokenStream &InStream, FStringToken *Accumulate, double *OutValue)
 
TOptional< FStringTokenParseNumber (const FTokenStream &InStream, FStringToken *Accumulate, double *OutValue)
 
TOptional< FExpressionErrorConsumeNumberWithRules (FExpressionTokenConsumer &Consumer, const FDecimalNumberFormattingRules &InFormattingRules)
 
TOptional< FExpressionErrorConsumeLocalizedNumberWithAgnosticFallback (FExpressionTokenConsumer &Consumer)
 
TOptional< FExpressionErrorConsumeLocalizedNumber (FExpressionTokenConsumer &Consumer)
 
TOptional< FExpressionErrorConsumeNumber (FExpressionTokenConsumer &Consumer)
 
template<typename CharType >
TLexResultType< CharType > Lex (const CharType *InExpression, const TTokenDefinitions< CharType > &TokenDefinitions)
 
template<typename CharType >
TCompileResultType< CharType > Compile (const CharType *InExpression, const TTokenDefinitions< CharType > &InTokenDefinitions, const FExpressionGrammar &InGrammar)
 
template<typename CharType >
TCompileResultType< CharType > Compile (TArray< TExpressionToken< CharType > > InTokens, const FExpressionGrammar &InGrammar)
 
template<typename CharType >
FExpressionResult Evaluate (const CharType *InExpression, const TTokenDefinitions< CharType > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TIOperatorEvaluationEnvironment< CharType > &InEnvironment)
 
template<typename CharType >
FExpressionResult Evaluate (const TArray< TCompiledToken< CharType > > &CompiledTokens, const TIOperatorEvaluationEnvironment< CharType > &InEnvironment)
 
template CORE_API TLexResultType< ANSICHARLex< ANSICHAR > (const ANSICHAR *InExpression, const TTokenDefinitions< ANSICHAR > &TokenDefinitions)
 
template CORE_API TLexResultType< UTF8CHARLex< UTF8CHAR > (const UTF8CHAR *InExpression, const TTokenDefinitions< UTF8CHAR > &TokenDefinitions)
 
template CORE_API TLexResultType< WIDECHARLex< WIDECHAR > (const WIDECHAR *InExpression, const TTokenDefinitions< WIDECHAR > &TokenDefinitions)
 
template CORE_API TCompileResultType< ANSICHARCompile< ANSICHAR > (const ANSICHAR *InExpression, const TTokenDefinitions< ANSICHAR > &TokenDefinitions, const FExpressionGrammar &InGrammar)
 
template CORE_API TCompileResultType< UTF8CHARCompile< UTF8CHAR > (const UTF8CHAR *InExpression, const TTokenDefinitions< UTF8CHAR > &TokenDefinitions, const FExpressionGrammar &InGrammar)
 
template CORE_API TCompileResultType< WIDECHARCompile< WIDECHAR > (const WIDECHAR *InExpression, const TTokenDefinitions< WIDECHAR > &TokenDefinitions, const FExpressionGrammar &InGrammar)
 
template CORE_API TCompileResultType< ANSICHARCompile< ANSICHAR > (TArray< TExpressionToken< ANSICHAR > > InTokens, const FExpressionGrammar &InGrammar)
 
template CORE_API TCompileResultType< UTF8CHARCompile< UTF8CHAR > (TArray< TExpressionToken< UTF8CHAR > > InTokens, const FExpressionGrammar &InGrammar)
 
template CORE_API TCompileResultType< WIDECHARCompile< WIDECHAR > (TArray< TExpressionToken< WIDECHAR > > InTokens, const FExpressionGrammar &InGrammar)
 
template CORE_API FExpressionResult Evaluate< ANSICHAR > (const ANSICHAR *InExpression, const TTokenDefinitions< ANSICHAR > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TIOperatorEvaluationEnvironment< ANSICHAR > &InEnvironment)
 
template CORE_API FExpressionResult Evaluate< UTF8CHAR > (const UTF8CHAR *InExpression, const TTokenDefinitions< UTF8CHAR > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TIOperatorEvaluationEnvironment< UTF8CHAR > &InEnvironment)
 
template CORE_API FExpressionResult Evaluate< WIDECHAR > (const WIDECHAR *InExpression, const TTokenDefinitions< WIDECHAR > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TIOperatorEvaluationEnvironment< WIDECHAR > &InEnvironment)
 
template CORE_API FExpressionResult Evaluate< ANSICHAR > (const TArray< TCompiledToken< ANSICHAR > > &CompiledTokens, const TIOperatorEvaluationEnvironment< ANSICHAR > &InEnvironment)
 
template CORE_API FExpressionResult Evaluate< UTF8CHAR > (const TArray< TCompiledToken< UTF8CHAR > > &CompiledTokens, const TIOperatorEvaluationEnvironment< UTF8CHAR > &InEnvironment)
 
template CORE_API FExpressionResult Evaluate< WIDECHAR > (const TArray< TCompiledToken< WIDECHAR > > &CompiledTokens, const TIOperatorEvaluationEnvironment< WIDECHAR > &InEnvironment)
 
template<typename TSymbol >
TOptional< FExpressionErrorConsumeSymbol (FExpressionTokenConsumer &Consumer)
 
template<typename CharType >
CORE_API TLexResultType< CharType > Lex (const CharType *InExpression, const TTokenDefinitions< CharType > &TokenDefinitions)
 
template<typename CharType >
CORE_API TCompileResultType< CharType > Compile (const CharType *InExpression, const TTokenDefinitions< CharType > &TokenDefinitions, const FExpressionGrammar &InGrammar)
 
template<typename CharType >
CORE_API TCompileResultType< CharType > Compile (TArray< TExpressionToken< CharType > > InTokens, const FExpressionGrammar &InGrammar)
 
template<typename CharType >
CORE_API FExpressionResult Evaluate (const CharType *InExpression, const TTokenDefinitions< CharType > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TIOperatorEvaluationEnvironment< CharType > &InEnvironment)
 
template<typename CharType >
CORE_API FExpressionResult Evaluate (const TArray< TCompiledToken< CharType > > &CompiledTokens, const TIOperatorEvaluationEnvironment< CharType > &InEnvironment)
 
template<typename CharType , typename ContextType >
FExpressionResult Evaluate (const CharType *InExpression, const TTokenDefinitions< CharType > &InTokenDefinitions, const FExpressionGrammar &InGrammar, const TOperatorJumpTable< ContextType > &InJumpTable, const ContextType *InContext=nullptr)
 
template<typename ContextType >
FExpressionResult Evaluate (const TArray< FCompiledToken > &CompiledTokens, const TOperatorJumpTable< ContextType > &InJumpTable, const ContextType *InContext=nullptr)
 

Detailed Description

Define some expression types for basic arithmetic

An expression parser, responsible for lexing, compiling, and evaluating expressions. The parser supports 3 functions:

  1. Lexing the expression into a set of user defined tokens,
  2. Compiling the tokenized expression to an efficient reverse-polish execution order,
  3. Evaluating the compiled tokens

See ExpressionParserExamples.cpp for example usage.

Typedef Documentation

◆ CompileResultType

◆ LexResultType

◆ TCompileResultType

◆ TLexResultType

Function Documentation

◆ Compile() [1/4]

template<typename CharType >
TCompileResultType< CharType > ExpressionParser::Compile ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  TokenDefinitions,
const FExpressionGrammar InGrammar 
)

Compile the specified expression into an array of Reverse-Polish order nodes for evaluation, according to our grammar definition

◆ Compile() [2/4]

template<typename CharType >
CORE_API TCompileResultType< CharType > ExpressionParser::Compile ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  TokenDefinitions,
const FExpressionGrammar InGrammar 
)

Compile the specified expression into an array of Reverse-Polish order nodes for evaluation, according to our grammar definition

◆ Compile() [3/4]

template<typename CharType >
TCompileResultType< CharType > ExpressionParser::Compile ( TArray< TExpressionToken< CharType > >  InTokens,
const FExpressionGrammar InGrammar 
)

Compile the specified tokens into an array of Reverse-Polish order nodes for evaluation, according to our grammar definition

◆ Compile() [4/4]

template<typename CharType >
CORE_API TCompileResultType< CharType > ExpressionParser::Compile ( TArray< TExpressionToken< CharType > >  InTokens,
const FExpressionGrammar InGrammar 
)

Compile the specified tokens into an array of Reverse-Polish order nodes for evaluation, according to our grammar definition

◆ Compile< ANSICHAR >() [1/2]

template CORE_API TCompileResultType< ANSICHAR > ExpressionParser::Compile< ANSICHAR > ( const ANSICHAR InExpression,
const TTokenDefinitions< ANSICHAR > &  TokenDefinitions,
const FExpressionGrammar InGrammar 
)

◆ Compile< ANSICHAR >() [2/2]

◆ Compile< UTF8CHAR >() [1/2]

template CORE_API TCompileResultType< UTF8CHAR > ExpressionParser::Compile< UTF8CHAR > ( const UTF8CHAR InExpression,
const TTokenDefinitions< UTF8CHAR > &  TokenDefinitions,
const FExpressionGrammar InGrammar 
)

◆ Compile< UTF8CHAR >() [2/2]

◆ Compile< WIDECHAR >() [1/2]

template CORE_API TCompileResultType< WIDECHAR > ExpressionParser::Compile< WIDECHAR > ( const WIDECHAR InExpression,
const TTokenDefinitions< WIDECHAR > &  TokenDefinitions,
const FExpressionGrammar InGrammar 
)

◆ Compile< WIDECHAR >() [2/2]

◆ ConsumeLocalizedNumber()

CORE_API TOptional< FExpressionError > ExpressionParser::ConsumeLocalizedNumber ( FExpressionTokenConsumer Consumer)

Consume a localized number from the specified consumer's stream, if one exists at the current read position

◆ ConsumeLocalizedNumberWithAgnosticFallback()

CORE_API TOptional< FExpressionError > ExpressionParser::ConsumeLocalizedNumberWithAgnosticFallback ( FExpressionTokenConsumer Consumer)

Consume a localized number from the specified consumer's stream, if one exists at the current read position

◆ ConsumeNumber()

CORE_API TOptional< FExpressionError > ExpressionParser::ConsumeNumber ( FExpressionTokenConsumer Consumer)

Consume a number from the specified consumer's stream, if one exists at the current read position

◆ ConsumeNumberWithRules()

CORE_API TOptional< FExpressionError > ExpressionParser::ConsumeNumberWithRules ( FExpressionTokenConsumer Consumer,
const FDecimalNumberFormattingRules InFormattingRules 
)

Consume a number formatted using the given rules from the specified consumer's stream, if one exists at the current read position

◆ ConsumeSymbol()

template<typename TSymbol >
TOptional< FExpressionError > ExpressionParser::ConsumeSymbol ( FExpressionTokenConsumer Consumer)

Consume a symbol from the specified consumer's stream, if one exists at the current read position

◆ Evaluate() [1/6]

template<typename CharType >
FExpressionResult ExpressionParser::Evaluate ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TIOperatorEvaluationEnvironment< CharType > &  InEnvironment 
)

Evaluate the specified expression using the specified token definitions, grammar definition, and evaluation environment

◆ Evaluate() [2/6]

template<typename CharType >
CORE_API FExpressionResult ExpressionParser::Evaluate ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TIOperatorEvaluationEnvironment< CharType > &  InEnvironment 
)

Evaluate the specified expression using the specified token definitions, grammar definition, and evaluation environment

◆ Evaluate() [3/6]

template<typename CharType , typename ContextType >
FExpressionResult ExpressionParser::Evaluate ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TOperatorJumpTable< ContextType > &  InJumpTable,
const ContextType *  InContext = nullptr 
)

Templated versions of evaluation functions used when passing a specific jump table and context

◆ Evaluate() [4/6]

template<typename ContextType >
FExpressionResult ExpressionParser::Evaluate ( const TArray< FCompiledToken > &  CompiledTokens,
const TOperatorJumpTable< ContextType > &  InJumpTable,
const ContextType *  InContext = nullptr 
)

◆ Evaluate() [5/6]

template<typename CharType >
FExpressionResult ExpressionParser::Evaluate ( const TArray< TCompiledToken< CharType > > &  CompiledTokens,
const TIOperatorEvaluationEnvironment< CharType > &  InEnvironment 
)

Evaluate the specified pre-compiled tokens using an evaluation environment

Get the token pertaining to the specified operand index

Add a new token to the runtime generated array

◆ Evaluate() [6/6]

template<typename CharType >
CORE_API FExpressionResult ExpressionParser::Evaluate ( const TArray< TCompiledToken< CharType > > &  CompiledTokens,
const TIOperatorEvaluationEnvironment< CharType > &  InEnvironment 
)

Evaluate the specified pre-compiled tokens using an evaluation environment

Get the token pertaining to the specified operand index

Add a new token to the runtime generated array

◆ Evaluate< ANSICHAR >() [1/2]

template CORE_API FExpressionResult ExpressionParser::Evaluate< ANSICHAR > ( const ANSICHAR InExpression,
const TTokenDefinitions< ANSICHAR > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TIOperatorEvaluationEnvironment< ANSICHAR > &  InEnvironment 
)

◆ Evaluate< ANSICHAR >() [2/2]

◆ Evaluate< UTF8CHAR >() [1/2]

◆ Evaluate< UTF8CHAR >() [2/2]

template CORE_API FExpressionResult ExpressionParser::Evaluate< UTF8CHAR > ( const UTF8CHAR InExpression,
const TTokenDefinitions< UTF8CHAR > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TIOperatorEvaluationEnvironment< UTF8CHAR > &  InEnvironment 
)

◆ Evaluate< WIDECHAR >() [1/2]

◆ Evaluate< WIDECHAR >() [2/2]

template CORE_API FExpressionResult ExpressionParser::Evaluate< WIDECHAR > ( const WIDECHAR InExpression,
const TTokenDefinitions< WIDECHAR > &  InTokenDefinitions,
const FExpressionGrammar InGrammar,
const TIOperatorEvaluationEnvironment< WIDECHAR > &  InEnvironment 
)

◆ GetLocalizedNumberFormattingRules()

CORE_API const FDecimalNumberFormattingRules & ExpressionParser::GetLocalizedNumberFormattingRules ( )

Get the default set number formatting rules based on the current locale and user settings

◆ Lex() [1/2]

template<typename CharType >
TLexResultType< CharType > ExpressionParser::Lex ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  TokenDefinitions 
)

Lex the specified string, using the specified grammar

◆ Lex() [2/2]

template<typename CharType >
CORE_API TLexResultType< CharType > ExpressionParser::Lex ( const CharType *  InExpression,
const TTokenDefinitions< CharType > &  TokenDefinitions 
)

Lex the specified string, using the specified grammar

◆ Lex< ANSICHAR >()

template CORE_API TLexResultType< ANSICHAR > ExpressionParser::Lex< ANSICHAR > ( const ANSICHAR InExpression,
const TTokenDefinitions< ANSICHAR > &  TokenDefinitions 
)

◆ Lex< UTF8CHAR >()

template CORE_API TLexResultType< UTF8CHAR > ExpressionParser::Lex< UTF8CHAR > ( const UTF8CHAR InExpression,
const TTokenDefinitions< UTF8CHAR > &  TokenDefinitions 
)

◆ Lex< WIDECHAR >()

template CORE_API TLexResultType< WIDECHAR > ExpressionParser::Lex< WIDECHAR > ( const WIDECHAR InExpression,
const TTokenDefinitions< WIDECHAR > &  TokenDefinitions 
)

◆ ParseLocalizedNumber()

CORE_API TOptional< FStringToken > ExpressionParser::ParseLocalizedNumber ( const FTokenStream InStream,
FStringToken Accumulate = nullptr,
double OutValue = nullptr 
)

Parse a localized number from the given stream, optionally from a specific read position

◆ ParseLocalizedNumberWithAgnosticFallback()

CORE_API TOptional< FStringToken > ExpressionParser::ParseLocalizedNumberWithAgnosticFallback ( const FTokenStream InStream,
FStringToken Accumulate = nullptr,
double OutValue = nullptr 
)

Parse a localized number from the given stream, optionally from a specific read position

◆ ParseNumber()

CORE_API TOptional< FStringToken > ExpressionParser::ParseNumber ( const FTokenStream InStream,
FStringToken Accumulate = nullptr,
double OutValue = nullptr 
)

Parse a number from the given stream, optionally from a specific read position

◆ ParseNumberWithFallback()

CORE_API TOptional< FStringToken > ExpressionParser::ParseNumberWithFallback ( const FTokenStream InStream,
const FDecimalNumberFormattingRules InPrimaryFormattingRules,
const FDecimalNumberFormattingRules InFallbackFormattingRules,
FStringToken Accumulate = nullptr,
double OutValue = nullptr 
)

Parse a number formatted using the given rules from the given stream, optionally from a specific read position

◆ ParseNumberWithRules()

CORE_API TOptional< FStringToken > ExpressionParser::ParseNumberWithRules ( const FTokenStream InStream,
const FDecimalNumberFormattingRules InFormattingRules,
FStringToken Accumulate = nullptr,
double OutValue = nullptr 
)

Parse a number formatted using the given rules from the given stream, optionally from a specific read position