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:
parent
713b9e7788
commit
fb7139bc63
1 changed files with 20 additions and 4 deletions
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in a new issue