本文整理汇总了C++中token_type::SetVar方法的典型用法代码示例。如果您正苦于以下问题:C++ token_type::SetVar方法的具体用法?C++ token_type::SetVar怎么用?C++ token_type::SetVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类token_type
的用法示例。
在下文中一共展示了token_type::SetVar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsVarTok
/** \brief Check wheter a token at a given position is a variable token.
\param a_Tok [out] If a variable token has been found it will be placed here.
\return true if a variable token has been found.
*/
bool ParserTokenReader::IsVarTok(token_type &a_Tok)
{
if (!m_pVarDef->size())
return false;
string_type strTok;
int iEnd = ExtractToken(m_pParser->ValidNameChars(), strTok, m_iPos);
if (iEnd==m_iPos)
return false;
varmap_type::const_iterator item = m_pVarDef->find(strTok);
if (item==m_pVarDef->end())
return false;
if (m_iSynFlags & noVAR)
Error(ecUNEXPECTED_VAR, m_iPos, strTok);
m_pParser->OnDetectVar(&m_strFormula, m_iPos, iEnd);
m_iPos = iEnd;
a_Tok.SetVar(item->second, strTok);
m_UsedVar[item->first] = item->second; // Add variable to used-var-list
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR;
// Zur Info hier die SynFlags von IsVal():
// m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
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;
}