diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-10-13 13:55:33 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-10-13 13:55:33 +0200 |
commit | c7d497b1a51827916194de040800662376e2c26a (patch) | |
tree | 1509c021f8006cb9f49ba8989140067988301f26 | |
parent | dc1d4ce5bbe134645a57d57d5e8c3cf41aa73dd6 (diff) |
Make values optional for CSV lines
-rw-r--r-- | src/openvic-dataloader/csv/CsvGrammar.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<ParseOptions Options> 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<LineEnd<Options>> | lexy::dsl::p<Seperator<Options>> >> lexy::dsl::p<LineEnd<Options>>; + static constexpr auto rule = lexy::dsl::p<LineEnd<Options>> | lexy::dsl::p<Seperator<Options>> >> lexy::dsl::opt(lexy::dsl::p<LineEnd<Options>>); static constexpr auto value = lexy::callback<ovdl::csv::LineObject>( [](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); }); }; |