expression_grammar: re-use unicode_string_grammar and add initial support for \uNNNNN code points (TODO)

This commit is contained in:
artemp 2017-03-01 11:58:18 +01:00
parent 378fa41db6
commit 2d2c5a191b

View file

@ -24,6 +24,7 @@
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP #define MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
#include <mapnik/expression_grammar_x3.hpp> #include <mapnik/expression_grammar_x3.hpp>
#include <mapnik/json/unicode_string_grammar_x3_def.hpp>
#include <mapnik/expression_node.hpp> #include <mapnik/expression_node.hpp>
#include <mapnik/function_call.hpp> #include <mapnik/function_call.hpp>
#include <mapnik/unicode.hpp> #include <mapnik/unicode.hpp>
@ -65,6 +66,9 @@ namespace mapnik { namespace grammar {
using x3::alnum; using x3::alnum;
x3::uint_parser<char, 16, 2, 2> const hex2 {}; x3::uint_parser<char, 16, 2, 2> const hex2 {};
namespace {
auto const& double_quoted = json::unicode_string_grammar();
}
auto do_assign = [] (auto const& ctx) auto do_assign = [] (auto const& ctx)
{ {
_val(ctx) = std::move(_attr(ctx)); _val(ctx) = std::move(_attr(ctx));
@ -303,8 +307,8 @@ namespace mapnik { namespace grammar {
// strings // strings
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'') >> no_skip[*(unesc_char | ("\\x" > hex2) | (char_ - '\''))] > '\''; 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 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 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"); auto const unquoted_ustring = x3::rule<class ustring, std::string> {} = no_skip[alpha > *alnum] - lit("not");