diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 469a24a09..b562447ef 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -148,6 +148,8 @@ struct expression_grammar : qi::grammar using qi::lit; using qi::int_; using qi::double_; + using qi::hex; + using qi::omit; using standard_wide::char_; expr = logical_expr.alias(); @@ -223,14 +225,23 @@ struct expression_grammar : qi::grammar | '(' >> expr [_val = _1 ] >> ')' ; - + unesc_char.add("\\a", '\a')("\\b", '\b')("\\f", '\f')("\\n", '\n') + ("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\') + ("\\\'", '\'')("\\\"", '\"') + ; + + ustring %= omit[quote_char[_a = _1]] + >> *(unesc_char | "\\x" >> hex | (char_ - lit(_a))) + >> lit(_a); + + quote_char %= char_('\'') | char_('"'); + #if BOOST_VERSION > 104200 - ustring %= '\'' >> no_skip[*~char_('\'')] >> '\''; attr %= '[' >> no_skip[+~char_(']')] >> ']'; #else - ustring %= '\'' >> lexeme[*(char_-'\'')] >> '\''; attr %= '[' >> lexeme[+(char_ - ']')] >> ']'; #endif + } qi::real_parser > strict_double; @@ -250,7 +261,9 @@ struct expression_grammar : qi::grammar qi::rule regex_match_expr; qi::rule, space_type> regex_replace_expr; qi::rule attr; - qi::rule ustring; + qi::rule > ustring; + qi::symbols unesc_char; + qi::rule quote_char; }; } // namespace