Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Functions | Variables
Parser::ShuntingYard Namespace Reference

Namespaces

 Operators
 classes for operators on shunting yards operator stack
 
 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 More...
 
std::string RemoveWhiteSpaces (const std::string &text)
 remove all whitespaces and convert to lowercase More...
 
void InitParser ()
 initialize some internal variables More...
 
void CleanUpParser ()
 clean up some internal static variables More...
 
std::string FindOperator (const std::string &searchString)
 compare the first characters in string with supportedBinaryOperations, return longest match More...
 
bool ConvertToRPN (const std::string &expression, const ConstantMap &constants, std::queue< RPNTokens::TokenBase * > &rpn)
 convert expression to RPN * More...
 
bool EvaluateRPN (std::queue< RPNTokens::TokenBase * > &input, double &result)
 evaluate RPN in input More...
 

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

void Parser::ShuntingYard::CleanUpParser ( )

clean up some internal static variables

Definition at line 300 of file ParseExp.cpp.

References ifOperator, ifOperatorClose, parenthesesOperator, supportedBinaryOperations, and supportedFunctions.

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

clear the queue

Definition at line 217 of file ParseExp.cpp.

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

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 Parser::ShuntingYard::Operators::OperatorBase::ComparePrecedence(), FindOperator(), ifOperator, ifOperatorClose, InitParser(), parenthesesOperator, supportedBinaryOperations, and supportedFunctions.

Referenced by Parser::ParseExpression().

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(), and Parser::ShuntingYard::RPNTokens::TokenBase::evaluate().

Referenced by Parser::ParseExpression().

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.

Referenced by ConvertToRPN().

void Parser::ShuntingYard::InitParser ( )

initialize some internal variables

Definition at line 248 of file ParseExp.cpp.

References ifOperator, ifOperatorClose, vigra_ext::log(), M_PI, parenthesesOperator, vigra_ext::pow(), supportedBinaryOperations, and supportedFunctions.

Referenced by ConvertToRPN().

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 hugin_utils::tolower().

Referenced by Parser::ParseExpression().

Variable Documentation

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

Definition at line 243 of file ParseExp.cpp.

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

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

Definition at line 244 of file ParseExp.cpp.

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

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

Definition at line 242 of file ParseExp.cpp.

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

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

Definition at line 239 of file ParseExp.cpp.

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

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

Definition at line 245 of file ParseExp.cpp.

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