From 266fe67ab1ffbe190f64027ac5719391a05e21d7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 14 Jan 2016 22:17:14 -0500 Subject: [PATCH] Lexer: Migrated to unicodeHexDigit --- src/Lexer.cpp | 27 +++++++++------------------ src/Lexer.h | 1 - 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index d0914659..6d42fdac 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -84,15 +84,6 @@ const std::string Lexer::typeName (const Lexer::Type& type) 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 // \d+ @@ -381,7 +372,7 @@ bool Lexer::isHexNumber (std::string& token, Lexer::Type& type) { marker += 2; - while (isHexDigit (_text[marker])) + while (unicodeHexDigit (_text[marker])) ++marker; if (marker - _cursor > 2) @@ -648,10 +639,10 @@ bool Lexer::readWord ( else if (eos - cursor >= 6 && ((text[cursor + 0] == 'U' && text[cursor + 1] == '+') || (text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) && - isHexDigit (text[cursor + 2]) && - isHexDigit (text[cursor + 3]) && - isHexDigit (text[cursor + 4]) && - isHexDigit (text[cursor + 5])) + unicodeHexDigit (text[cursor + 2]) && + unicodeHexDigit (text[cursor + 3]) && + unicodeHexDigit (text[cursor + 4]) && + unicodeHexDigit (text[cursor + 5])) { word += utf8_character ( hexToInt ( @@ -732,10 +723,10 @@ bool Lexer::readWord ( else if (eos - cursor >= 6 && ((text[cursor + 0] == 'U' && text[cursor + 1] == '+') || (text[cursor + 0] == '\\' && text[cursor + 1] == 'u')) && - isHexDigit (text[cursor + 2]) && - isHexDigit (text[cursor + 3]) && - isHexDigit (text[cursor + 4]) && - isHexDigit (text[cursor + 5])) + unicodeHexDigit (text[cursor + 2]) && + unicodeHexDigit (text[cursor + 3]) && + unicodeHexDigit (text[cursor + 4]) && + unicodeHexDigit (text[cursor + 5])) { word += utf8_character ( hexToInt ( diff --git a/src/Lexer.h b/src/Lexer.h index 48e3cbdb..a14d79d2 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -49,7 +49,6 @@ public: // Static helpers. static const std::string typeName (const Lexer::Type&); - static bool isHexDigit (int); static bool isSingleCharOperator (int); static bool isDoubleCharOperator (int, int, int); static bool isTripleCharOperator (int, int, int, int);