mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
fix: remove overlapping [error] sign
This commit is contained in:
20
toml/get.hpp
20
toml/get.hpp
@@ -186,7 +186,7 @@ get(const basic_value<C, M, V>& v)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw type_error(detail::format_underline("[error] toml::value "
|
throw type_error(detail::format_underline("toml::value: "
|
||||||
"bad_cast to std::chrono::system_clock::time_point", {
|
"bad_cast to std::chrono::system_clock::time_point", {
|
||||||
{std::addressof(detail::get_region(v)),
|
{std::addressof(detail::get_region(v)),
|
||||||
concat_to_string("the actual type is ", v.type())}
|
concat_to_string("the actual type is ", v.type())}
|
||||||
@@ -301,7 +301,7 @@ get(const basic_value<C, M, V>& v)
|
|||||||
if(ar.size() != container.size())
|
if(ar.size() != container.size())
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[erorr] toml::get specified container size is ", container.size(),
|
"toml::get: specified container size is ", container.size(),
|
||||||
" but there are ", ar.size(), " elements in toml array."), {
|
" but there are ", ar.size(), " elements in toml array."), {
|
||||||
{std::addressof(detail::get_region(v)), "here"}
|
{std::addressof(detail::get_region(v)), "here"}
|
||||||
}));
|
}));
|
||||||
@@ -326,7 +326,7 @@ get(const basic_value<C, M, V>& v)
|
|||||||
if(ar.size() != 2)
|
if(ar.size() != 2)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[erorr] toml::get specified std::pair but there are ", ar.size(),
|
"toml::get: specified std::pair but there are ", ar.size(),
|
||||||
" elements in toml array."), {
|
" elements in toml array."), {
|
||||||
{std::addressof(detail::get_region(v)), "here"}
|
{std::addressof(detail::get_region(v)), "here"}
|
||||||
}));
|
}));
|
||||||
@@ -357,7 +357,7 @@ get(const basic_value<C, M, V>& v)
|
|||||||
if(ar.size() != std::tuple_size<T>::value)
|
if(ar.size() != std::tuple_size<T>::value)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] toml::get specified std::tuple with ",
|
"toml::get: specified std::tuple with ",
|
||||||
std::tuple_size<T>::value, " elements, but there are ", ar.size(),
|
std::tuple_size<T>::value, " elements, but there are ", ar.size(),
|
||||||
" elements in toml array."), {
|
" elements in toml array."), {
|
||||||
{std::addressof(detail::get_region(v)), "here"}
|
{std::addressof(detail::get_region(v)), "here"}
|
||||||
@@ -430,7 +430,7 @@ basic_value<C, M, V> const& find(const basic_value<C, M, V>& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -444,7 +444,7 @@ basic_value<C, M, V>& find(basic_value<C, M, V>& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -458,7 +458,7 @@ basic_value<C, M, V> find(basic_value<C, M, V>&& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,7 @@ find(const basic_value<C, M, V>& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -493,7 +493,7 @@ find(basic_value<C, M, V>& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -509,7 +509,7 @@ find(basic_value<C, M, V>&& v, const key& ky)
|
|||||||
if(tab.count(ky) == 0)
|
if(tab.count(ky) == 0)
|
||||||
{
|
{
|
||||||
throw std::out_of_range(detail::format_underline(concat_to_string(
|
throw std::out_of_range(detail::format_underline(concat_to_string(
|
||||||
"[error] key \"", ky, "\" not found"), {
|
"key \"", ky, "\" not found"), {
|
||||||
{std::addressof(detail::get_region(v)), "in this table"}
|
{std::addressof(detail::get_region(v)), "in this table"}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
162
toml/parser.hpp
162
toml/parser.hpp
@@ -30,13 +30,13 @@ parse_boolean(location<Container>& loc)
|
|||||||
else // internal error.
|
else // internal error.
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline(
|
throw internal_error(format_underline(
|
||||||
"[error] toml::parse_boolean: internal error",
|
"toml::parse_boolean: internal error",
|
||||||
{{std::addressof(reg), "invalid token"}}),
|
{{std::addressof(reg), "invalid token"}}),
|
||||||
source_location(std::addressof(reg)));
|
source_location(std::addressof(reg)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loc.reset(first); //rollback
|
loc.reset(first); //rollback
|
||||||
return err(format_underline("[error] toml::parse_boolean: ",
|
return err(format_underline("toml::parse_boolean: ",
|
||||||
{{std::addressof(loc), "the next token is not a boolean"}}));
|
{{std::addressof(loc), "the next token is not a boolean"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ parse_binary_integer(location<Container>& loc)
|
|||||||
else // internal error.
|
else // internal error.
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline(
|
throw internal_error(format_underline(
|
||||||
"[error] toml::parse_integer: internal error",
|
"toml::parse_integer: internal error",
|
||||||
{{std::addressof(token.unwrap()), "invalid token"}}),
|
{{std::addressof(token.unwrap()), "invalid token"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ parse_binary_integer(location<Container>& loc)
|
|||||||
return ok(std::make_pair(retval, token.unwrap()));
|
return ok(std::make_pair(retval, token.unwrap()));
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_binary_integer:",
|
return err(format_underline("toml::parse_binary_integer:",
|
||||||
{{std::addressof(loc), "the next token is not an integer"}}));
|
{{std::addressof(loc), "the next token is not an integer"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ parse_octal_integer(location<Container>& loc)
|
|||||||
return ok(std::make_pair(retval, token.unwrap()));
|
return ok(std::make_pair(retval, token.unwrap()));
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_octal_integer:",
|
return err(format_underline("toml::parse_octal_integer:",
|
||||||
{{std::addressof(loc), "the next token is not an integer"}}));
|
{{std::addressof(loc), "the next token is not an integer"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ parse_hexadecimal_integer(location<Container>& loc)
|
|||||||
return ok(std::make_pair(retval, token.unwrap()));
|
return ok(std::make_pair(retval, token.unwrap()));
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_hexadecimal_integer",
|
return err(format_underline("toml::parse_hexadecimal_integer",
|
||||||
{{std::addressof(loc), "the next token is not an integer"}}));
|
{{std::addressof(loc), "the next token is not an integer"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,13 +131,13 @@ parse_integer(location<Container>& loc)
|
|||||||
|
|
||||||
if(std::isdigit(*second))
|
if(std::isdigit(*second))
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_integer: "
|
return err(format_underline("toml::parse_integer: "
|
||||||
"leading zero in an Integer is not allowed.",
|
"leading zero in an Integer is not allowed.",
|
||||||
{{std::addressof(loc), "leading zero"}}));
|
{{std::addressof(loc), "leading zero"}}));
|
||||||
}
|
}
|
||||||
else if(std::isalpha(*second))
|
else if(std::isalpha(*second))
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_integer: "
|
return err(format_underline("toml::parse_integer: "
|
||||||
"unknown integer prefix appeared.",
|
"unknown integer prefix appeared.",
|
||||||
{{std::addressof(loc), "none of 0x, 0o, 0b"}}));
|
{{std::addressof(loc), "none of 0x, 0o, 0b"}}));
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ parse_integer(location<Container>& loc)
|
|||||||
return ok(std::make_pair(retval, token.unwrap()));
|
return ok(std::make_pair(retval, token.unwrap()));
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_integer: ",
|
return err(format_underline("toml::parse_integer: ",
|
||||||
{{std::addressof(loc), "the next token is not an integer"}}));
|
{{std::addressof(loc), "the next token is not an integer"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ parse_floating(location<Container>& loc)
|
|||||||
return ok(std::make_pair(v, token.unwrap()));
|
return ok(std::make_pair(v, token.unwrap()));
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_floating: ",
|
return err(format_underline("toml::parse_floating: ",
|
||||||
{{std::addressof(loc), "the next token is not a float"}}));
|
{{std::addressof(loc), "the next token is not a float"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ std::string read_utf8_codepoint(const region<Container>& reg,
|
|||||||
{
|
{
|
||||||
if(0xD800 <= codepoint && codepoint <= 0xDFFF)
|
if(0xD800 <= codepoint && codepoint <= 0xDFFF)
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] "
|
throw syntax_error(format_underline(
|
||||||
"toml::read_utf8_codepoint: codepoints in the range "
|
"toml::read_utf8_codepoint: codepoints in the range "
|
||||||
"[0xD800, 0xDFFF] are not valid UTF-8.", {{
|
"[0xD800, 0xDFFF] are not valid UTF-8.", {{
|
||||||
std::addressof(loc), "not a valid UTF-8 codepoint"
|
std::addressof(loc), "not a valid UTF-8 codepoint"
|
||||||
@@ -298,7 +298,7 @@ std::string read_utf8_codepoint(const region<Container>& reg,
|
|||||||
}
|
}
|
||||||
else // out of UTF-8 region
|
else // out of UTF-8 region
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] toml::read_utf8_codepoint:"
|
throw syntax_error(format_underline("toml::read_utf8_codepoint:"
|
||||||
" input codepoint is too large.",
|
" input codepoint is too large.",
|
||||||
{{std::addressof(loc), "should be in [0x00..0x10FFFF]"}}),
|
{{std::addressof(loc), "should be in [0x00..0x10FFFF]"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -333,7 +333,7 @@ result<std::string, std::string> parse_escape_sequence(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] parse_escape_sequence: "
|
return err(format_underline("parse_escape_sequence: "
|
||||||
"invalid token found in UTF-8 codepoint uXXXX.",
|
"invalid token found in UTF-8 codepoint uXXXX.",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
@@ -346,14 +346,14 @@ result<std::string, std::string> parse_escape_sequence(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] parse_escape_sequence: "
|
return err(format_underline("parse_escape_sequence: "
|
||||||
"invalid token found in UTF-8 codepoint Uxxxxxxxx",
|
"invalid token found in UTF-8 codepoint Uxxxxxxxx",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto msg = format_underline("[error] parse_escape_sequence: "
|
const auto msg = format_underline("parse_escape_sequence: "
|
||||||
"unknown escape sequence appeared.", {{std::addressof(loc),
|
"unknown escape sequence appeared.", {{std::addressof(loc),
|
||||||
"escape sequence is one of \\, \", b, t, n, f, r, uxxxx, Uxxxxxxxx"}},
|
"escape sequence is one of \\, \", b, t, n, f, r, uxxxx, Uxxxxxxxx"}},
|
||||||
/* Hints = */{"if you want to write backslash as just one backslash, "
|
/* Hints = */{"if you want to write backslash as just one backslash, "
|
||||||
@@ -378,7 +378,7 @@ parse_ml_basic_string(location<Container>& loc)
|
|||||||
auto delim = lex_ml_basic_string_delim::invoke(inner_loc);
|
auto delim = lex_ml_basic_string_delim::invoke(inner_loc);
|
||||||
if(!delim)
|
if(!delim)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_ml_basic_string: invalid token",
|
"parse_ml_basic_string: invalid token",
|
||||||
{{std::addressof(inner_loc), "should be \"\"\""}}),
|
{{std::addressof(inner_loc), "should be \"\"\""}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -405,7 +405,7 @@ parse_ml_basic_string(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
if(inner_loc.iter() == inner_loc.end())
|
if(inner_loc.iter() == inner_loc.end())
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_ml_basic_string: unexpected end of region",
|
"parse_ml_basic_string: unexpected end of region",
|
||||||
{{std::addressof(inner_loc), "not sufficient token"}}),
|
{{std::addressof(inner_loc), "not sufficient token"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -417,7 +417,7 @@ parse_ml_basic_string(location<Container>& loc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(format_underline("[error] toml::parse_ml_basic_string: "
|
return err(format_underline("toml::parse_ml_basic_string: "
|
||||||
"the next token is not a valid multiline string",
|
"the next token is not a valid multiline string",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
@@ -436,7 +436,7 @@ parse_basic_string(location<Container>& loc)
|
|||||||
auto quot = lex_quotation_mark::invoke(inner_loc);
|
auto quot = lex_quotation_mark::invoke(inner_loc);
|
||||||
if(!quot)
|
if(!quot)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] parse_basic_string: "
|
throw internal_error(format_underline("parse_basic_string: "
|
||||||
"invalid token", {{std::addressof(inner_loc), "should be \""}}),
|
"invalid token", {{std::addressof(inner_loc), "should be \""}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
}
|
}
|
||||||
@@ -458,7 +458,7 @@ parse_basic_string(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
if(inner_loc.iter() == inner_loc.end())
|
if(inner_loc.iter() == inner_loc.end())
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_basic_string: unexpected end of region",
|
"parse_basic_string: unexpected end of region",
|
||||||
{{std::addressof(inner_loc), "not sufficient token"}}),
|
{{std::addressof(inner_loc), "not sufficient token"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -470,7 +470,7 @@ parse_basic_string(location<Container>& loc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loc.reset(first); // rollback
|
loc.reset(first); // rollback
|
||||||
return err(format_underline("[error] toml::parse_basic_string: "
|
return err(format_underline("toml::parse_basic_string: "
|
||||||
"the next token is not a valid string",
|
"the next token is not a valid string",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ parse_ml_literal_string(location<Container>& loc)
|
|||||||
const auto open = lex_ml_literal_string_delim::invoke(inner_loc);
|
const auto open = lex_ml_literal_string_delim::invoke(inner_loc);
|
||||||
if(!open)
|
if(!open)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_ml_literal_string: invalid token",
|
"parse_ml_literal_string: invalid token",
|
||||||
{{std::addressof(inner_loc), "should be '''"}}),
|
{{std::addressof(inner_loc), "should be '''"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -501,7 +501,7 @@ parse_ml_literal_string(location<Container>& loc)
|
|||||||
const auto close = lex_ml_literal_string_delim::invoke(inner_loc);
|
const auto close = lex_ml_literal_string_delim::invoke(inner_loc);
|
||||||
if(!close)
|
if(!close)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_ml_literal_string: invalid token",
|
"parse_ml_literal_string: invalid token",
|
||||||
{{std::addressof(inner_loc), "should be '''"}}),
|
{{std::addressof(inner_loc), "should be '''"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -513,7 +513,7 @@ parse_ml_literal_string(location<Container>& loc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loc.reset(first); // rollback
|
loc.reset(first); // rollback
|
||||||
return err(format_underline("[error] toml::parse_ml_literal_string: "
|
return err(format_underline("toml::parse_ml_literal_string: "
|
||||||
"the next token is not a valid multiline literal string",
|
"the next token is not a valid multiline literal string",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
@@ -531,7 +531,7 @@ parse_literal_string(location<Container>& loc)
|
|||||||
const auto open = lex_apostrophe::invoke(inner_loc);
|
const auto open = lex_apostrophe::invoke(inner_loc);
|
||||||
if(!open)
|
if(!open)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_literal_string: invalid token",
|
"parse_literal_string: invalid token",
|
||||||
{{std::addressof(inner_loc), "should be '"}}),
|
{{std::addressof(inner_loc), "should be '"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -542,7 +542,7 @@ parse_literal_string(location<Container>& loc)
|
|||||||
const auto close = lex_apostrophe::invoke(inner_loc);
|
const auto close = lex_apostrophe::invoke(inner_loc);
|
||||||
if(!close)
|
if(!close)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"parse_literal_string: invalid token",
|
"parse_literal_string: invalid token",
|
||||||
{{std::addressof(inner_loc), "should be '"}}),
|
{{std::addressof(inner_loc), "should be '"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -554,7 +554,7 @@ parse_literal_string(location<Container>& loc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
loc.reset(first); // rollback
|
loc.reset(first); // rollback
|
||||||
return err(format_underline("[error] toml::parse_literal_string: "
|
return err(format_underline("toml::parse_literal_string: "
|
||||||
"the next token is not a valid literal string",
|
"the next token is not a valid literal string",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
@@ -588,7 +588,7 @@ parse_string(location<Container>& loc)
|
|||||||
return parse_literal_string(loc);
|
return parse_literal_string(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err(format_underline("[error] toml::parse_string: ",
|
return err(format_underline("toml::parse_string: ",
|
||||||
{{std::addressof(loc), "the next token is not a string"}}));
|
{{std::addressof(loc), "the next token is not a string"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,7 +836,7 @@ parse_simple_key(location<Container>& loc)
|
|||||||
const auto reg = bare.unwrap();
|
const auto reg = bare.unwrap();
|
||||||
return ok(std::make_pair(reg.str(), reg));
|
return ok(std::make_pair(reg.str(), reg));
|
||||||
}
|
}
|
||||||
return err(format_underline("[error] toml::parse_simple_key: ",
|
return err(format_underline("toml::parse_simple_key: ",
|
||||||
{{std::addressof(loc), "the next token is not a simple key"}}));
|
{{std::addressof(loc), "the next token is not a simple key"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,7 +862,7 @@ parse_key(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::detail::parse_key: dotted key contains invalid key",
|
"toml::detail::parse_key: dotted key contains invalid key",
|
||||||
{{std::addressof(inner_loc), k.unwrap_err()}}),
|
{{std::addressof(inner_loc), k.unwrap_err()}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -879,7 +879,7 @@ parse_key(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] toml::parse_key: "
|
throw internal_error(format_underline("toml::parse_key: "
|
||||||
"dotted key contains invalid key ",
|
"dotted key contains invalid key ",
|
||||||
{{std::addressof(inner_loc), "should be `.`"}}),
|
{{std::addressof(inner_loc), "should be `.`"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -895,7 +895,7 @@ parse_key(location<Container>& loc)
|
|||||||
return ok(std::make_pair(std::vector<key>(1, smpl.unwrap().first),
|
return ok(std::make_pair(std::vector<key>(1, smpl.unwrap().first),
|
||||||
smpl.unwrap().second));
|
smpl.unwrap().second));
|
||||||
}
|
}
|
||||||
return err(format_underline("[error] toml::parse_key: ",
|
return err(format_underline("toml::parse_key: ",
|
||||||
{{std::addressof(loc), "is not a valid key"}}));
|
{{std::addressof(loc), "is not a valid key"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,11 +913,11 @@ parse_array(location<Container>& loc)
|
|||||||
const auto first = loc.iter();
|
const auto first = loc.iter();
|
||||||
if(loc.iter() == loc.end())
|
if(loc.iter() == loc.end())
|
||||||
{
|
{
|
||||||
return err("[error] toml::parse_array: input is empty");
|
return err("toml::parse_array: input is empty");
|
||||||
}
|
}
|
||||||
if(*loc.iter() != '[')
|
if(*loc.iter() != '[')
|
||||||
{
|
{
|
||||||
return err("[error] toml::parse_array: token is not an array");
|
return err("toml::parse_array: token is not an array");
|
||||||
}
|
}
|
||||||
loc.advance();
|
loc.advance();
|
||||||
|
|
||||||
@@ -944,7 +944,7 @@ parse_array(location<Container>& loc)
|
|||||||
auto array_start_loc = loc;
|
auto array_start_loc = loc;
|
||||||
array_start_loc.reset(first);
|
array_start_loc.reset(first);
|
||||||
|
|
||||||
throw syntax_error(format_underline("[error] toml::parse_array: "
|
throw syntax_error(format_underline("toml::parse_array: "
|
||||||
"type of elements should be the same each other.", {
|
"type of elements should be the same each other.", {
|
||||||
{std::addressof(array_start_loc), "array starts here"},
|
{std::addressof(array_start_loc), "array starts here"},
|
||||||
{
|
{
|
||||||
@@ -965,7 +965,7 @@ parse_array(location<Container>& loc)
|
|||||||
auto array_start_loc = loc;
|
auto array_start_loc = loc;
|
||||||
array_start_loc.reset(first);
|
array_start_loc.reset(first);
|
||||||
|
|
||||||
throw syntax_error(format_underline("[error] toml::parse_array: "
|
throw syntax_error(format_underline("toml::parse_array: "
|
||||||
"value having invalid format appeared in an array", {
|
"value having invalid format appeared in an array", {
|
||||||
{std::addressof(array_start_loc), "array starts here"},
|
{std::addressof(array_start_loc), "array starts here"},
|
||||||
{std::addressof(loc), "it is not a valid value."}
|
{std::addressof(loc), "it is not a valid value."}
|
||||||
@@ -988,7 +988,7 @@ parse_array(location<Container>& loc)
|
|||||||
auto array_start_loc = loc;
|
auto array_start_loc = loc;
|
||||||
array_start_loc.reset(first);
|
array_start_loc.reset(first);
|
||||||
|
|
||||||
throw syntax_error(format_underline("[error] toml::parse_array:"
|
throw syntax_error(format_underline("toml::parse_array:"
|
||||||
" missing array separator `,` after a value", {
|
" missing array separator `,` after a value", {
|
||||||
{std::addressof(array_start_loc), "array starts here"},
|
{std::addressof(array_start_loc), "array starts here"},
|
||||||
{std::addressof(loc), "should be `,`"}
|
{std::addressof(loc), "should be `,`"}
|
||||||
@@ -997,7 +997,7 @@ parse_array(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
throw syntax_error(format_underline("[error] toml::parse_array: "
|
throw syntax_error(format_underline("toml::parse_array: "
|
||||||
"array did not closed by `]`",
|
"array did not closed by `]`",
|
||||||
{{std::addressof(loc), "should be closed"}}),
|
{{std::addressof(loc), "should be closed"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -1019,7 +1019,7 @@ parse_key_value_pair(location<Container>& loc)
|
|||||||
if(const auto keyval_sep = lex_keyval_sep::invoke(loc))
|
if(const auto keyval_sep = lex_keyval_sep::invoke(loc))
|
||||||
{
|
{
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
msg = format_underline("[error] toml::parse_key_value_pair: "
|
msg = format_underline("toml::parse_key_value_pair: "
|
||||||
"empty key is not allowed.",
|
"empty key is not allowed.",
|
||||||
{{std::addressof(loc), "key expected before '='"}});
|
{{std::addressof(loc), "key expected before '='"}});
|
||||||
}
|
}
|
||||||
@@ -1035,7 +1035,7 @@ parse_key_value_pair(location<Container>& loc)
|
|||||||
const auto line_end = std::find(loc.iter(), loc.end(), '\n');
|
const auto line_end = std::find(loc.iter(), loc.end(), '\n');
|
||||||
if(std::find(loc.iter(), line_end, '=') != line_end)
|
if(std::find(loc.iter(), line_end, '=') != line_end)
|
||||||
{
|
{
|
||||||
msg = format_underline("[error] toml::parse_key_value_pair: "
|
msg = format_underline("toml::parse_key_value_pair: "
|
||||||
"invalid format for key",
|
"invalid format for key",
|
||||||
{{std::addressof(loc), "invalid character in key"}},
|
{{std::addressof(loc), "invalid character in key"}},
|
||||||
{"Did you forget '.' to separate dotted-key?",
|
{"Did you forget '.' to separate dotted-key?",
|
||||||
@@ -1043,7 +1043,7 @@ parse_key_value_pair(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else // if not, the error is lack of key-value separator.
|
else // if not, the error is lack of key-value separator.
|
||||||
{
|
{
|
||||||
msg = format_underline("[error] toml::parse_key_value_pair: "
|
msg = format_underline("toml::parse_key_value_pair: "
|
||||||
"missing key-value separator `=`",
|
"missing key-value separator `=`",
|
||||||
{{std::addressof(loc), "should be `=`"}});
|
{{std::addressof(loc), "should be `=`"}});
|
||||||
}
|
}
|
||||||
@@ -1061,7 +1061,7 @@ parse_key_value_pair(location<Container>& loc)
|
|||||||
if(sequence<maybe<lex_ws>, maybe<lex_comment>, lex_newline>::invoke(loc))
|
if(sequence<maybe<lex_ws>, maybe<lex_comment>, lex_newline>::invoke(loc))
|
||||||
{
|
{
|
||||||
loc.reset(after_kvsp);
|
loc.reset(after_kvsp);
|
||||||
msg = format_underline("[error] toml::parse_key_value_pair: "
|
msg = format_underline("toml::parse_key_value_pair: "
|
||||||
"missing value after key-value separator '='",
|
"missing value after key-value separator '='",
|
||||||
{{std::addressof(loc), "expected value, but got nothing"}});
|
{{std::addressof(loc), "expected value, but got nothing"}});
|
||||||
}
|
}
|
||||||
@@ -1196,7 +1196,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
{
|
{
|
||||||
// show special err msg for conflicting table
|
// show special err msg for conflicting table
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: array of table (\"",
|
"toml::insert_value: array of table (\"",
|
||||||
format_dotted_keys(first, last),
|
format_dotted_keys(first, last),
|
||||||
"\") cannot be defined"), {
|
"\") cannot be defined"), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1208,7 +1208,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
else if(!(tab->at(k).is_array()))
|
else if(!(tab->at(k).is_array()))
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: array of table (\"",
|
"toml::insert_value: array of table (\"",
|
||||||
format_dotted_keys(first, last), "\") collides with"
|
format_dotted_keys(first, last), "\") collides with"
|
||||||
" existing value"), {
|
" existing value"), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1223,7 +1223,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
if(!(a.front().is_table()))
|
if(!(a.front().is_table()))
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: array of table (\"",
|
"toml::insert_value: array of table (\"",
|
||||||
format_dotted_keys(first, last), "\") collides with"
|
format_dotted_keys(first, last), "\") collides with"
|
||||||
" existing value"), {
|
" existing value"), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1251,7 +1251,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
if(detail::get_region(a.front()).str().substr(0,2) != "[[")
|
if(detail::get_region(a.front()).str().substr(0,2) != "[[")
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: array of table (\"",
|
"toml::insert_value: array of table (\"",
|
||||||
format_dotted_keys(first, last), "\") collides with"
|
format_dotted_keys(first, last), "\") collides with"
|
||||||
" existing array-of-tables"), {
|
" existing array-of-tables"), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1280,7 +1280,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
tab->at(k), first, iter, last))
|
tab->at(k), first, iter, last))
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: table (\"",
|
"toml::insert_value: table (\"",
|
||||||
format_dotted_keys(first, last),
|
format_dotted_keys(first, last),
|
||||||
"\") already exists."), {
|
"\") already exists."), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1308,7 +1308,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
tab->at(k).as_array().front().is_table())
|
tab->at(k).as_array().front().is_table())
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: array of tables (\"",
|
"toml::insert_value: array of tables (\"",
|
||||||
format_dotted_keys(first, last), "\") already exists."), {
|
format_dotted_keys(first, last), "\") already exists."), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
"array of tables defined here"},
|
"array of tables defined here"},
|
||||||
@@ -1319,7 +1319,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: value (\"",
|
"toml::insert_value: value (\"",
|
||||||
format_dotted_keys(first, last), "\") already exists."), {
|
format_dotted_keys(first, last), "\") already exists."), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
"value already exists here"},
|
"value already exists here"},
|
||||||
@@ -1355,7 +1355,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
if(!a.back().is_table())
|
if(!a.back().is_table())
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: target (",
|
"toml::insert_value: target (",
|
||||||
format_dotted_keys(first, std::next(iter)),
|
format_dotted_keys(first, std::next(iter)),
|
||||||
") is neither table nor an array of tables"), {
|
") is neither table nor an array of tables"), {
|
||||||
{std::addressof(get_region(a.back())),
|
{std::addressof(get_region(a.back())),
|
||||||
@@ -1368,7 +1368,7 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline(concat_to_string(
|
throw syntax_error(format_underline(concat_to_string(
|
||||||
"[error] toml::insert_value: target (",
|
"toml::insert_value: target (",
|
||||||
format_dotted_keys(first, std::next(iter)),
|
format_dotted_keys(first, std::next(iter)),
|
||||||
") is neither table nor an array of tables"), {
|
") is neither table nor an array of tables"), {
|
||||||
{std::addressof(get_region(tab->at(k))),
|
{std::addressof(get_region(tab->at(k))),
|
||||||
@@ -1392,7 +1392,7 @@ parse_inline_table(location<Container>& loc)
|
|||||||
table_type retval;
|
table_type retval;
|
||||||
if(!(loc.iter() != loc.end() && *loc.iter() == '{'))
|
if(!(loc.iter() != loc.end() && *loc.iter() == '{'))
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_inline_table: ",
|
return err(format_underline("toml::parse_inline_table: ",
|
||||||
{{std::addressof(loc), "the next token is not an inline table"}}));
|
{{std::addressof(loc), "the next token is not an inline table"}}));
|
||||||
}
|
}
|
||||||
loc.advance();
|
loc.advance();
|
||||||
@@ -1421,7 +1421,7 @@ parse_inline_table(location<Container>& loc)
|
|||||||
insert_nested_key(retval, val, keys.begin(), keys.end(), key_reg);
|
insert_nested_key(retval, val, keys.begin(), keys.end(), key_reg);
|
||||||
if(!inserted)
|
if(!inserted)
|
||||||
{
|
{
|
||||||
throw internal_error("[error] toml::parse_inline_table: "
|
throw internal_error("toml::parse_inline_table: "
|
||||||
"failed to insert value into table: " + inserted.unwrap_err(),
|
"failed to insert value into table: " + inserted.unwrap_err(),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
}
|
}
|
||||||
@@ -1439,14 +1439,14 @@ parse_inline_table(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else if(*loc.iter() == '#' || *loc.iter() == '\r' || *loc.iter() == '\n')
|
else if(*loc.iter() == '#' || *loc.iter() == '\r' || *loc.iter() == '\n')
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] "
|
throw syntax_error(format_underline(
|
||||||
"toml::parse_inline_table: missing curly brace `}`",
|
"toml::parse_inline_table: missing curly brace `}`",
|
||||||
{{std::addressof(loc), "should be `}`"}}),
|
{{std::addressof(loc), "should be `}`"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] "
|
throw syntax_error(format_underline(
|
||||||
"toml::parse_inline_table: missing table separator `,` ",
|
"toml::parse_inline_table: missing table separator `,` ",
|
||||||
{{std::addressof(loc), "should be `,`"}}),
|
{{std::addressof(loc), "should be `,`"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -1454,7 +1454,7 @@ parse_inline_table(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
throw syntax_error(format_underline("[error] toml::parse_inline_table: "
|
throw syntax_error(format_underline("toml::parse_inline_table: "
|
||||||
"inline table did not closed by `}`",
|
"inline table did not closed by `}`",
|
||||||
{{std::addressof(loc), "should be closed"}}),
|
{{std::addressof(loc), "should be closed"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -1480,7 +1480,7 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
if(loc.iter() != loc.end() && (*loc.iter() == '+' || *loc.iter() == '-'
|
if(loc.iter() != loc.end() && (*loc.iter() == '+' || *loc.iter() == '-'
|
||||||
|| *loc.iter() == 'Z' || *loc.iter() == 'z'))
|
|| *loc.iter() == 'Z' || *loc.iter() == 'z'))
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad offset: should be [+-]HH:MM or Z",
|
return err(format_underline("bad offset: should be [+-]HH:MM or Z",
|
||||||
{{std::addressof(loc), "[+-]HH:MM or Z"}},
|
{{std::addressof(loc), "[+-]HH:MM or Z"}},
|
||||||
{"pass: +09:00, -05:30", "fail: +9:00, -5:30"}));
|
{"pass: +09:00, -05:30", "fail: +9:00, -5:30"}));
|
||||||
}
|
}
|
||||||
@@ -1500,14 +1500,14 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
const auto c = *loc.iter();
|
const auto c = *loc.iter();
|
||||||
if(c == 'T' || c == 't')
|
if(c == 'T' || c == 't')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad time: should be HH:MM:SS.subsec",
|
return err(format_underline("bad time: should be HH:MM:SS.subsec",
|
||||||
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
||||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||||
"fail: 1979-05-27T7:32:00, 1979-05-27 17:32"}));
|
"fail: 1979-05-27T7:32:00, 1979-05-27 17:32"}));
|
||||||
}
|
}
|
||||||
if('0' <= c && c <= '9')
|
if('0' <= c && c <= '9')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad time: missing T",
|
return err(format_underline("bad time: missing T",
|
||||||
{{std::addressof(loc), "T or space required here"}},
|
{{std::addressof(loc), "T or space required here"}},
|
||||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||||
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||||
@@ -1516,7 +1516,7 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
('0' <= *std::next(loc.iter()) && *std::next(loc.iter())<= '9'))
|
('0' <= *std::next(loc.iter()) && *std::next(loc.iter())<= '9'))
|
||||||
{
|
{
|
||||||
loc.advance();
|
loc.advance();
|
||||||
return err(format_underline("[error] bad time: should be HH:MM:SS.subsec",
|
return err(format_underline("bad time: should be HH:MM:SS.subsec",
|
||||||
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
{{std::addressof(loc), "HH:MM:SS.subsec"}},
|
||||||
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
{"pass: 1979-05-27T07:32:00, 1979-05-27 07:32:00.999999",
|
||||||
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
"fail: 1979-05-27T7:32:00, 1979-05-27 7:32"}));
|
||||||
@@ -1533,7 +1533,7 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
{
|
{
|
||||||
if(loc.iter() != loc.end() && *loc.iter() == '_')
|
if(loc.iter() != loc.end() && *loc.iter() == '_')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad float: `_` should be surrounded by digits",
|
return err(format_underline("bad float: `_` should be surrounded by digits",
|
||||||
{{std::addressof(loc), "here"}},
|
{{std::addressof(loc), "here"}},
|
||||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||||
@@ -1549,7 +1549,7 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
const auto c = *loc.iter();
|
const auto c = *loc.iter();
|
||||||
if(c == '_')
|
if(c == '_')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad integer: `_` should be surrounded by digits",
|
return err(format_underline("bad integer: `_` should be surrounded by digits",
|
||||||
{{std::addressof(loc), "here"}},
|
{{std::addressof(loc), "here"}},
|
||||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||||
"fail: 1__000, 0123"}));
|
"fail: 1__000, 0123"}));
|
||||||
@@ -1558,21 +1558,21 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
{
|
{
|
||||||
// leading zero. point '0'
|
// leading zero. point '0'
|
||||||
loc.retrace();
|
loc.retrace();
|
||||||
return err(format_underline("[error] bad integer: leading zero",
|
return err(format_underline("bad integer: leading zero",
|
||||||
{{std::addressof(loc), "here"}},
|
{{std::addressof(loc), "here"}},
|
||||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||||
"fail: 1__000, 0123"}));
|
"fail: 1__000, 0123"}));
|
||||||
}
|
}
|
||||||
if(c == ':' || c == '-')
|
if(c == ':' || c == '-')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad datetime: invalid format",
|
return err(format_underline("bad datetime: invalid format",
|
||||||
{{std::addressof(loc), "here"}},
|
{{std::addressof(loc), "here"}},
|
||||||
{"pass: 1979-05-27T07:32:00-07:00, 1979-05-27 07:32:00.999999Z",
|
{"pass: 1979-05-27T07:32:00-07:00, 1979-05-27 07:32:00.999999Z",
|
||||||
"fail: 1979-05-27T7:32:00-7:00, 1979-05-27 7:32-00:30"}));
|
"fail: 1979-05-27T7:32:00-7:00, 1979-05-27 7:32-00:30"}));
|
||||||
}
|
}
|
||||||
if(c == '.' || c == 'e' || c == 'E')
|
if(c == '.' || c == 'e' || c == 'E')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad float: invalid format",
|
return err(format_underline("bad float: invalid format",
|
||||||
{{std::addressof(loc), "here"}},
|
{{std::addressof(loc), "here"}},
|
||||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||||
@@ -1582,19 +1582,19 @@ result<value_t, std::string> guess_number_type(const location<Container>& l)
|
|||||||
}
|
}
|
||||||
if(loc.iter() != loc.end() && *loc.iter() == '.')
|
if(loc.iter() != loc.end() && *loc.iter() == '.')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad float: invalid format",
|
return err(format_underline("bad float: invalid format",
|
||||||
{{std::addressof(loc), "integer part required before this"}},
|
{{std::addressof(loc), "integer part required before this"}},
|
||||||
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
{"pass: +1.0, -2e-2, 3.141_592_653_589, inf, nan",
|
||||||
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
"fail: .0, 1., _1.0, 1.0_, 1_.0, 1.0__0"}));
|
||||||
}
|
}
|
||||||
if(loc.iter() != loc.end() && *loc.iter() == '_')
|
if(loc.iter() != loc.end() && *loc.iter() == '_')
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] bad number: `_` should be surrounded by digits",
|
return err(format_underline("bad number: `_` should be surrounded by digits",
|
||||||
{{std::addressof(loc), "`_` is not surrounded by digits"}},
|
{{std::addressof(loc), "`_` is not surrounded by digits"}},
|
||||||
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
{"pass: -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755",
|
||||||
"fail: 1__000, 0123"}));
|
"fail: 1__000, 0123"}));
|
||||||
}
|
}
|
||||||
return err(format_underline("[error] bad format: unknown value appeared",
|
return err(format_underline("bad format: unknown value appeared",
|
||||||
{{std::addressof(loc), "here"}}));
|
{{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1623,7 +1623,7 @@ result<Value, std::string> parse_value(location<Container>& loc)
|
|||||||
const auto first = loc.iter();
|
const auto first = loc.iter();
|
||||||
if(first == loc.end())
|
if(first == loc.end())
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_value: input is empty",
|
return err(format_underline("toml::parse_value: input is empty",
|
||||||
{{std::addressof(loc), ""}}));
|
{{std::addressof(loc), ""}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1646,7 +1646,7 @@ result<Value, std::string> parse_value(location<Container>& loc)
|
|||||||
case value_t::table : {return parse_inline_table<value_type>(loc);}
|
case value_t::table : {return parse_inline_table<value_type>(loc);}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
const auto msg = format_underline("[error] toml::parse_value: "
|
const auto msg = format_underline("toml::parse_value: "
|
||||||
"unknown token appeared", {{std::addressof(loc), "unknown"}});
|
"unknown token appeared", {{std::addressof(loc), "unknown"}});
|
||||||
loc.reset(first);
|
loc.reset(first);
|
||||||
return err(msg);
|
return err(msg);
|
||||||
@@ -1665,7 +1665,7 @@ parse_table_key(location<Container>& loc)
|
|||||||
const auto open = lex_std_table_open::invoke(inner_loc);
|
const auto open = lex_std_table_open::invoke(inner_loc);
|
||||||
if(!open || inner_loc.iter() == inner_loc.end())
|
if(!open || inner_loc.iter() == inner_loc.end())
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_table_key: no `[`",
|
"toml::parse_table_key: no `[`",
|
||||||
{{std::addressof(inner_loc), "should be `[`"}}),
|
{{std::addressof(inner_loc), "should be `[`"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1676,7 +1676,7 @@ parse_table_key(location<Container>& loc)
|
|||||||
const auto keys = parse_key(inner_loc);
|
const auto keys = parse_key(inner_loc);
|
||||||
if(!keys)
|
if(!keys)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_table_key: invalid key",
|
"toml::parse_table_key: invalid key",
|
||||||
{{std::addressof(inner_loc), "not key"}}),
|
{{std::addressof(inner_loc), "not key"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1687,7 +1687,7 @@ parse_table_key(location<Container>& loc)
|
|||||||
const auto close = lex_std_table_close::invoke(inner_loc);
|
const auto close = lex_std_table_close::invoke(inner_loc);
|
||||||
if(!close)
|
if(!close)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_table_key: no `]`",
|
"toml::parse_table_key: no `]`",
|
||||||
{{std::addressof(inner_loc), "should be `]`"}}),
|
{{std::addressof(inner_loc), "should be `]`"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1701,7 +1701,7 @@ parse_table_key(location<Container>& loc)
|
|||||||
const auto nl = lex_newline_after_table_key::invoke(loc);
|
const auto nl = lex_newline_after_table_key::invoke(loc);
|
||||||
if(!nl)
|
if(!nl)
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] "
|
throw syntax_error(format_underline(
|
||||||
"toml::parse_table_key: newline required after [table.key]",
|
"toml::parse_table_key: newline required after [table.key]",
|
||||||
{{std::addressof(loc), "expected newline"}}),
|
{{std::addressof(loc), "expected newline"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -1711,7 +1711,7 @@ parse_table_key(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_table_key: "
|
return err(format_underline("toml::parse_table_key: "
|
||||||
"not a valid table key", {{std::addressof(loc), "here"}}));
|
"not a valid table key", {{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1727,7 +1727,7 @@ parse_array_table_key(location<Container>& loc)
|
|||||||
const auto open = lex_array_table_open::invoke(inner_loc);
|
const auto open = lex_array_table_open::invoke(inner_loc);
|
||||||
if(!open || inner_loc.iter() == inner_loc.end())
|
if(!open || inner_loc.iter() == inner_loc.end())
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_array_table_key: no `[[`",
|
"toml::parse_array_table_key: no `[[`",
|
||||||
{{std::addressof(inner_loc), "should be `[[`"}}),
|
{{std::addressof(inner_loc), "should be `[[`"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1736,7 +1736,7 @@ parse_array_table_key(location<Container>& loc)
|
|||||||
const auto keys = parse_key(inner_loc);
|
const auto keys = parse_key(inner_loc);
|
||||||
if(!keys)
|
if(!keys)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_array_table_key: invalid key",
|
"toml::parse_array_table_key: invalid key",
|
||||||
{{std::addressof(inner_loc), "not a key"}}),
|
{{std::addressof(inner_loc), "not a key"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1745,7 +1745,7 @@ parse_array_table_key(location<Container>& loc)
|
|||||||
const auto close = lex_array_table_close::invoke(inner_loc);
|
const auto close = lex_array_table_close::invoke(inner_loc);
|
||||||
if(!close)
|
if(!close)
|
||||||
{
|
{
|
||||||
throw internal_error(format_underline("[error] "
|
throw internal_error(format_underline(
|
||||||
"toml::parse_table_key: no `]]`",
|
"toml::parse_table_key: no `]]`",
|
||||||
{{std::addressof(inner_loc), "should be `]]`"}}),
|
{{std::addressof(inner_loc), "should be `]]`"}}),
|
||||||
source_location(std::addressof(inner_loc)));
|
source_location(std::addressof(inner_loc)));
|
||||||
@@ -1759,7 +1759,7 @@ parse_array_table_key(location<Container>& loc)
|
|||||||
const auto nl = lex_newline_after_table_key::invoke(loc);
|
const auto nl = lex_newline_after_table_key::invoke(loc);
|
||||||
if(!nl)
|
if(!nl)
|
||||||
{
|
{
|
||||||
throw syntax_error(format_underline("[error] toml::"
|
throw syntax_error(format_underline("toml::"
|
||||||
"parse_array_table_key: newline required after [[table.key]]",
|
"parse_array_table_key: newline required after [[table.key]]",
|
||||||
{{std::addressof(loc), "expected newline"}}),
|
{{std::addressof(loc), "expected newline"}}),
|
||||||
source_location(std::addressof(loc)));
|
source_location(std::addressof(loc)));
|
||||||
@@ -1769,7 +1769,7 @@ parse_array_table_key(location<Container>& loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return err(format_underline("[error] toml::parse_array_table_key: "
|
return err(format_underline("toml::parse_array_table_key: "
|
||||||
"not a valid table key", {{std::addressof(loc), "here"}}));
|
"not a valid table key", {{std::addressof(loc), "here"}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1844,7 +1844,7 @@ parse_ml_table(location<Container>& loc)
|
|||||||
{
|
{
|
||||||
const auto before2 = loc.iter();
|
const auto before2 = loc.iter();
|
||||||
lex_ws::invoke(loc); // skip whitespace
|
lex_ws::invoke(loc); // skip whitespace
|
||||||
const auto msg = format_underline("[error] toml::parse_table: "
|
const auto msg = format_underline("toml::parse_table: "
|
||||||
"invalid line format", {{std::addressof(loc), concat_to_string(
|
"invalid line format", {{std::addressof(loc), concat_to_string(
|
||||||
"expected newline, but got '", show_char(*loc.iter()), "'.")}});
|
"expected newline, but got '", show_char(*loc.iter()), "'.")}});
|
||||||
loc.reset(before2);
|
loc.reset(before2);
|
||||||
|
@@ -32,7 +32,7 @@ template<value_t Expected,
|
|||||||
throw_bad_cast(value_t actual, const ::toml::basic_value<C, T, A>& v)
|
throw_bad_cast(value_t actual, const ::toml::basic_value<C, T, A>& v)
|
||||||
{
|
{
|
||||||
throw type_error(detail::format_underline(concat_to_string(
|
throw type_error(detail::format_underline(concat_to_string(
|
||||||
"[error] toml::value bad_cast to ", Expected), {
|
"toml::value: bad_cast to ", Expected), {
|
||||||
{std::addressof(get_region(v)),
|
{std::addressof(get_region(v)),
|
||||||
concat_to_string("the actual type is ", actual)}
|
concat_to_string("the actual type is ", actual)}
|
||||||
}), v.location());
|
}), v.location());
|
||||||
|
Reference in New Issue
Block a user