NCBI C++ ToolKit
|
Search Toolkit Book for CExprParser
#include <corelib/expr.hpp>
Public Types | |
enum | EAutoVar { fAllowAutoVar = 0 , fDenyAutoVar = (1 << 0) , fLogicalOnly = (1 << 1) , eAllowAutoVar = fAllowAutoVar , eDenyAutoVar = fDenyAutoVar } |
Parser flags. More... | |
typedef int | TParserFlags |
Public Member Functions | |
CExprParser (TParserFlags auto_var=0) | |
~CExprParser (void) | |
void | Parse (const char *str) |
const CExprValue & | GetResult (void) const |
template<typename VT > | |
CExprSymbol * | AddSymbol (const char *name, VT value) |
Private Types | |
enum | EOperator { eBEGIN , eOPERAND , eERROR , eEND , eLPAR , eRPAR , eFUNC , ePOSTINC , ePOSTDEC , ePREINC , ePREDEC , ePLUS , eMINUS , eNOT , eCOM , ePOW , eMUL , eDIV , eMOD , eADD , eSUB , eASL , eASR , eLSR , eGT , eGE , eLT , eLE , eEQ , eNE , eAND , eXOR , eOR , eSET , eSETADD , eSETSUB , eSETMUL , eSETDIV , eSETMOD , eSETASL , eSETASR , eSETLSR , eSETAND , eSETXOR , eSETOR , eSETPOW , eCOMMA , eTERMINALS } |
enum | { hash_table_size = 1013 } |
enum | { max_stack_size = 256 } |
enum | { max_expression_length = 1024 } |
Private Member Functions | |
EOperator | Scan (bool operand) |
bool | Assign (void) |
CExprSymbol * | GetSymbol (const char *name) const |
void | ReportError (const string &msg) const |
EOperator | IfChar (char c, EOperator val, EOperator val_def) |
EOperator | IfElseChar (char c1, EOperator val1, char c2, EOperator val2, EOperator val_def) |
EOperator | IfLongest2ElseChar (char c1, char c2, EOperator val_true_longest, EOperator val_true, EOperator val_false, EOperator val_def) |
TParserFlags | AutoCreateVariable (void) const |
bool | LogicalOnly (void) const |
Static Private Member Functions | |
static void | ReportError (int pos, const string &msg) |
Private Attributes | |
CExprSymbol * | hash_table [hash_table_size] |
CExprValue | m_VStack [max_stack_size] |
int | m_v_sp |
EOperator | m_OStack [max_stack_size] |
int | m_o_sp |
const char * | m_Buf |
int | m_Pos |
TParserFlags | m_ParserFlags |
Static Private Attributes | |
static int | sm_lpr [eTERMINALS] |
static int | sm_rpr [eTERMINALS] |
typedef int CExprParser::TParserFlags |
|
private |
CExprParser::CExprParser | ( | CExprParser::TParserFlags | ParserFlags = 0 | ) |
Definition at line 416 of file expr.cpp.
References AddSymbol(), fabs, gcd(), hash_table, invmod(), log, log10(), prime(), to_float(), and to_int().
CExprParser::~CExprParser | ( | void | ) |
Definition at line 451 of file expr.cpp.
References hash_table, hash_table_size, and i.
|
inline |
Definition at line 382 of file expr.hpp.
References GetSymbol(), hash_table, hash_table_size, CExprSymbol::m_Next, string_hash_function(), and rapidjson::value.
Referenced by CExprParser(), CProjBulderApp::IsAllowedProjectTag(), Scan(), and CNcbiTestApplication::x_InitCommonParserVars().
|
private |
Definition at line 726 of file expr.cpp.
References CExprValue::m_Pos, m_v_sp, CExprSymbol::m_Val, CExprValue::m_Var, m_VStack, NULL, and ReportError().
Referenced by Parse().
|
inlineprivate |
Definition at line 346 of file expr.hpp.
References fDenyAutoVar, and m_ParserFlags.
Referenced by Scan().
|
inline |
Definition at line 289 of file expr.hpp.
References m_v_sp, m_VStack, and ReportError().
Referenced by CProjBulderApp::IsAllowedProjectTag(), and CNcbiTestApplication::x_CalcConfigValue().
|
private |
Definition at line 496 of file expr.cpp.
References hash_table, hash_table_size, CExprSymbol::m_Name, CExprSymbol::m_Next, NULL, and string_hash_function().
Referenced by AddSymbol(), and Scan().
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Definition at line 351 of file expr.hpp.
References fLogicalOnly, and m_ParserFlags.
Referenced by Scan().
void CExprParser::Parse | ( | const char * | str | ) |
Definition at line 738 of file expr.cpp.
References Assign(), BINARY, CExprValue::bval, eADD, eAND, eASL, eASR, eBEGIN, CExprSymbol::eBFUNC1, CExprSymbol::eBFUNC2, CExprValue::eBOOL, eCOM, eCOMMA, eDIV, eEND, eEQ, eERROR, CExprSymbol::eFFUNC1, CExprSymbol::eFFUNC2, CExprValue::eFLOAT, eFUNC, eGE, eGT, CExprSymbol::eIFUNC1, CExprSymbol::eIFUNC2, CExprValue::eINT, eLE, eLPAR, eLSR, eLT, eMINUS, eMOD, eMUL, eNE, eNOT, eOPERAND, eOR, ePLUS, ePOSTDEC, ePOSTINC, ePOW, ePREDEC, ePREINC, eRPAR, eSET, eSETADD, eSETAND, eSETASL, eSETASR, eSETDIV, eSETLSR, eSETMOD, eSETMUL, eSETOR, eSETPOW, eSETSUB, eSETXOR, CExprSymbol::eSFUNC1, CExprValue::eSTRING, eSUB, eXOR, CExprValue::fval, CExprValue::GetBool(), CExprValue::GetDouble(), CExprValue::GetInt(), CExprValue::GetString(), CExprValue::GetType(), int, CExprValue::ival, CExprSymbol::m_BoolFunc1, CExprSymbol::m_BoolFunc2, m_Buf, CExprSymbol::m_FloatFunc1, CExprSymbol::m_FloatFunc2, CExprSymbol::m_IntFunc1, CExprSymbol::m_IntFunc2, m_o_sp, m_OStack, m_Pos, CExprSymbol::m_StringFunc1, CExprValue::m_sval, CExprSymbol::m_Tag, m_v_sp, CExprSymbol::m_Val, CExprValue::m_Var, m_VStack, max_stack_size, NULL, ReportError(), Scan(), CExprValue::SetType(), sm_lpr, sm_rpr, and str().
Referenced by CProjBulderApp::IsAllowedProjectTag(), and CNcbiTestApplication::x_CalcConfigValue().
Definition at line 330 of file expr.hpp.
References m_Pos, msg(), and ReportError().
Referenced by ReportError().
Definition at line 326 of file expr.hpp.
References msg(), and NCBI_THROW2.
Referenced by Assign(), GetResult(), Parse(), and Scan().
|
private |
Definition at line 511 of file expr.cpp.
References AddSymbol(), AutoCreateVariable(), CExprValue::bval, eADD, eAllowAutoVar, eAND, eASL, eASR, CExprValue::eBOOL, eCOM, eCOMMA, eDIV, eEND, eEQ, eERROR, CExprValue::eFLOAT, eFUNC, eGE, eGT, CExprValue::eINT, eLE, eLPAR, eLSR, eLT, eMINUS, eMOD, eMUL, eNE, eNOT, eOPERAND, eOR, ePLUS, ePOSTDEC, ePOSTINC, ePOW, ePREDEC, ePREINC, eRPAR, eSET, eSETADD, eSETAND, eSETASL, eSETASR, eSETDIV, eSETLSR, eSETMOD, eSETMUL, eSETOR, eSETPOW, eSETSUB, eSETXOR, CExprValue::eSTRING, eSUB, CExprSymbol::eVARIABLE, eXOR, CExprValue::fval, GetSymbol(), IfChar(), IfElseChar(), IfLongest2ElseChar(), int, isalnum(), isspace(), CExprValue::ival, LogicalOnly(), m_Buf, CExprValue::m_Pos, m_Pos, CExprValue::m_sval, CExprSymbol::m_Tag, m_v_sp, CExprSymbol::m_Val, CExprValue::m_Var, m_VStack, max_expression_length, max_stack_size, n, NULL, ReportError(), CExprValue::SetType(), and util::strcmp().
Referenced by Parse().
|
private |
Definition at line 355 of file expr.hpp.
Referenced by AddSymbol(), CExprParser(), GetSymbol(), and ~CExprParser().
|
private |
Definition at line 367 of file expr.hpp.
Referenced by IfChar(), IfElseChar(), IfLongest2ElseChar(), Parse(), and Scan().
|
private |
|
private |
Definition at line 369 of file expr.hpp.
Referenced by AutoCreateVariable(), and LogicalOnly().
|
private |
Definition at line 368 of file expr.hpp.
Referenced by IfChar(), IfElseChar(), IfLongest2ElseChar(), Parse(), ReportError(), and Scan().
|
private |
|
private |
|
staticprivate |
|
staticprivate |