MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / ExtractOperatorToken

Method ExtractOperatorToken

libraries/muparser/src/muParserTokenReader.cpp:392–411  ·  view source on GitHub ↗

\brief Check Expression for the presence of a binary operator token. Userdefined binary operator "++" gives inconsistent parsing result for the equations "a++b" and "a ++ b" if alphabetic characters are allowed in operator tokens. To avoid this this function checks specifically for operator tokens. */

Source from the content-addressed store, hash-verified

390 for operator tokens.
391 */
392 int ParserTokenReader::ExtractOperatorToken(string_type& a_sTok, std::size_t a_iPos) const
393 {
394 // Changed as per Issue 6: https://code.google.com/p/muparser/issues/detail?id=6
395 auto iEnd = m_strFormula.find_first_not_of(m_pParser->ValidOprtChars(), a_iPos);
396 if (iEnd == string_type::npos)
397 iEnd = m_strFormula.length();
398
399 // Assign token string if there was something found
400 if (a_iPos != iEnd)
401 {
402 a_sTok = string_type(m_strFormula.begin() + a_iPos, m_strFormula.begin() + iEnd);
403 return static_cast<int>(iEnd);
404 }
405 else
406 {
407 // There is still the chance of having to deal with an operator consisting exclusively
408 // of alphabetic characters.
409 return ExtractToken(_T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, (std::size_t)a_iPos);
410 }
411 }
412
413
414 /** \brief Check if a built in operator or other token can be found

Callers

nothing calls this directly

Calls 2

ValidOprtCharsMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected