From c7d497b1a51827916194de040800662376e2c26a Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Fri, 13 Oct 2023 07:55:33 -0400 Subject: Make values optional for CSV lines --- src/openvic-dataloader/csv/CsvGrammar.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/openvic-dataloader/csv/CsvGrammar.hpp b/src/openvic-dataloader/csv/CsvGrammar.hpp index 4c1c1ab..aef513b 100644 --- a/src/openvic-dataloader/csv/CsvGrammar.hpp +++ b/src/openvic-dataloader/csv/CsvGrammar.hpp @@ -132,7 +132,6 @@ namespace ovdl::csv::grammar { template struct Line { - static constexpr auto suffix_setter(ovdl::csv::LineObject& line) { auto& [position, value] = line.back(); if (value.empty()) { @@ -143,7 +142,7 @@ namespace ovdl::csv::grammar { } }; - static constexpr auto rule = lexy::dsl::p> | lexy::dsl::p> >> lexy::dsl::p>; + static constexpr auto rule = lexy::dsl::p> | lexy::dsl::p> >> lexy::dsl::opt(lexy::dsl::p>); static constexpr auto value = lexy::callback( [](ovdl::csv::LineObject&& line) { @@ -158,6 +157,9 @@ namespace ovdl::csv::grammar { } suffix_setter(line); return LEXY_MOV(line); + }, + [](std::size_t suffix_count, lexy::nullopt = {}) { + return ovdl::csv::LineObject(0, {}, suffix_count + 1); }); }; -- cgit v1.2.3-56-ga3b1