mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Lexer: Migrated to unicodeHexDigit
This commit is contained in:
parent
323fdcf44b
commit
266fe67ab1
2 changed files with 9 additions and 19 deletions
|
@ -84,15 +84,6 @@ const std::string Lexer::typeName (const Lexer::Type& type)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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');
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Lexer::Type::number
|
// Lexer::Type::number
|
||||||
// \d+
|
// \d+
|
||||||
|
@ -381,7 +372,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)
|
||||||
|
@ -648,10 +639,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 (
|
||||||
|
@ -732,10 +723,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 (
|
||||||
|
|
|
@ -49,7 +49,6 @@ public:
|
||||||
|
|
||||||
// Static helpers.
|
// Static helpers.
|
||||||
static const std::string typeName (const Lexer::Type&);
|
static const std::string typeName (const Lexer::Type&);
|
||||||
static bool isHexDigit (int);
|
|
||||||
static bool isSingleCharOperator (int);
|
static bool isSingleCharOperator (int);
|
||||||
static bool isDoubleCharOperator (int, int, int);
|
static bool isDoubleCharOperator (int, int, int);
|
||||||
static bool isTripleCharOperator (int, int, int, int);
|
static bool isTripleCharOperator (int, int, int, int);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue