Pig: Added ::getHexDigit

This commit is contained in:
Paul Beckingham 2015-12-30 11:06:43 -05:00
parent 91b1d512a7
commit a66e03e858
2 changed files with 31 additions and 0 deletions

View file

@ -171,6 +171,36 @@ bool Pig::getDigits (int& result)
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:
// int frac? exp?