Add CSS parser grammar + move into separate include/css and src/css dirs.

This commit is contained in:
Artem Pavlenko 2020-02-04 10:37:55 +00:00
parent 3be9ce8fa0
commit 00b888c1ef
10 changed files with 72 additions and 8 deletions

View file

@ -28,7 +28,8 @@ src/json/libmapnik-json.a:
src/renderer_common/render_thunk_extractor.os \ src/renderer_common/render_thunk_extractor.os \
src/json/libmapnik-json.a \ src/json/libmapnik-json.a \
src/wkt/libmapnik-wkt.a \ src/wkt/libmapnik-wkt.a \
src/css_color_grammar_x3.os \ src/css/css_grammar_x3.os \
src/css/css_color_grammar_x3.os \
src/expression_grammar_x3.os \ src/expression_grammar_x3.os \
src/transform_expression_grammar_x3.os \ src/transform_expression_grammar_x3.os \
src/image_filter_grammar_x3.os \ src/image_filter_grammar_x3.os \

View file

@ -28,6 +28,7 @@ subdirglobs = [
('.', 'mapnik/*.hpp'), ('.', 'mapnik/*.hpp'),
('agg', '../deps/agg/include/agg*'), ('agg', '../deps/agg/include/agg*'),
('cairo', 'mapnik/cairo/*.hpp'), ('cairo', 'mapnik/cairo/*.hpp'),
('css', 'mapnik/css/*.hpp'),
('csv', 'mapnik/csv/*.hpp'), ('csv', 'mapnik/csv/*.hpp'),
('deps/mapbox', '../deps/mapbox/variant/include/mapbox/*.hpp'), ('deps/mapbox', '../deps/mapbox/variant/include/mapbox/*.hpp'),
('deps/mapbox', '../deps/mapbox/geometry/include/mapbox/*.hpp'), ('deps/mapbox', '../deps/mapbox/geometry/include/mapbox/*.hpp'),

View file

@ -25,7 +25,7 @@
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP #ifndef MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP #define MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
#include <mapnik/css_color_grammar_x3.hpp> #include <mapnik/css/css_color_grammar_x3.hpp>
#include <mapnik/util/hsl.hpp> #include <mapnik/util/hsl.hpp>
#include <mapnik/safe_cast.hpp> #include <mapnik/safe_cast.hpp>

View file

@ -26,7 +26,7 @@
#include <mapnik/image_filter_grammar_x3.hpp> #include <mapnik/image_filter_grammar_x3.hpp>
#include <mapnik/image_filter_types.hpp> #include <mapnik/image_filter_types.hpp>
#include <mapnik/css_color_grammar_x3.hpp> #include <mapnik/css/css_color_grammar_x3.hpp>
#pragma GCC diagnostic push #pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp> #include <mapnik/warning_ignore.hpp>

View file

@ -152,7 +152,6 @@ else: # unix, non-macos
source = Split( source = Split(
""" """
expression_grammar_x3.cpp expression_grammar_x3.cpp
css_color_grammar_x3.cpp
fs.cpp fs.cpp
request.cpp request.cpp
well_known_srs.cpp well_known_srs.cpp
@ -225,6 +224,8 @@ source = Split(
raster_colorizer.cpp raster_colorizer.cpp
mapped_memory_cache.cpp mapped_memory_cache.cpp
marker_cache.cpp marker_cache.cpp
css/css_color_grammar_x3.cpp
css/css_grammar_x3.cpp
svg/svg_parser.cpp svg/svg_parser.cpp
svg/svg_path_parser.cpp svg/svg_path_parser.cpp
svg/svg_points_parser.cpp svg/svg_points_parser.cpp

View file

@ -24,7 +24,7 @@
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
#include <mapnik/color_factory.hpp> #include <mapnik/color_factory.hpp>
#include <mapnik/config_error.hpp> #include <mapnik/config_error.hpp>
#include <mapnik/css_color_grammar_x3.hpp> #include <mapnik/css/css_color_grammar_x3.hpp>
namespace mapnik { namespace mapnik {

View file

@ -20,7 +20,8 @@
* *
*****************************************************************************/ *****************************************************************************/
#include <mapnik/css_color_grammar_x3_def.hpp> #include <mapnik/css/css_grammar_x3.hpp>
#include <mapnik/css/css_color_grammar_x3_def.hpp>
#if BOOST_VERSION < 107000 #if BOOST_VERSION < 107000
#include <mapnik/image_filter_types.hpp> #include <mapnik/image_filter_types.hpp>
#endif #endif
@ -29,8 +30,10 @@ namespace mapnik { namespace css_color_grammar {
namespace x3 = boost::spirit::x3; namespace x3 = boost::spirit::x3;
using iterator_type = std::string::const_iterator; using iterator_type = std::string::const_iterator;
using context_type = x3::phrase_parse_context<x3::ascii::space_type>::type; using context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
using context_skipper_type = x3::phrase_parse_context<css_grammar::css_skipper_type>::type;
BOOST_SPIRIT_INSTANTIATE(css_color_grammar_type, iterator_type, context_type); BOOST_SPIRIT_INSTANTIATE(css_color_grammar_type, iterator_type, context_type);
BOOST_SPIRIT_INSTANTIATE(css_color_grammar_type, iterator_type, context_skipper_type);
#if BOOST_VERSION < 107000 #if BOOST_VERSION < 107000
template bool parse_rule<iterator_type, context_type, mapnik::filter::color_to_alpha> template bool parse_rule<iterator_type, context_type, mapnik::filter::color_to_alpha>

View file

@ -0,0 +1,58 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2020 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#include <mapnik/css/css_grammar_x3_def.hpp>
#include <mapnik/css/css_color_grammar_x3.hpp>
namespace mapnik { namespace css_grammar {
namespace x3 = boost::spirit::x3;
using iterator_type = std::string::const_iterator;
using context_type = x3::phrase_parse_context<css_skipper_type>::type;
BOOST_SPIRIT_INSTANTIATE(ident_grammar_type, iterator_type, context_type);
BOOST_SPIRIT_INSTANTIATE(css_classes_type, iterator_type, context_type);
BOOST_SPIRIT_INSTANTIATE(css_grammar_type, iterator_type, context_type);
BOOST_SPIRIT_INSTANTIATE(css_skipper_type, iterator_type, x3::unused_type);
}
css_grammar::ident_grammar_type const ident_grammar()
{
return css_grammar::ident;
}
css_grammar::css_classes_type const classes()
{
return css_grammar::css_classes;
}
css_grammar::css_grammar_type const grammar()
{
return css_grammar::css_grammar;
}
css_grammar::css_skipper_type const skipper()
{
return css_grammar::css_skipper;
}
}

View file

@ -2,8 +2,8 @@
#include <mapnik/safe_cast.hpp> #include <mapnik/safe_cast.hpp>
#include <mapnik/color.hpp> #include <mapnik/color.hpp>
#include <mapnik/css_color_grammar_x3.hpp> #include <mapnik/css/css_color_grammar_x3.hpp>
#include <mapnik/css_color_grammar_x3_def.hpp> #include <mapnik/css/css_color_grammar_x3_def.hpp>
#include <sstream> #include <sstream>