expressions - only import escaped rule from unicode_string_grammar and construct single/double quoted string rules locally to match expression grammar. NOTE: single quoted strings don't accept unicode encodings

This commit is contained in:
artemp 2017-03-03 15:14:01 +01:00
parent 713b9e7788
commit fb7139bc63

View file

@ -67,8 +67,14 @@ namespace mapnik { namespace grammar {
x3::uint_parser<char, 16, 2, 2> const hex2 {};
namespace {
auto const& double_quoted = json::unicode_string_grammar();
auto const& escaped = json::grammar::escaped;
}
auto append = [](auto const& ctx)
{
_val(ctx) += _attr(ctx);
};
auto do_assign = [] (auto const& ctx)
{
_val(ctx) = std::move(_attr(ctx));
@ -306,9 +312,19 @@ namespace mapnik { namespace grammar {
x3::rule<class regex_replace_expression, std::pair<std::string,std::string> > const regex_replace_expression("regex replace expression");
// strings
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'') >> no_skip[*(unesc_char | ("\\x" > hex2) | (char_ - '\''))] > '\'';
//auto const double_quoted_string = x3::rule<class double_quoted_string, std::string> {} = lit('"') >> no_skip[*(unesc_char | ("\\x" > hex2) | (char_ - '"'))] > '"';
auto const quoted_string = x3::rule<class quoted_string, std::string> {} = single_quoted_string | double_quoted;//_string;
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'')
>> no_skip[*(unesc_char[append]
|
(~char_('\''))[append])] > lit('\'');
auto const double_quoted_string = x3::rule<class double_quoted_string, std::string> {} = lit('"')
>> no_skip[*(unesc_char[append]
|
escaped[append]
|
(~char_('"'))[append])] > lit('"');
auto const quoted_string = x3::rule<class quoted_string, std::string> {} = single_quoted_string | double_quoted_string;
auto const unquoted_ustring = x3::rule<class ustring, std::string> {} = no_skip[alpha > *alnum] - lit("not");