forked from lix-project/lix
Clean up toml parsing code
This commit is contained in:
parent
5d06836b9f
commit
9dea5768ef
|
@ -29,8 +29,6 @@ static void prim_fromTOML(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
for(auto & elem: table) {
|
for(auto & elem: table) {
|
||||||
|
|
||||||
auto & v2 = *state.allocAttr(v, state.symbols.create(elem.first));
|
auto & v2 = *state.allocAttr(v, state.symbols.create(elem.first));
|
||||||
|
|
||||||
// TODO: note about creating children here in old code
|
|
||||||
visit(v2, elem.second);
|
visit(v2, elem.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +59,7 @@ static void prim_fromTOML(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
case toml::value_t::offset_datetime:
|
case toml::value_t::offset_datetime:
|
||||||
case toml::value_t::local_date:
|
case toml::value_t::local_date:
|
||||||
case toml::value_t::local_time:
|
case toml::value_t::local_time:
|
||||||
// TODO: convert to string?
|
// We fail since Nix doesn't have date and time types
|
||||||
throw std::runtime_error("Dates and times are not supported");
|
throw std::runtime_error("Dates and times are not supported");
|
||||||
break;;
|
break;;
|
||||||
case toml::value_t::empty:
|
case toml::value_t::empty:
|
||||||
|
@ -72,7 +70,7 @@ static void prim_fromTOML(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
visit(val, toml::parse(tomlStream)); // TODO give filename
|
visit(val, toml::parse(tomlStream, "fromTOML" /* the "filename" */));
|
||||||
} catch (std::exception & e) { // TODO: toml::syntax_error
|
} catch (std::exception & e) { // TODO: toml::syntax_error
|
||||||
throw EvalError({
|
throw EvalError({
|
||||||
.msg = hintfmt("while parsing a TOML string: %s", e.what()),
|
.msg = hintfmt("while parsing a TOML string: %s", e.what()),
|
||||||
|
|
Loading…
Reference in a new issue