Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ExpressionParser Namespace Reference

Typedefs

typedef TValueOrError< TArray< FExpressionToken >, FExpressionErrorLexResultType
 
typedef TValueOrError< TArray< FCompiledToken >, FExpressionErrorCompileResultType
 

Functions

const FDecimalNumberFormattingRulesGetLocalizedNumberFormattingRules ()
 
TOptional< FStringTokenParseNumberWithFallback (const FTokenStream &InStream, const FDecimalNumberFormattingRules &InPrimaryFormattingRules, const FDecimalNumberFormattingRules &InFallbackFormattingRules, FStringToken *Accumulate=nullptr, double *OutValue=nullptr)
 
TOptional< FStringTokenParseNumberWithRules (const FTokenStream &InStream, const FDecimalNumberFormattingRules &InFormattingRules, FStringToken *Accumulate=nullptr, double *OutValue=nullptr)
 
TOptional< FStringTokenParseLocalizedNumberWithAgnosticFallback (const FTokenStream &InStream, FStringToken *Accumulate=nullptr, double *OutValue=nullptr)
 
TOptional< FStringTokenParseLocalizedNumber (const FTokenStream &InStream, FStringToken *Accumulate=nullptr, double *OutValue=nullptr)
 
TOptional< FStringTokenParseNumber (const FTokenStream &InStream, FStringToken *Accumulate=nullptr, double *OutValue=nullptr)
 
TOptional< FExpressionErrorConsumeNumberWithRules (FExpressionTokenConsumer &Consumer, const FDecimalNumberFormattingRules &InFormattingRules)
 
TOptional< FExpressionErrorConsumeLocalizedNumberWithAgnosticFallback (FExpressionTokenConsumer &Consumer)
 
TOptional< FExpressionErrorConsumeLocalizedNumber (FExpressionTokenConsumer &Consumer)
 
TOptional< FExpressionErrorConsumeNumber (FExpressionTokenConsumer &Consumer)
 
template<typename TSymbol >
TOptional< FExpressionErrorConsumeSymbol (FExpressionTokenConsumer &Consumer)
 
LexResultType Lex (const TCHAR *InExpression, const FTokenDefinitions &TokenDefinitions)
 
CompileResultType Compile (const TCHAR *InExpression, const FTokenDefinitions &TokenDefinitions, const FExpressionGrammar &InGrammar)
 
CompileResultType Compile (TArray< FExpressionToken > InTokens, const FExpressionGrammar &InGrammar)
 
FExpressionResult Evaluate (const TCHAR *InExpression, const FTokenDefinitions &InTokenDefinitions, const FExpressionGrammar &InGrammar, const IOperatorEvaluationEnvironment &InEnvironment)
 
FExpressionResult Evaluate (const TArray< FCompiledToken > &CompiledTokens, const IOperatorEvaluationEnvironment &InEnvironment)
 
template<typename ContextType >
FExpressionResult Evaluate (const TCHAR *InExpression, const FTokenDefinitions &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

Function Documentation

◆ Compile() [1/2]

CompileResultType ExpressionParser::Compile ( const TCHAR * InExpression,
const FTokenDefinitions & 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/2]

CompileResultType ExpressionParser::Compile ( TArray< FExpressionToken > InTokens,
const FExpressionGrammar & InGrammar )

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

◆ ConsumeLocalizedNumber()

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()

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()

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

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

◆ ConsumeNumberWithRules()

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

Definition at line 69 of file BasicMathExpressionEvaluator.h.

◆ Evaluate() [1/4]

FExpressionResult ExpressionParser::Evaluate ( const TArray< FCompiledToken > & CompiledTokens,
const IOperatorEvaluationEnvironment & InEnvironment )

Evaluate the specified pre-compiled tokens using an evaluation environment

◆ Evaluate() [2/4]

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

Definition at line 49 of file ExpressionParser.h.

◆ Evaluate() [3/4]

FExpressionResult ExpressionParser::Evaluate ( const TCHAR * InExpression,
const FTokenDefinitions & InTokenDefinitions,
const FExpressionGrammar & InGrammar,
const IOperatorEvaluationEnvironment & InEnvironment )

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

◆ Evaluate() [4/4]

template<typename ContextType >
FExpressionResult ExpressionParser::Evaluate ( const TCHAR * InExpression,
const FTokenDefinitions & 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

Definition at line 42 of file ExpressionParser.h.

◆ GetLocalizedNumberFormattingRules()

const FDecimalNumberFormattingRules & ExpressionParser::GetLocalizedNumberFormattingRules ( )

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

◆ Lex()

LexResultType ExpressionParser::Lex ( const TCHAR * InExpression,
const FTokenDefinitions & TokenDefinitions )

Lex the specified string, using the specified grammar

◆ ParseLocalizedNumber()

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()

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()

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()

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()

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