bump simplecpp
This commit is contained in:
parent
4dbf006dc7
commit
aabe3a70e1
|
@ -45,6 +45,11 @@ static bool isHex(const std::string &s)
|
||||||
return s.size()>2 && (s.compare(0,2,"0x")==0 || s.compare(0,2,"0X")==0);
|
return s.size()>2 && (s.compare(0,2,"0x")==0 || s.compare(0,2,"0X")==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isOct(const std::string &s)
|
||||||
|
{
|
||||||
|
return s.size()>1 && (s[0]=='0') && (s[1] >= '0') && (s[1] < '8');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const simplecpp::TokenString DEFINE("define");
|
static const simplecpp::TokenString DEFINE("define");
|
||||||
static const simplecpp::TokenString UNDEF("undef");
|
static const simplecpp::TokenString UNDEF("undef");
|
||||||
|
@ -76,9 +81,12 @@ static long long stringToLL(const std::string &s)
|
||||||
{
|
{
|
||||||
long long ret;
|
long long ret;
|
||||||
const bool hex = isHex(s);
|
const bool hex = isHex(s);
|
||||||
std::istringstream istr(hex ? s.substr(2) : s);
|
const bool oct = isOct(s);
|
||||||
|
std::istringstream istr(hex ? s.substr(2) : oct ? s.substr(1) : s);
|
||||||
if (hex)
|
if (hex)
|
||||||
istr >> std::hex;
|
istr >> std::hex;
|
||||||
|
else if (oct)
|
||||||
|
istr >> std::oct;
|
||||||
istr >> ret;
|
istr >> ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -87,9 +95,12 @@ static unsigned long long stringToULL(const std::string &s)
|
||||||
{
|
{
|
||||||
unsigned long long ret;
|
unsigned long long ret;
|
||||||
const bool hex = isHex(s);
|
const bool hex = isHex(s);
|
||||||
std::istringstream istr(hex ? s.substr(2) : s);
|
const bool oct = isOct(s);
|
||||||
|
std::istringstream istr(hex ? s.substr(2) : oct ? s.substr(1) : s);
|
||||||
if (hex)
|
if (hex)
|
||||||
istr >> std::hex;
|
istr >> std::hex;
|
||||||
|
else if (oct)
|
||||||
|
istr >> std::oct;
|
||||||
istr >> ret;
|
istr >> ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -769,7 +780,7 @@ void simplecpp::TokenList::combineOperators()
|
||||||
}
|
}
|
||||||
// match: [0-9.]+E [+-] [0-9]+
|
// match: [0-9.]+E [+-] [0-9]+
|
||||||
const char lastChar = tok->str()[tok->str().size() - 1];
|
const char lastChar = tok->str()[tok->str().size() - 1];
|
||||||
if (tok->number && !isHex(tok->str()) && (lastChar == 'E' || lastChar == 'e') && tok->next && tok->next->isOneOf("+-") && tok->next->next && tok->next->next->number) {
|
if (tok->number && !isHex(tok->str()) && !isOct(tok->str()) && (lastChar == 'E' || lastChar == 'e') && tok->next && tok->next->isOneOf("+-") && tok->next->next && tok->next->next->number) {
|
||||||
tok->setstr(tok->str() + tok->next->op + tok->next->next->str());
|
tok->setstr(tok->str() + tok->next->op + tok->next->next->str());
|
||||||
deleteToken(tok->next);
|
deleteToken(tok->next);
|
||||||
deleteToken(tok->next);
|
deleteToken(tok->next);
|
||||||
|
@ -830,7 +841,7 @@ void simplecpp::TokenList::combineOperators()
|
||||||
} else if ((tok->op == '<' || tok->op == '>') && tok->op == tok->next->op) {
|
} else if ((tok->op == '<' || tok->op == '>') && tok->op == tok->next->op) {
|
||||||
tok->setstr(tok->str() + tok->next->str());
|
tok->setstr(tok->str() + tok->next->str());
|
||||||
deleteToken(tok->next);
|
deleteToken(tok->next);
|
||||||
if (tok->next && tok->next->op == '=') {
|
if (tok->next && tok->next->op == '=' && tok->next->next && tok->next->next->op != '=') {
|
||||||
tok->setstr(tok->str() + tok->next->str());
|
tok->setstr(tok->str() + tok->next->str());
|
||||||
deleteToken(tok->next);
|
deleteToken(tok->next);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue