mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
feat: add escape sequence of ESC
as an unreleased feature
This commit is contained in:
@@ -217,6 +217,19 @@ BOOST_AUTO_TEST_CASE(test_ml_literal_string_value)
|
|||||||
value("'This,' she said, 'is just a pointless statement.'", string_t::literal));
|
value("'This,' she said, 'is just a pointless statement.'", string_t::literal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(test_simple_excape_sequences)
|
||||||
|
{
|
||||||
|
TOML11_TEST_PARSE_EQUAL(parse_string,
|
||||||
|
R"("\"\\\b\f\n\r\t")",
|
||||||
|
string("\"\\\b\f\n\r\t", string_t::basic));
|
||||||
|
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
||||||
|
TOML11_TEST_PARSE_EQUAL(parse_string,
|
||||||
|
R"("\e")",
|
||||||
|
string("\x1b", string_t::basic));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_unicode_escape_sequence)
|
BOOST_AUTO_TEST_CASE(test_unicode_escape_sequence)
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||||
|
@@ -133,6 +133,9 @@ using lex_escape_seq_char = either<character<'"'>, character<'\\'>,
|
|||||||
character<'b'>, character<'f'>,
|
character<'b'>, character<'f'>,
|
||||||
character<'n'>, character<'r'>,
|
character<'n'>, character<'r'>,
|
||||||
character<'t'>,
|
character<'t'>,
|
||||||
|
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
||||||
|
character<'e'>, // ESC (0x1B)
|
||||||
|
#endif
|
||||||
lex_escape_unicode_short,
|
lex_escape_unicode_short,
|
||||||
lex_escape_unicode_long
|
lex_escape_unicode_long
|
||||||
>;
|
>;
|
||||||
|
@@ -327,6 +327,9 @@ inline result<std::string, std::string> parse_escape_sequence(location& loc)
|
|||||||
case 'n' :{loc.advance(); return ok(std::string("\n"));}
|
case 'n' :{loc.advance(); return ok(std::string("\n"));}
|
||||||
case 'f' :{loc.advance(); return ok(std::string("\f"));}
|
case 'f' :{loc.advance(); return ok(std::string("\f"));}
|
||||||
case 'r' :{loc.advance(); return ok(std::string("\r"));}
|
case 'r' :{loc.advance(); return ok(std::string("\r"));}
|
||||||
|
#ifdef TOML11_USE_UNRELEASED_TOML_FEATURES
|
||||||
|
case 'e' :{loc.advance(); return ok(std::string("\x1b"));} // ESC
|
||||||
|
#endif
|
||||||
case 'u' :
|
case 'u' :
|
||||||
{
|
{
|
||||||
if(const auto token = lex_escape_unicode_short::invoke(loc))
|
if(const auto token = lex_escape_unicode_short::invoke(loc))
|
||||||
|
Reference in New Issue
Block a user