本文整理汇总了C++中token_type::GetAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ token_type::GetAsString方法的具体用法?C++ token_type::GetAsString怎么用?C++ token_type::GetAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类token_type
的用法示例。
在下文中一共展示了token_type::GetAsString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsFunTok
/** \brief Check whether the token at a given position is a function token.
\param a_Tok [out] If a value token is found it will be placed here.
\throw ParserException if Syntaxflags do not allow a function at a_iPos
\return true if a function token has been found false otherwise.
\pre [assert] m_pParser!=0
*/
bool ParserTokenReader::IsFunTok(token_type &a_Tok)
{
string_type strTok;
int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
if (iEnd==m_iPos)
return false;
funmap_type::const_iterator item = m_pFunDef->find(strTok);
if (item==m_pFunDef->end())
return false;
// Check if the next sign is an opening bracket
const char_type *szFormula = m_strFormula.c_str();
if (szFormula[iEnd]!='(')
return false;
a_Tok.Set(item->second, strTok);
m_iPos = (int)iEnd;
if (m_iSynFlags & noFUN)
Error(ecUNEXPECTED_FUN, m_iPos-(int)a_Tok.GetAsString().length(), a_Tok.GetAsString());
m_iSynFlags = noANY ^ noBO;
return true;
}
示例2: IsUndefVarTok
/** \brief Check wheter a token at a given position is an undefined variable.
\param a_Tok [out] If a variable tom_pParser->m_vStringBufken has been found it will be placed here.
\return true if a variable token has been found.
\throw nothrow
*/
bool ParserTokenReader::IsUndefVarTok(token_type &a_Tok)
{
string_type strTok;
int iEnd( ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos) );
if ( iEnd==m_iPos )
return false;
if (m_iSynFlags & noVAR)
{
// <ibg/> 20061021 added token string strTok instead of a_Tok.GetAsString() as the
// token identifier.
// related bug report:
// http://sourceforge.net/tracker/index.php?func=detail&aid=1578779&group_id=137191&atid=737979
Error(ecUNEXPECTED_VAR, m_iPos - (int)a_Tok.GetAsString().length(), strTok);
}
// If a factory is available implicitely create new variables
if (m_pFactory)
{
value_type *fVar = m_pFactory(strTok.c_str(), m_pFactoryData);
a_Tok.SetVar(fVar, strTok );
// Do not use m_pParser->DefineVar( strTok, fVar );
// in order to define the new variable, it will clear the
// m_UsedVar array which will kill previousely defined variables
// from the list
// This is safe because the new variable can never override an existing one
// because they are checked first!
(*m_pVarDef)[strTok] = fVar;
m_UsedVar[strTok] = fVar; // Add variable to used-var-list
}
else
{
a_Tok.SetVar((value_type*)&m_fZero, strTok);
m_UsedVar[strTok] = 0; // Add variable to used-var-list
}
m_iPos = iEnd;
// Call the variable factory in order to let it define a new parser variable
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noPOSTOP | noINFIXOP | noSTR;
return true;
}
示例3: IsInfixOpTok
/** \brief Check if a string position contains a unary infix operator.
\return true if a function token has been found false otherwise.
*/
bool ParserTokenReader::IsInfixOpTok(token_type &a_Tok)
{
string_type sTok;
int iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, m_iPos);
if (iEnd==m_iPos)
return false;
funmap_type::const_iterator item = m_pInfixOprtDef->find(sTok);
if (item==m_pInfixOprtDef->end())
return false;
a_Tok.Set(item->second, sTok);
m_iPos = (int)iEnd;
if (m_iSynFlags & noINFIXOP)
Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString());
m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN;
return true;
}
示例4: IsInfixOpTok
/** \brief Check if a string position contains a unary infix operator.
\return true if a function token has been found false otherwise.
*/
bool ParserTokenReader::IsInfixOpTok(token_type &a_Tok)
{
string_type sTok;
int iEnd = ExtractToken(m_pParser->ValidInfixOprtChars(), sTok, m_iPos);
if (iEnd==m_iPos)
return false;
// iteraterate over all postfix operator strings
funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin();
for ( ; it!=m_pInfixOprtDef->rend(); ++it)
{
if (sTok.find(it->first)!=0)
continue;
a_Tok.Set(it->second, it->first);
m_iPos += (int)it->first.length();
if (m_iSynFlags & noINFIXOP)
Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString());
m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN;
return true;
}
return false;
/*
a_Tok.Set(item->second, sTok);
m_iPos = (int)iEnd;
if (m_iSynFlags & noINFIXOP)
Error(ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString());
m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN;
return true;
*/
}