Token: Allow dollar sign in identifiers
This commit is contained in:
parent
30354ee026
commit
a65ae3ce2e
|
@ -65,7 +65,7 @@ void Token::update_property_info()
|
||||||
if (!_str.empty()) {
|
if (!_str.empty()) {
|
||||||
if (_str == "true" || _str == "false")
|
if (_str == "true" || _str == "false")
|
||||||
_tokType = eBoolean;
|
_tokType = eBoolean;
|
||||||
else if (_str[0] == '_' || std::isalpha((unsigned char)_str[0])) { // Name
|
else if (std::isalpha((unsigned char)_str[0]) || _str[0] == '_' || _str[0] == '$') { // Name
|
||||||
if (_varId)
|
if (_varId)
|
||||||
_tokType = eVariable;
|
_tokType = eVariable;
|
||||||
else if (_tokType != eVariable && _tokType != eFunction && _tokType != eType && _tokType != eKeyword)
|
else if (_tokType != eVariable && _tokType != eFunction && _tokType != eType && _tokType != eKeyword)
|
||||||
|
|
|
@ -85,6 +85,7 @@ private:
|
||||||
TEST_CASE(isNameGuarantees3)
|
TEST_CASE(isNameGuarantees3)
|
||||||
TEST_CASE(isNameGuarantees4)
|
TEST_CASE(isNameGuarantees4)
|
||||||
TEST_CASE(isNameGuarantees5)
|
TEST_CASE(isNameGuarantees5)
|
||||||
|
TEST_CASE(isNameGuarantees6)
|
||||||
|
|
||||||
TEST_CASE(canFindMatchingBracketsNeedsOpen);
|
TEST_CASE(canFindMatchingBracketsNeedsOpen);
|
||||||
TEST_CASE(canFindMatchingBracketsInnerPair);
|
TEST_CASE(canFindMatchingBracketsInnerPair);
|
||||||
|
@ -888,6 +889,11 @@ private:
|
||||||
ASSERT_EQUALS(false, tok.isNumber());
|
ASSERT_EQUALS(false, tok.isNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void isNameGuarantees6() const {
|
||||||
|
Token tok(nullptr);
|
||||||
|
tok.str("$f");
|
||||||
|
ASSERT_EQUALS(true, tok.isName());
|
||||||
|
}
|
||||||
|
|
||||||
void canFindMatchingBracketsNeedsOpen() const {
|
void canFindMatchingBracketsNeedsOpen() const {
|
||||||
givenACodeSampleToTokenize var("std::deque<std::set<int> > intsets;");
|
givenACodeSampleToTokenize var("std::deque<std::set<int> > intsets;");
|
||||||
|
|
Loading…
Reference in New Issue