diff --git a/src/Parser/Parsing/Impl/AbstractLexer.h b/src/Parser/Parsing/Impl/AbstractLexer.h index 3f8911e7..dbf1b12b 100644 --- a/src/Parser/Parsing/Impl/AbstractLexer.h +++ b/src/Parser/Parsing/Impl/AbstractLexer.h @@ -289,6 +289,28 @@ protected: } } + void ReadNumber(bool& hasSignPrefix, int& integerValue) + { + const auto& currentLine = CurrentLine(); + assert(m_current_line_offset >= 1); + assert(isdigit(currentLine.m_line[m_current_line_offset - 1]) + || currentLine.m_line[m_current_line_offset - 1] == '+' + || currentLine.m_line[m_current_line_offset - 1] == '-'); + hasSignPrefix = currentLine.m_line[m_current_line_offset - 1] == '+' || currentLine.m_line[m_current_line_offset - 1] == '-'; + + const auto lineLength = currentLine.m_line.size(); + if (lineLength - m_current_line_offset >= 1 + && currentLine.m_line[m_current_line_offset - 1] == '0' + && currentLine.m_line[m_current_line_offset] == 'x') + { + ReadHexNumber(integerValue); + } + else + { + integerValue = ReadInteger(); + } + } + public: const TokenType& GetToken(unsigned index) override { diff --git a/src/Parser/Parsing/Simple/SimpleLexer.cpp b/src/Parser/Parsing/Simple/SimpleLexer.cpp index fc7db4d3..b5e0775b 100644 --- a/src/Parser/Parsing/Simple/SimpleLexer.cpp +++ b/src/Parser/Parsing/Simple/SimpleLexer.cpp @@ -125,12 +125,13 @@ SimpleParserValue SimpleLexer::GetNextToken() if (m_config.m_read_integer_numbers && (isdigit(c) || (c == '+' || c == '-' || (m_config.m_read_floating_point_numbers && c == '.')) && isdigit(PeekChar()))) { + bool hasSignPrefix; + int integerValue; + if(m_config.m_read_floating_point_numbers) { bool isFloatingPointValue; - bool hasSignPrefix; double floatingPointValue; - int integerValue; ReadNumber(isFloatingPointValue, hasSignPrefix, floatingPointValue, integerValue); @@ -140,7 +141,8 @@ SimpleParserValue SimpleLexer::GetNextToken() return SimpleParserValue::Integer(pos, integerValue, hasSignPrefix); } - return SimpleParserValue::Integer(pos, ReadInteger(), c == '+' || c == '-'); + ReadNumber(hasSignPrefix, integerValue); + return SimpleParserValue::Integer(pos, integerValue, hasSignPrefix); } if (isalpha(c) || c == '_')