\brief Check if a built in operator or other token can be found \param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. \return true if an operator token has been found. */
| 416 | \return true if an operator token has been found. |
| 417 | */ |
| 418 | bool ParserTokenReader::IsBuiltIn(token_type& a_Tok) |
| 419 | { |
| 420 | const char_type** const pOprtDef = m_pParser->GetOprtDef(), |
| 421 | * const szFormula = m_strFormula.c_str(); |
| 422 | |
| 423 | // Compare token with function and operator strings |
| 424 | // check string for operator/function |
| 425 | for (int i = 0; pOprtDef[i]; i++) |
| 426 | { |
| 427 | std::size_t len(std::char_traits<char_type>::length(pOprtDef[i])); |
| 428 | if (string_type(pOprtDef[i]) == string_type(szFormula + m_iPos, szFormula + m_iPos + len)) |
| 429 | { |
| 430 | switch (i) |
| 431 | { |
| 432 | case cmLAND: |
| 433 | case cmLOR: |
| 434 | case cmLT: |
| 435 | case cmGT: |
| 436 | case cmLE: |
| 437 | case cmGE: |
| 438 | case cmNEQ: |
| 439 | case cmEQ: |
| 440 | case cmADD: |
| 441 | case cmSUB: |
| 442 | case cmMUL: |
| 443 | case cmDIV: |
| 444 | case cmPOW: |
| 445 | case cmASSIGN: |
| 446 | // The assignment operator need special treatment |
| 447 | if (i == cmASSIGN && m_iSynFlags & noASSIGN) |
| 448 | Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); |
| 449 | |
| 450 | if (!m_pParser->HasBuiltInOprt()) continue; |
| 451 | if (m_iSynFlags & noOPT) |
| 452 | { |
| 453 | // Maybe its an infix operator not an operator |
| 454 | // Both operator types can share characters in |
| 455 | // their identifiers |
| 456 | if (IsInfixOpTok(a_Tok)) |
| 457 | return true; |
| 458 | |
| 459 | Error(ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef[i]); |
| 460 | } |
| 461 | |
| 462 | m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE | noEND; |
| 463 | break; |
| 464 | |
| 465 | case cmBO: |
| 466 | if (m_iSynFlags & noBO) |
| 467 | Error(ecUNEXPECTED_PARENS, m_iPos, pOprtDef[i]); |
| 468 | |
| 469 | if (m_lastTok.GetCode() == cmFUNC) |
| 470 | m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; |
| 471 | else |
| 472 | m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; |
| 473 | |
| 474 | m_bracketStack.push(cmBO); |
| 475 | break; |
nothing calls this directly
no test coverage detected