Don't include dot as special when doing float runs

This commit is contained in:
Thomas Krijnen
2026-03-27 21:04:48 +01:00
parent 603cedc487
commit 95b3f7dac4
+13 -7
View File
@@ -243,6 +243,7 @@ constexpr uint64_t quote = splat('"');
constexpr uint64_t dot = splat('.'); constexpr uint64_t dot = splat('.');
} // namespace chars } // namespace chars
template <bool IncludeDot = true>
inline uint64_t has_special_char(uint64_t x) { inline uint64_t has_special_char(uint64_t x) {
return eq_mask(x, chars::lpar) | return eq_mask(x, chars::lpar) |
eq_mask(x, chars::rpar) | eq_mask(x, chars::rpar) |
@@ -255,9 +256,10 @@ inline uint64_t has_special_char(uint64_t x) {
eq_mask(x, chars::lf) | eq_mask(x, chars::lf) |
eq_mask(x, chars::tab) | eq_mask(x, chars::tab) |
eq_mask(x, chars::quote) | eq_mask(x, chars::quote) |
eq_mask(x, chars::dot); (IncludeDot ? eq_mask(x, chars::dot) : uint64_t{0});
} }
template <bool IncludeDot = true>
inline uint32_t has_special_char(uint32_t x) { inline uint32_t has_special_char(uint32_t x) {
return eq_mask(x, static_cast<uint32_t>(chars::lpar)) | return eq_mask(x, static_cast<uint32_t>(chars::lpar)) |
eq_mask(x, static_cast<uint32_t>(chars::rpar)) | eq_mask(x, static_cast<uint32_t>(chars::rpar)) |
@@ -270,7 +272,7 @@ inline uint32_t has_special_char(uint32_t x) {
eq_mask(x, static_cast<uint32_t>(chars::lf)) | eq_mask(x, static_cast<uint32_t>(chars::lf)) |
eq_mask(x, static_cast<uint32_t>(chars::tab)) | eq_mask(x, static_cast<uint32_t>(chars::tab)) |
eq_mask(x, static_cast<uint32_t>(chars::quote)) | eq_mask(x, static_cast<uint32_t>(chars::quote)) |
eq_mask(x, static_cast<uint32_t>(chars::dot)); (IncludeDot ? eq_mask(x, static_cast<uint32_t>(chars::dot)) : uint32_t{0});
} }
} }
@@ -332,20 +334,23 @@ Token IfcSpfLexer<Reader>::Next() {
str.assign(&character, 1); str.assign(&character, 1);
} }
while (!stream->eof()) { auto remaining = stream->remaining();
if (stream->remaining() >= 8) { while (remaining) {
if (remaining >= 8) {
uint64_t x = stream->peek_u64(); uint64_t x = stream->peek_u64();
if (SWAR::has_special_char(x) == 0) { if ((ttype == Token::Token_NONE ? SWAR::has_special_char<false>(x) : SWAR::has_special_char<true>(x)) == 0) {
str.append(reinterpret_cast<const char*>(&x), 8); str.append(reinterpret_cast<const char*>(&x), 8);
stream->increment(8); stream->increment(8);
remaining -= 8;
continue; continue;
} }
} }
if (stream->remaining() >= 4) { if (remaining >= 4) {
uint32_t x = stream->peek_u32(); uint32_t x = stream->peek_u32();
if (SWAR::has_special_char(x) == 0) { if ((ttype == Token::Token_NONE ? SWAR::has_special_char<false>(x) : SWAR::has_special_char<true>(x)) == 0) {
str.append(reinterpret_cast<const char*>(&x), 4); str.append(reinterpret_cast<const char*>(&x), 4);
stream->increment(4); stream->increment(4);
remaining -= 4;
continue; continue;
} }
} }
@@ -369,6 +374,7 @@ Token IfcSpfLexer<Reader>::Next() {
} }
} }
stream->increment(); stream->increment();
remaining -= 1;
} }
if (ttype == Token::Token_ENUMERATION && str.size() == 1 && (str[0] == 'T' || str[0] == 'F' || str[0] == 'U')) { if (ttype == Token::Token_ENUMERATION && str.size() == 1 && (str[0] == 'T' || str[0] == 'F' || str[0] == 'U')) {