From 99ca6f8efbbfecafb6a6c11ffdbd0844f8b251e6 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 1 Nov 2021 15:12:46 +0100 Subject: [PATCH] Fix SimpleLexer not understanding floating point numbers that omit pre dot zero --- src/Parser/Parsing/Impl/AbstractLexer.h | 2 +- src/Parser/Parsing/Simple/SimpleLexer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser/Parsing/Impl/AbstractLexer.h b/src/Parser/Parsing/Impl/AbstractLexer.h index ee4b4617..27ab1298 100644 --- a/src/Parser/Parsing/Impl/AbstractLexer.h +++ b/src/Parser/Parsing/Impl/AbstractLexer.h @@ -263,7 +263,7 @@ protected: { const auto& currentLine = CurrentLine(); assert(m_current_line_offset >= 1); - assert(isdigit(currentLine.m_line[m_current_line_offset - 1])); + assert(isdigit(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 diff --git a/src/Parser/Parsing/Simple/SimpleLexer.cpp b/src/Parser/Parsing/Simple/SimpleLexer.cpp index c2bd229d..a63dd201 100644 --- a/src/Parser/Parsing/Simple/SimpleLexer.cpp +++ b/src/Parser/Parsing/Simple/SimpleLexer.cpp @@ -48,7 +48,7 @@ SimpleParserValue SimpleLexer::GetNextToken() if (m_config.m_read_strings && c == '\"') return SimpleParserValue::String(GetPreviousCharacterPos(), new std::string(ReadString())); - if (m_config.m_read_numbers && isdigit(c)) + if (m_config.m_read_numbers && (isdigit(c) || c == '.' && isdigit(PeekChar()))) { bool isFloatingPointValue; double doubleValue;