mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Pig: Added ::getHexDigit
This commit is contained in:
parent
91b1d512a7
commit
a66e03e858
2 changed files with 31 additions and 0 deletions
30
src/Pig.cpp
30
src/Pig.cpp
|
@ -171,6 +171,36 @@ bool Pig::getDigits (int& result)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Pig::getHexDigit (int& result)
|
||||||
|
{
|
||||||
|
int c = _text[_cursor];
|
||||||
|
if (c &&
|
||||||
|
Lexer::isHexDigit (c))
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
{
|
||||||
|
result = c - '0';
|
||||||
|
++_cursor;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (c >= 'A' && c <= 'F')
|
||||||
|
{
|
||||||
|
result = c - 'A' + 10;
|
||||||
|
++_cursor;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (c >= 'a' && c <= 'f')
|
||||||
|
{
|
||||||
|
result = c - 'a' + 10;
|
||||||
|
++_cursor;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// number:
|
// number:
|
||||||
// int frac? exp?
|
// int frac? exp?
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
bool getUntilWS (std::string&);
|
bool getUntilWS (std::string&);
|
||||||
bool getDigit (int&);
|
bool getDigit (int&);
|
||||||
bool getDigits (int&);
|
bool getDigits (int&);
|
||||||
|
bool getHexDigit (int&);
|
||||||
bool getNumber (std::string&);
|
bool getNumber (std::string&);
|
||||||
bool getNumber (double&);
|
bool getNumber (double&);
|
||||||
bool getOneOf (const std::vector <std::string>&, std::string&);
|
bool getOneOf (const std::vector <std::string>&, std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue