Lexer: Migrated to unicodeHexDigit

This commit is contained in:
Paul Beckingham 2018-01-25 00:53:47 -05:00
parent cac258ef72
commit e199bc98b3
2 changed files with 10 additions and 20 deletions

View file

@ -159,15 +159,6 @@ bool Lexer::isDigit (int c)
return c >= 0x30 && c <= 0x39; return c >= 0x30 && c <= 0x39;
} }
////////////////////////////////////////////////////////////////////////////////
// Digits 0-9 a-f A-F.
bool Lexer::isHexDigit (int c)
{
return (c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F');
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Lexer::isIdentifierStart (int c) bool Lexer::isIdentifierStart (int c)
{ {
@ -581,7 +572,7 @@ bool Lexer::isUUID (std::string& token, Lexer::Type& type, bool endBoundary)
{ {
if (uuid_pattern[i] == 'x') if (uuid_pattern[i] == 'x')
{ {
if (! isHexDigit (_text[marker + i])) if (! unicodeHexDigit (_text[marker + i]))
break; break;
} }
else if (uuid_pattern[i] != _text[marker + i]) else if (uuid_pattern[i] != _text[marker + i])
@ -616,7 +607,7 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type)
{ {
marker += 2; marker += 2;
while (isHexDigit (_text[marker])) while (unicodeHexDigit (_text[marker]))
++marker; ++marker;
if (marker - _cursor > 2) if (marker - _cursor > 2)
@ -1469,10 +1460,10 @@ bool Lexer::readWord (
else if (eos - cursor >= 6 && else if (eos - cursor >= 6 &&
((text[cursor + 0] == 'U' && text[cursor + 1] == '+') || ((text[cursor + 0] == 'U' && text[cursor + 1] == '+') ||
(text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) && (text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) &&
isHexDigit (text[cursor + 2]) && unicodeHexDigit (text[cursor + 2]) &&
isHexDigit (text[cursor + 3]) && unicodeHexDigit (text[cursor + 3]) &&
isHexDigit (text[cursor + 4]) && unicodeHexDigit (text[cursor + 4]) &&
isHexDigit (text[cursor + 5])) unicodeHexDigit (text[cursor + 5]))
{ {
word += utf8_character ( word += utf8_character (
hexToInt ( hexToInt (
@ -1553,10 +1544,10 @@ bool Lexer::readWord (
else if (eos - cursor >= 6 && else if (eos - cursor >= 6 &&
((text[cursor + 0] == 'U' && text[cursor + 1] == '+') || ((text[cursor + 0] == 'U' && text[cursor + 1] == '+') ||
(text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) && (text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) &&
isHexDigit (text[cursor + 2]) && unicodeHexDigit (text[cursor + 2]) &&
isHexDigit (text[cursor + 3]) && unicodeHexDigit (text[cursor + 3]) &&
isHexDigit (text[cursor + 4]) && unicodeHexDigit (text[cursor + 4]) &&
isHexDigit (text[cursor + 5])) unicodeHexDigit (text[cursor + 5]))
{ {
word += utf8_character ( word += utf8_character (
hexToInt ( hexToInt (

View file

@ -63,7 +63,6 @@ public:
static const std::string typeName (const Lexer::Type&); static const std::string typeName (const Lexer::Type&);
static bool isAlpha (int); static bool isAlpha (int);
static bool isDigit (int); static bool isDigit (int);
static bool isHexDigit (int);
static bool isIdentifierStart (int); static bool isIdentifierStart (int);
static bool isIdentifierNext (int); static bool isIdentifierNext (int);
static bool isSingleCharOperator (int); static bool isSingleCharOperator (int);