mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
feat: remove TOML11_UNRELEASED_FEATURES.
v1.0.0-rc.1 has been released
This commit is contained in:
@@ -80,13 +80,13 @@ BOOST_AUTO_TEST_CASE(test_detect_conflicting_value)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_detect_inhomogeneous_array)
|
BOOST_AUTO_TEST_CASE(test_detect_inhomogeneous_array)
|
||||||
{
|
{
|
||||||
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
#ifdef TOML11_DISALLOW_HETEROGENEOUS_ARRAYS
|
||||||
BOOST_TEST_MESSAGE("heterogeneous array will be allowed in the next release");
|
|
||||||
#else
|
|
||||||
std::istringstream stream(std::string(
|
std::istringstream stream(std::string(
|
||||||
"a = [1, 1.0]\n"
|
"a = [1, 1.0]\n"
|
||||||
));
|
));
|
||||||
BOOST_CHECK_THROW(toml::parse(stream), toml::syntax_error);
|
BOOST_CHECK_THROW(toml::parse(stream), toml::syntax_error);
|
||||||
|
#else
|
||||||
|
BOOST_TEST_MESSAGE("After v1.0.0-rc.1, heterogeneous arrays are allowed");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,15 +69,8 @@ using lex_zero_prefixable_int = sequence<lex_digit, repeat<either<lex_digit,
|
|||||||
|
|
||||||
using lex_fractional_part = sequence<character<'.'>, lex_zero_prefixable_int>;
|
using lex_fractional_part = sequence<character<'.'>, lex_zero_prefixable_int>;
|
||||||
|
|
||||||
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
|
||||||
// use toml-lang/toml HEAD
|
|
||||||
using lex_exponent_part = sequence<either<character<'e'>, character<'E'>>,
|
using lex_exponent_part = sequence<either<character<'e'>, character<'E'>>,
|
||||||
maybe<lex_sign>, lex_zero_prefixable_int>;
|
maybe<lex_sign>, lex_zero_prefixable_int>;
|
||||||
#else
|
|
||||||
// strictly TOML v0.5.0
|
|
||||||
using lex_exponent_part = sequence<either<character<'e'>, character<'E'>>,
|
|
||||||
lex_dec_int>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using lex_float = either<lex_special_float,
|
using lex_float = either<lex_special_float,
|
||||||
sequence<lex_dec_int, either<lex_exponent_part,
|
sequence<lex_dec_int, either<lex_exponent_part,
|
||||||
@@ -125,17 +118,11 @@ using lex_local_time = lex_partial_time;
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
using lex_quotation_mark = character<'"'>;
|
using lex_quotation_mark = character<'"'>;
|
||||||
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
|
||||||
using lex_basic_unescaped = exclude<either<in_range<0x00, 0x08>, // 0x09 (tab)
|
using lex_basic_unescaped = exclude<either<in_range<0x00, 0x08>, // 0x09 (tab)
|
||||||
in_range<0x0a, 0x1F>, // is allowed
|
in_range<0x0a, 0x1F>, // is allowed
|
||||||
character<0x22>, character<0x5C>,
|
character<0x22>, character<0x5C>,
|
||||||
character<0x7F>>>;
|
character<0x7F>>>;
|
||||||
#else
|
|
||||||
using lex_basic_unescaped = exclude<either<in_range<0x00, 0x1F>,
|
|
||||||
character<0x22>, character<0x5C>,
|
|
||||||
character<0x7F>>>;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
using lex_escape = character<'\\'>;
|
using lex_escape = character<'\\'>;
|
||||||
using lex_escape_unicode_short = sequence<character<'u'>,
|
using lex_escape_unicode_short = sequence<character<'u'>,
|
||||||
repeat<lex_hex_dig, exactly<4>>>;
|
repeat<lex_hex_dig, exactly<4>>>;
|
||||||
@@ -183,12 +170,6 @@ using lex_basic_string = sequence<lex_quotation_mark,
|
|||||||
// In parse_ml_basic_string() function, the trailing `"`s will be attached to
|
// In parse_ml_basic_string() function, the trailing `"`s will be attached to
|
||||||
// the string body.
|
// the string body.
|
||||||
//
|
//
|
||||||
// Note: This feature is a "clarification". Therefore this change is considered
|
|
||||||
// as a spec that has been defined since the time when the multi-line
|
|
||||||
// basic string was introduced. Although it is a post-v0.5.0 changes,
|
|
||||||
// this change will be activated regardless of the flag,
|
|
||||||
// `TOML11_USE_UNRELEASED_TOML_FEATURES`.
|
|
||||||
//
|
|
||||||
using lex_ml_basic_string_delim = repeat<lex_quotation_mark, exactly<3>>;
|
using lex_ml_basic_string_delim = repeat<lex_quotation_mark, exactly<3>>;
|
||||||
using lex_ml_basic_string_open = lex_ml_basic_string_delim;
|
using lex_ml_basic_string_open = lex_ml_basic_string_delim;
|
||||||
using lex_ml_basic_string_close = sequence<
|
using lex_ml_basic_string_close = sequence<
|
||||||
@@ -196,18 +177,11 @@ using lex_ml_basic_string_close = sequence<
|
|||||||
maybe<lex_quotation_mark>, maybe<lex_quotation_mark>
|
maybe<lex_quotation_mark>, maybe<lex_quotation_mark>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
|
||||||
using lex_ml_basic_unescaped = exclude<either<in_range<0x00, 0x08>, // 0x09
|
using lex_ml_basic_unescaped = exclude<either<in_range<0x00, 0x08>, // 0x09
|
||||||
in_range<0x0a, 0x1F>, // is tab
|
in_range<0x0a, 0x1F>, // is tab
|
||||||
character<0x5C>, // backslash
|
character<0x5C>, // backslash
|
||||||
character<0x7F>, // DEL
|
character<0x7F>, // DEL
|
||||||
lex_ml_basic_string_delim>>;
|
lex_ml_basic_string_delim>>;
|
||||||
#else // TOML v0.5.0
|
|
||||||
using lex_ml_basic_unescaped = exclude<either<in_range<0x00,0x1F>,
|
|
||||||
character<0x5C>,
|
|
||||||
character<0x7F>,
|
|
||||||
lex_ml_basic_string_delim>>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using lex_ml_basic_escaped_newline = sequence<
|
using lex_ml_basic_escaped_newline = sequence<
|
||||||
lex_escape, maybe<lex_ws>, lex_newline,
|
lex_escape, maybe<lex_ws>, lex_newline,
|
||||||
|
|||||||
@@ -977,7 +977,12 @@ parse_array(location<Container>& loc)
|
|||||||
|
|
||||||
if(auto val = parse_value<value_type>(loc))
|
if(auto val = parse_value<value_type>(loc))
|
||||||
{
|
{
|
||||||
#ifndef TOML11_USE_UNRELEASED_TOML_FEATURES
|
// After TOML v1.0.0-rc.1, array becomes to be able to have values
|
||||||
|
// with different types. So here we will omit this by default.
|
||||||
|
//
|
||||||
|
// But some of the test-suite checks if the parser accepts a hetero-
|
||||||
|
// geneous arrays, so we keep this for a while.
|
||||||
|
#ifdef TOML11_DISALLOW_HETEROGENEOUS_ARRAYS
|
||||||
if(!retval.empty() && retval.front().type() != val.as_ok().type())
|
if(!retval.empty() && retval.front().type() != val.as_ok().type())
|
||||||
{
|
{
|
||||||
auto array_start_loc = loc;
|
auto array_start_loc = loc;
|
||||||
@@ -1389,9 +1394,6 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
|
|||||||
// According to toml-lang/toml:36d3091b3 "Clarify that inline
|
// According to toml-lang/toml:36d3091b3 "Clarify that inline
|
||||||
// tables are immutable", check if it adds key-value pair to an
|
// tables are immutable", check if it adds key-value pair to an
|
||||||
// inline table.
|
// inline table.
|
||||||
// This is one of the unreleased (after-0.5.0) toml feature.
|
|
||||||
// But this is marked as "Clarify", so TOML-lang intended that
|
|
||||||
// inline tables are immutable in all version.
|
|
||||||
{
|
{
|
||||||
// here, if the value is a (multi-line) table, the region
|
// here, if the value is a (multi-line) table, the region
|
||||||
// should be something like `[table-name]`.
|
// should be something like `[table-name]`.
|
||||||
|
|||||||
@@ -135,43 +135,8 @@ struct serializer
|
|||||||
{
|
{
|
||||||
// the resulting value does not have any float specific part!
|
// the resulting value does not have any float specific part!
|
||||||
token += ".0";
|
token += ".0";
|
||||||
return token;
|
|
||||||
}
|
|
||||||
if(!has_exponent)
|
|
||||||
{
|
|
||||||
return token; // there is no exponent part. just return it.
|
|
||||||
}
|
|
||||||
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
|
||||||
// Although currently it is not released yet as a tagged version,
|
|
||||||
// TOML will allow zero-prefix in an exponent part, such as `1.234e+01`.
|
|
||||||
// ```toml
|
|
||||||
// num1 = 1.234e+1 # OK in TOML v0.5.0
|
|
||||||
// num2 = 1.234e+01 # error in TOML v0.5.0 but will be allowed soon
|
|
||||||
// ```
|
|
||||||
// To avoid `e+01`, the following `else` section removes the zero
|
|
||||||
// prefixes in the exponent part.
|
|
||||||
// If the feature is activated, it can be skipped.
|
|
||||||
return token;
|
|
||||||
#else
|
|
||||||
// zero-prefix in an exponent is NOT allowed in TOML v0.5.0.
|
|
||||||
// remove it if it exists.
|
|
||||||
bool sign_exists = false;
|
|
||||||
std::size_t zero_prefix = 0;
|
|
||||||
for(auto iter = std::next(e), iend = token.cend(); iter != iend; ++iter)
|
|
||||||
{
|
|
||||||
if(*iter == '+' || *iter == '-'){sign_exists = true; continue;}
|
|
||||||
if(*iter == '0'){zero_prefix += 1;}
|
|
||||||
else {break;}
|
|
||||||
}
|
|
||||||
if(zero_prefix != 0)
|
|
||||||
{
|
|
||||||
const auto offset = std::distance(token.cbegin(), e) +
|
|
||||||
(sign_exists ? 2 : 1);
|
|
||||||
token.erase(static_cast<typename std::string::size_type>(offset),
|
|
||||||
zero_prefix);
|
|
||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
std::string operator()(const string_type& s) const
|
std::string operator()(const string_type& s) const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user