| 14660 | } |
| 14661 | |
| 14662 | TOML_NODISCARD |
| 14663 | node_ptr parse_value() |
| 14664 | { |
| 14665 | return_if_error({}); |
| 14666 | assert_not_eof(); |
| 14667 | TOML_ASSERT_ASSUME(!is_value_terminator(*cp)); |
| 14668 | push_parse_scope("value"sv); |
| 14669 | |
| 14670 | const depth_counter_scope depth_counter{ nested_values }; |
| 14671 | if TOML_UNLIKELY(nested_values > max_nested_values) |
| 14672 | set_error_and_return_default("exceeded maximum nested value depth of "sv, |
| 14673 | max_nested_values, |
| 14674 | " (TOML_MAX_NESTED_VALUES)"sv); |
| 14675 | |
| 14676 | // check if it begins with some control character |
| 14677 | // (note that this will also fail for whitespace but we're assuming we've |
| 14678 | // called consume_leading_whitespace() before calling parse_value()) |
| 14679 | if TOML_UNLIKELY(is_control_character(*cp)) |
| 14680 | set_error_and_return_default("unexpected control character"sv); |
| 14681 | |
| 14682 | // underscores at the beginning |
| 14683 | else if (*cp == U'_') |
| 14684 | set_error_and_return_default("values may not begin with underscores"sv); |
| 14685 | |
| 14686 | const auto begin_pos = cp->position; |
| 14687 | node_ptr val; |
| 14688 | |
| 14689 | do |
| 14690 | { |
| 14691 | TOML_ASSERT_ASSUME(!is_control_character(*cp)); |
| 14692 | TOML_ASSERT_ASSUME(*cp != U'_'); |
| 14693 | |
| 14694 | // detect the value type and parse accordingly, |
| 14695 | // starting with value types that can be detected |
| 14696 | // unambiguously from just one character. |
| 14697 | |
| 14698 | val = parse_value_known_prefixes(); |
| 14699 | return_if_error({}); |
| 14700 | if (val) |
| 14701 | break; |
| 14702 | |
| 14703 | // value types from here down require more than one character to unambiguously identify |
| 14704 | // so scan ahead and collect a set of value 'traits'. |
| 14705 | enum TOML_CLOSED_FLAGS_ENUM value_traits : int |
| 14706 | { |
| 14707 | has_nothing = 0, |
| 14708 | has_digits = 1, |
| 14709 | has_b = 1 << 1, // as second char only (0b) |
| 14710 | has_e = 1 << 2, // only float exponents |
| 14711 | has_o = 1 << 3, // as second char only (0o) |
| 14712 | has_p = 1 << 4, // only hexfloat exponents |
| 14713 | has_t = 1 << 5, |
| 14714 | has_x = 1 << 6, // as second or third char only (0x, -0x, +0x) |
| 14715 | has_z = 1 << 7, |
| 14716 | has_colon = 1 << 8, |
| 14717 | has_plus = 1 << 9, |
| 14718 | has_minus = 1 << 10, |
| 14719 | has_dot = 1 << 11, |
nothing calls this directly
no outgoing calls
no test coverage detected