diff options
author | Hop311 <Hop3114@gmail.com> | 2023-10-22 17:22:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 17:22:13 +0200 |
commit | efc11f571794acd64884680834c6636a03e8322b (patch) | |
tree | 5ae26ce32e536a9e0ca281785b297d014e66179d /src/openvic-dataloader/v2script/SimpleGrammar.hpp | |
parent | 0e3640b670932a597a8430588bd8ea3302126aab (diff) | |
parent | 7d5d86e44ebbd907c690023b4546a0ae0a37de3a (diff) |
Merge pull request #28 from OpenVicProject/say-thanks-to-non-breaking-space-breaking-everything-again
Add grammar support for BEL, HT, LF, and CR characters
Diffstat (limited to 'src/openvic-dataloader/v2script/SimpleGrammar.hpp')
-rw-r--r-- | src/openvic-dataloader/v2script/SimpleGrammar.hpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/openvic-dataloader/v2script/SimpleGrammar.hpp b/src/openvic-dataloader/v2script/SimpleGrammar.hpp index 9bddabd..99bbfca 100644 --- a/src/openvic-dataloader/v2script/SimpleGrammar.hpp +++ b/src/openvic-dataloader/v2script/SimpleGrammar.hpp @@ -83,12 +83,13 @@ namespace ovdl::v2script::grammar { template<ParseOptions Options> struct StringExpression { static constexpr auto rule = [] { - // Arbitrary code points that aren't control characters. - auto c = ovdl::detail::lexydsl::make_range<0x20, 0xFF>() - lexy::dsl::ascii::control; - if constexpr (Options.NoStringEscape) { + auto c = ovdl::detail::lexydsl::make_range<0x20, 0xFF>() / lexy::dsl::lit_b<0x07> / lexy::dsl::lit_b<0x09> / lexy::dsl::lit_b<0x0A> / lexy::dsl::lit_b<0x0D>; return lexy::dsl::delimited(lexy::dsl::position(lexy::dsl::lit_b<'"'>))(c); } else { + // Arbitrary code points that aren't control characters. + auto c = ovdl::detail::lexydsl::make_range<0x20, 0xFF>() - lexy::dsl::ascii::control; + // Escape sequences start with a backlash. // They either map one of the symbols, // or a Unicode code point of the form uXXXX. @@ -102,7 +103,7 @@ namespace ovdl::v2script::grammar { lexy::as_string<std::string> >> lexy::callback<ast::NodePtr>( [](const char* begin, auto&& str, const char* end) { - return ast::make_node_ptr<ast::StringNode>(ast::NodeLocation::make_from(begin, end), LEXY_MOV(str)); + return ast::make_node_ptr<ast::StringNode>(ast::NodeLocation::make_from(begin, end), LEXY_MOV(str), Options.NoStringEscape); }); }; |