| 107 | }; |
| 108 | |
| 109 | void Token::update_property_info() |
| 110 | { |
| 111 | assert(mImpl); |
| 112 | |
| 113 | setFlag(fIsControlFlowKeyword, false); |
| 114 | // TODO: clear fIsLong |
| 115 | isStandardType(false); |
| 116 | |
| 117 | if (!mStr.empty()) { |
| 118 | if (mStr == "true" || mStr == "false") { |
| 119 | if (mImpl->mVarId) { |
| 120 | if (mIsCpp) |
| 121 | throw InternalError(this, "Internal error. VarId set for bool literal."); |
| 122 | tokType(eVariable); |
| 123 | } |
| 124 | else |
| 125 | tokType(eBoolean); |
| 126 | } |
| 127 | else if (isStringLiteral(mStr)) { |
| 128 | tokType(eString); |
| 129 | isLong(isPrefixStringCharLiteral(mStr, '"', "L")); |
| 130 | } |
| 131 | else if (isCharLiteral(mStr)) { |
| 132 | tokType(eChar); |
| 133 | isLong(isPrefixStringCharLiteral(mStr, '\'', "L")); |
| 134 | } |
| 135 | else if (std::isalpha(static_cast<unsigned char>(mStr[0])) || mStr[0] == '_' || mStr[0] == '$') { // Name |
| 136 | if (mImpl->mVarId) |
| 137 | tokType(eVariable); |
| 138 | else if (mList.isKeyword(mStr)) { |
| 139 | tokType(eKeyword); |
| 140 | update_property_isStandardType(); |
| 141 | if (mTokType != eType) // cannot be a control-flow keyword when it is a type |
| 142 | setFlag(fIsControlFlowKeyword, controlFlowKeywords.find(mStr) != controlFlowKeywords.end()); |
| 143 | } |
| 144 | else if (mStr == "asm") { // TODO: not a keyword |
| 145 | tokType(eKeyword); |
| 146 | } |
| 147 | else { |
| 148 | tokType(eName); |
| 149 | // some types are not being treated as keywords |
| 150 | update_property_isStandardType(); |
| 151 | } |
| 152 | } else if (simplecpp::Token::isNumberLike(mStr)) { |
| 153 | if ((MathLib::isInt(mStr) || MathLib::isFloat(mStr)) && mStr.find('_') == std::string::npos) |
| 154 | tokType(eNumber); |
| 155 | else |
| 156 | tokType(eLiteral); // assume it is a user defined literal |
| 157 | } else if (mStr == "=" || mStr == "<<=" || mStr == ">>=" || |
| 158 | (mStr.size() == 2U && mStr[1] == '=' && std::strchr("+-*/%&^|", mStr[0]))) |
| 159 | tokType(eAssignmentOp); |
| 160 | else if (mStr.size() == 1 && mStr.find_first_of(",[]()?:") != std::string::npos) |
| 161 | tokType(eExtendedOp); |
| 162 | else if (mStr=="<<" || mStr==">>" || (mStr.size()==1 && mStr.find_first_of("+-*/%") != std::string::npos)) |
| 163 | tokType(eArithmeticalOp); |
| 164 | else if (mStr.size() == 1 && mStr.find_first_of("&|^~") != std::string::npos) |
| 165 | tokType(eBitOp); |
| 166 | else if (mStr.size() <= 2 && |
nothing calls this directly
no test coverage detected