Fix SimpleLexer not recognizing negative numbers

This commit is contained in:
Jan 2021-11-14 20:04:00 +01:00
parent 18aa914d70
commit ebb8eb9e5b
3 changed files with 5 additions and 3 deletions

View File

@ -263,7 +263,9 @@ protected:
{ {
const auto& currentLine = CurrentLine(); const auto& currentLine = CurrentLine();
assert(m_current_line_offset >= 1); assert(m_current_line_offset >= 1);
assert(isdigit(currentLine.m_line[m_current_line_offset - 1]) || 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] == '.'
|| currentLine.m_line[m_current_line_offset - 1] == '-');
const auto lineLength = currentLine.m_line.size(); const auto lineLength = currentLine.m_line.size();
if (lineLength - m_current_line_offset >= 1 if (lineLength - m_current_line_offset >= 1

View File

@ -30,7 +30,7 @@ protected:
virtual const std::vector<sequence_t*>& GetTestsForState() = 0; virtual const std::vector<sequence_t*>& GetTestsForState() = 0;
public: public:
virtual ~AbstractParser() override = default; ~AbstractParser() override = default;
AbstractParser(const AbstractParser& other) = default; AbstractParser(const AbstractParser& other) = default;
AbstractParser(AbstractParser&& other) noexcept = default; AbstractParser(AbstractParser&& other) noexcept = default;
AbstractParser& operator=(const AbstractParser& other) = default; AbstractParser& operator=(const AbstractParser& other) = default;

View File

@ -120,7 +120,7 @@ SimpleParserValue SimpleLexer::GetNextToken()
if (m_config.m_read_strings && c == '\"') if (m_config.m_read_strings && c == '\"')
return SimpleParserValue::String(pos, new std::string(ReadString())); return SimpleParserValue::String(pos, new std::string(ReadString()));
if (m_config.m_read_numbers && (isdigit(c) || c == '.' && isdigit(PeekChar()))) if (m_config.m_read_numbers && (isdigit(c) || (c == '-' || c == '.') && isdigit(PeekChar())))
{ {
bool isFloatingPointValue; bool isFloatingPointValue;
double doubleValue; double doubleValue;