Parser Namespace Reference


Classes

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

Namespaces

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

Typedefs

typedef std::map< std::string,
double > 
ConstantMap

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
bool ParseExpression (const std::string &expression, double &result, const ConstantMap &constants)
 parse complete expression in 2 steps

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


Typedef Documentation

typedef std::map<std::string, double> Parser::ConstantMap

Definition at line 35 of file ParseExp.h.


Function Documentation

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

clear the queue

Definition at line 211 of file ParseExp.cpp.

Referenced by EvaluateRPN(), and ParseExpression().

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

remove all whitespaces and convert to lowercase

Definition at line 221 of file ParseExp.cpp.

References hugin_utils::tolower().

Referenced by ParseExpression().

void Parser::InitParser (  ) 

initialize some internal variables

Definition at line 242 of file ParseExp.cpp.

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

Referenced by ConvertToRPN().

void Parser::CleanUpParser (  ) 

clean up some internal static variables

Definition at line 294 of file ParseExp.cpp.

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

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

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

Definition at line 324 of file ParseExp.cpp.

References supportedBinaryOperations.

Referenced by ConvertToRPN().

bool Parser::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 343 of file ParseExp.cpp.

References Parser::Operators::OperatorBase::ComparePrecedence(), FindOperator(), ifOperator, ifOperatorClose, InitParser(), parenthesesOperator, supportedBinaryOperations, and supportedFunctions.

Referenced by ParseExpression().

bool Parser::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 544 of file ParseExp.cpp.

References ClearQueue().

Referenced by ParseExpression().

bool Parser::ParseExpression ( const std::string expression,
double &  result,
const ConstantMap constants = ConstantMap() 
)

parse complete expression in 2 steps

Definition at line 572 of file ParseExp.cpp.

References ClearQueue(), ConvertToRPN(), EvaluateRPN(), M_PI, and RemoveWhiteSpaces().

Referenced by UpdateSingleVar().


Variable Documentation

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

Definition at line 233 of file ParseExp.cpp.

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

Operators::OperatorBase* Parser::parenthesesOperator = nullptr [static]

Definition at line 236 of file ParseExp.cpp.

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

Operators::OperatorBase* Parser::ifOperator = nullptr [static]

Definition at line 237 of file ParseExp.cpp.

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

Operators::OperatorBase* Parser::ifOperatorClose = nullptr [static]

Definition at line 238 of file ParseExp.cpp.

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

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

Definition at line 239 of file ParseExp.cpp.

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


Generated on 25 Aug 2016 for Hugintrunk by  doxygen 1.4.7