aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-10-13 14:42:22 +0200
committer GitHub <noreply@github.com>2023-10-13 14:42:22 +0200
commit4f9477642fa18bc8c0ed8c2062c882ff1010db95 (patch)
tree1509c021f8006cb9f49ba8989140067988301f26 /src
parentdc1d4ce5bbe134645a57d57d5e8c3cf41aa73dd6 (diff)
parentc7d497b1a51827916194de040800662376e2c26a (diff)
Merge pull request #26 from OpenVicProject/fix/empty-csv-lines
Diffstat (limited to 'src')
-rw-r--r--src/openvic-dataloader/csv/CsvGrammar.hpp6
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);
});
};