improve lexing of numbers

This commit is contained in:
pantor
2021-11-17 12:13:22 +01:00
parent b41524f129
commit b2c0dddafe
3 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -197,7 +197,7 @@ class Lexer {
}
const char ch = m_in[pos];
// be very permissive in lexer (we'll catch errors when conversion happens)
if (!std::isdigit(ch) && ch != '.' && ch != 'e' && ch != 'E' && ch != '+' && ch != '-') {
if (!(std::isdigit(ch) || ch == '.' || ch == 'e' || ch == 'E' || (ch == '+' && (pos == 0 || m_in[pos-1] == 'e' || m_in[pos-1] == 'E')) || (ch == '-' && (pos == 0 || m_in[pos-1] == 'e' || m_in[pos-1] == 'E')))) {
break;
}
pos += 1;