Hugin trunk 0.1
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
Parser::ShuntingYard Namespace Reference

Namespaces

namespace  Operators
 classes for operators on shunting yards operator stack
 
namespace  RPNTokens
 classes for parsed tokens in rpn queue
 

Classes

class  ParseException
 internal exception class for all errors More...
 

Functions

void ClearQueue (std::queue< RPNTokens::TokenBase * > &input)
 clear the queue
 
std::string RemoveWhiteSpaces (const std::string &text)
 remove all whitespaces and convert to lowercase
 
void InitParser ()
 initialize some internal variables
 
void CleanUpParser ()
 clean up some internal static variables
 
std::string FindOperator (const std::string &searchString)
 compare the first characters in string with supportedBinaryOperations, return longest match
 
bool ConvertToRPN (const std::string &expression, const ConstantMap &constants, std::queue< RPNTokens::TokenBase * > &rpn)
 convert expression to RPN *
 
bool EvaluateRPN (std::queue< RPNTokens::TokenBase * > &input, double &result)
 evaluate RPN in input
 

Variables

static std::map< std::string, Operators::OperatorBase * > supportedBinaryOperations
 
static Operators::OperatorBaseparenthesesOperator = nullptr
 
static Operators::OperatorBaseifOperator = nullptr
 
static Operators::OperatorBaseifOperatorClose = nullptr
 
static std::map< std::string, Operators::FunctionOperator * > supportedFunctions
 

Function Documentation

◆ CleanUpParser()

void Parser::ShuntingYard::CleanUpParser ( )

clean up some internal static variables

Definition at line 300 of file ParseExp.cpp.

References ifOperator, ifOperatorClose, parenthesesOperator, supportedBinaryOperations, supportedFunctions, and threshold().

Referenced by Parser::PanoParseExpression().

◆ ClearQueue()

void Parser::ShuntingYard::ClearQueue ( std::queue< RPNTokens::TokenBase * > &  input)

clear the queue

Definition at line 217 of file ParseExp.cpp.

References threshold().

Referenced by EvaluateRPN(), and Parser::ParseExpression().

◆ ConvertToRPN()

bool Parser::ShuntingYard::ConvertToRPN ( const std::string &  expression,
const ConstantMap constants,
std::queue< RPNTokens::TokenBase * > &  rpn 
)

convert expression to RPN *

Returns
true, if expression could be converted to Reverse Polish notation (RPN), otherwise false

Definition at line 349 of file ParseExp.cpp.

References FindOperator(), ifOperator, ifOperatorClose, InitParser(), parenthesesOperator, supportedBinaryOperations, supportedFunctions, and threshold().

Referenced by Parser::ParseExpression().

◆ EvaluateRPN()

bool Parser::ShuntingYard::EvaluateRPN ( std::queue< RPNTokens::TokenBase * > &  input,
double result 
)

evaluate RPN in input

Returns
true, if input could be evaluated, result has the final value; otherwise false and result is unmodified

Definition at line 551 of file ParseExp.cpp.

References ClearQueue(), Parser::ShuntingYard::RPNTokens::TokenBase::evaluate(), and threshold().

Referenced by Parser::ParseExpression().

◆ FindOperator()

std::string Parser::ShuntingYard::FindOperator ( const std::string &  searchString)

compare the first characters in string with supportedBinaryOperations, return longest match

Definition at line 330 of file ParseExp.cpp.

References supportedBinaryOperations, and threshold().

Referenced by ConvertToRPN().

◆ InitParser()

void Parser::ShuntingYard::InitParser ( )

initialize some internal variables

Definition at line 248 of file ParseExp.cpp.

References ifOperator, ifOperatorClose, M_PI, parenthesesOperator, supportedBinaryOperations, supportedFunctions, and threshold().

Referenced by ConvertToRPN().

◆ RemoveWhiteSpaces()

std::string Parser::ShuntingYard::RemoveWhiteSpaces ( const std::string &  text)

remove all whitespaces and convert to lowercase

Definition at line 227 of file ParseExp.cpp.

References threshold().

Referenced by Parser::ParseExpression().

Variable Documentation

◆ ifOperator

Operators::OperatorBase* Parser::ShuntingYard::ifOperator = nullptr
static

Definition at line 243 of file ParseExp.cpp.

Referenced by CleanUpParser(), ConvertToRPN(), and InitParser().

◆ ifOperatorClose

Operators::OperatorBase* Parser::ShuntingYard::ifOperatorClose = nullptr
static

Definition at line 244 of file ParseExp.cpp.

Referenced by CleanUpParser(), ConvertToRPN(), and InitParser().

◆ parenthesesOperator

Operators::OperatorBase* Parser::ShuntingYard::parenthesesOperator = nullptr
static

Definition at line 242 of file ParseExp.cpp.

Referenced by CleanUpParser(), ConvertToRPN(), and InitParser().

◆ supportedBinaryOperations

std::map<std::string, Operators::OperatorBase*> Parser::ShuntingYard::supportedBinaryOperations
static

Definition at line 241 of file ParseExp.cpp.

Referenced by CleanUpParser(), ConvertToRPN(), FindOperator(), and InitParser().

◆ supportedFunctions

std::map<std::string, Operators::FunctionOperator*> Parser::ShuntingYard::supportedFunctions
static

Definition at line 245 of file ParseExp.cpp.

Referenced by CleanUpParser(), ConvertToRPN(), and InitParser().