From a07c64148eb60b886f92caa46a9c687240ec420c Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 20 Jul 2024 21:02:30 -0400 Subject: Add backslash identifier support to v2script Add buffer::char_type size multiplier to max file size of string intern buffer Fix list grammar segfaults Fix diagnostic logger intern segfaults from buffer reallocation Fix non-string-supported CSV parser not supporting Victoria 2 CSV escaping behavior --- src/openvic-dataloader/DiagnosticLogger.hpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/openvic-dataloader/DiagnosticLogger.hpp') diff --git a/src/openvic-dataloader/DiagnosticLogger.hpp b/src/openvic-dataloader/DiagnosticLogger.hpp index 9810e1e..8c491ca 100644 --- a/src/openvic-dataloader/DiagnosticLogger.hpp +++ b/src/openvic-dataloader/DiagnosticLogger.hpp @@ -2,6 +2,7 @@ #include // IWYU pragma: keep #include +#include #include #include #include @@ -37,12 +38,7 @@ namespace ovdl { template struct BasicDiagnosticLogger; - struct DiagnosticLogger { - struct SymbolId; - using index_type = std::uint32_t; - using symbol_type = dryad::symbol; - using symbol_interner_type = dryad::symbol_interner; - + struct DiagnosticLogger : error::ErrorSymbolInterner { using AnnotationKind = lexy_ext::annotation_kind; using DiagnosticKind = lexy_ext::diagnostic_kind; @@ -116,23 +112,23 @@ namespace ovdl { } result = writer.error(); } else { - auto production = _logger.intern_cstr(production_name); + auto production = production_name; if constexpr (std::is_same_v) { auto string = lexy::_detail::make_literal_lexeme(error.string(), error.length()); NodeLocation loc = NodeLocation::make_from(context.position(), error.position() - 1); - auto message = _logger.intern_cstr(fmt::format("expected '{}'", string.data())); + auto message = _logger.intern(fmt::format("expected '{}'", string.data())); result = _logger.template create(loc, message, production); } else if constexpr (std::is_same_v) { auto string = lexy::_detail::make_literal_lexeme(error.string(), error.length()); NodeLocation loc = NodeLocation::make_from(context.position(), error.position() - 1); - auto message = _logger.intern_cstr(fmt::format("expected keyword '{}'", string.data())); + auto message = _logger.intern(fmt::format("expected keyword '{}'", string.data())); result = _logger.template create(loc, message, production); } else if constexpr (std::is_same_v) { - auto message = _logger.intern_cstr(fmt::format("expected {}", error.name())); + auto message = _logger.intern(fmt::format("expected {}", error.name())); result = _logger.template create(error.position(), message, production); } else { NodeLocation loc = NodeLocation::make_from(error.begin(), error.end()); - auto message = _logger.intern_cstr(error.message()); + auto message = _logger.intern(error.message()); result = _logger.template create(loc, message, production); } } @@ -361,7 +357,7 @@ namespace ovdl { }); error::Annotation* annotation; - auto message = _logger.intern_cstr(output); + auto message = _logger.intern(output); switch (kind) { case AnnotationKind::primary: annotation = _logger.create(loc, message); @@ -404,7 +400,7 @@ namespace ovdl { }); impl.write_path(iter, file().path()); - auto message = intern_cstr(output); + auto message = intern(output); error->_set_message(message); if (!error->is_linked_in_tree()) insert(error); @@ -422,8 +418,8 @@ namespace ovdl { }); impl.write_path(iter, file().path()); - auto production = intern_cstr(production_name); - auto message = intern_cstr(output); + auto production = production_name; + auto message = intern(output); auto* error = [&] { if constexpr (std::is_same_v) { return create(loc, message, production); -- cgit v1.2.3-56-ga3b1