<commit_before>/*****************************************************************************
 * 
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 <NAME>
 *
 * 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
 *
 *****************************************************************************/

//$Id$

#ifndef CSS_COLOR_PARSER_HPP
#define CSS_COLOR_PARSER_HPP

#include <boost/spirit/core.hpp>
#include <boost/spirit/symbols.hpp>

using namespace boost::spirit;

namespace mapnik {
    template <typename ColorT>
    struct named_colors : public symbols<ColorT>
    {
        named_colors()
        {
            symbols<ColorT>::add
                ("aliceblue", ColorT(240, 248, 255))
                ("antiquewhite", ColorT(250, 235, 215))
                ("aqua", ColorT(0, 255, 255))
                ("aquamarine", ColorT(127, 255, 212))
                ("azure", ColorT(240, 255, 255))
                ("beige", ColorT(245, 245, 220))
                ("bisque", ColorT(255, 228, 196))
                ("black", ColorT(0, 0, 0))
                ("blanchedalmond", ColorT(255,235,205))
                ("blue", ColorT(0, 0, 255))
                ("blueviolet", ColorT(138, 43, 226))
                ("brown", ColorT(165, 42, 42))
                ("burlywood", ColorT(222, 184, 135))
                ("cadetblue", ColorT(95, 158, 160))
                ("chartreuse", ColorT(127, 255, 0))
                ("chocolate", ColorT(210, 105, 30))
                ("coral", ColorT(255, 127, 80))
                ("cornflowerblue", ColorT(100, 149, 237))
                ("cornsilk", ColorT(255, 248, 220))
                ("crimson", ColorT(220, 20, 60))
                ("cyan", ColorT(0, 255, 255))
                ("darkblue", ColorT(0, 0, 139))
                ("darkcyan", ColorT(0, 139, 139))
                ("darkgoldenrod", ColorT(184, 134, 11))
                ("darkgray", ColorT(169, 169, 169))
                ("darkgreen", ColorT(0, 100, 0))
                ("darkgrey", ColorT(169, 169, 169))
                ("darkkhaki", ColorT(189, 183, 107))
                ("darkmagenta", ColorT(139, 0, 139))
                ("darkolivegreen", ColorT(85, 107, 47))
                ("darkorange", ColorT(255, 140, 0))
                ("darkorchid", ColorT(153, 50, 204))
                ("darkred", ColorT(139, 0, 0))
                ("darksalmon", ColorT(233, 150, 122))
                ("darkseagreen", ColorT(143, 188, 143))
                ("darkslateblue", ColorT(72, 61, 139))
                ("darkslategrey", ColorT(47, 79, 79))
                ("darkturquoise", ColorT(0, 206, 209))
                ("darkviolet", ColorT(148, 0, 211))
                ("deeppink", ColorT(255, 20, 147))
                ("deepskyblue", ColorT(0, 191, 255))
                ("dimgray", ColorT(105, 105, 105))
                ("dimgrey", ColorT(105, 105, 105))
                ("dodgerblue", ColorT(30, 144, 255))
                ("firebrick", ColorT(178, 34, 34))
                ("floralwhite", ColorT(255, 250, 240))
                ("forestgreen", ColorT(34, 139, 34))
                ("fuchsia", ColorT(255, 0, 255))
                ("gainsboro", ColorT(220, 220, 220))
                ("ghostwhite", ColorT(248, 248, 255))
                ("gold", ColorT(255, 215, 0))
                ("goldenrod", ColorT(218, 165, 32))
                ("gray", ColorT(128, 128, 128))
                ("grey", ColorT(128, 128, 128))
                ("green", ColorT(0, 128, 0))
                ("greenyellow", ColorT(173, 255, 47))
                ("honeydew", ColorT(240, 255, 240))
                ("hotpink", ColorT(255, 105, 180))
                ("indianred", ColorT(205, 92, 92))
                ("indigo", ColorT(75, 0, 130))
                ("ivory", ColorT(255, 255, 240))
                ("khaki", ColorT(240, 230, 140))
                ("lavender", ColorT(230, 230, 250))
                ("lavenderblush", ColorT(255, 240, 245))
                ("lawngreen", ColorT(124, 252, 0))
                ("lemonchiffon", ColorT(255, 250, 205))
                ("lightblue", ColorT(173, 216, 230))
                ("lightcoral", ColorT(240, 128, 128))
                ("lightcyan", ColorT(224, 255, 255))
                ("lightgoldenrodyellow", ColorT(250, 250, 210))
                ("lightgray", ColorT(211, 211, 211))
                ("lightgreen", ColorT(144, 238, 144))
                ("lightgrey", ColorT(211, 211, 211))
                ("lightpink", ColorT(255, 182, 193))
                ("lightsalmon", ColorT(255, 160, 122))
                ("lightseagreen", ColorT(32, 178, 170))
                ("lightskyblue", ColorT(135, 206, 250))
                ("lightslategray", ColorT(119, 136, 153))
                ("lightslategrey", ColorT(119, 136, 153))
                ("lightsteelblue", ColorT(176, 196, 222))
                ("lightyellow", ColorT(255, 255, 224))
                ("lime", ColorT(0, 255, 0))
                ("limegreen", ColorT(50, 205, 50))
                ("linen", ColorT(250, 240, 230))
                ("magenta", ColorT(255, 0, 255))
                ("maroon", ColorT(128, 0, 0))
                ("mediumaquamarine", ColorT(102, 205, 170))
                ("mediumblue", ColorT(0, 0, 205))
                ("mediumorchid", ColorT(186, 85, 211))
                ("mediumpurple", ColorT(147, 112, 219))
                ("mediumseagreen", ColorT(60, 179, 113))
                ("mediumslateblue", ColorT(123, 104, 238))
                ("mediumspringgreen", ColorT(0, 250, 154))
                ("mediumturquoise", ColorT(72, 209, 204))
                ("mediumvioletred", ColorT(199, 21, 133))
                ("midnightblue", ColorT(25, 25, 112))
                ("mintcream", ColorT(245, 255, 250))
                ("mistyrose", ColorT(255, 228, 225))
                ("moccasin", ColorT(255, 228, 181))
                ("navajowhite", ColorT(255, 222, 173))
                ("navy", ColorT(0, 0, 128))
                ("oldlace", ColorT(253, 245, 230))
                ("olive", ColorT(128, 128, 0))
                ("olivedrab", ColorT(107, 142, 35))
                ("orange", ColorT(255, 165, 0))
                ("orangered", ColorT(255, 69, 0))
                ("orchid", ColorT(218, 112, 214))
                ("palegoldenrod", ColorT(238, 232, 170))
                ("palegreen", ColorT(152, 251, 152))
                ("paleturquoise", ColorT(175, 238, 238))
                ("palevioletred", ColorT(219, 112, 147))
                ("papayawhip", ColorT(255, 239, 213))
                ("peachpuff", ColorT(255, 218, 185))
                ("peru", ColorT(205, 133, 63))
                ("pink", ColorT(255, 192, 203))
                ("plum", ColorT(221, 160, 221))
                ("powderblue", ColorT(176, 224, 230))
                ("purple", ColorT(128, 0, 128))
                ("red", ColorT(255, 0, 0))
                ("rosybrown", ColorT(188, 143, 143))
                ("royalblue", ColorT(65, 105, 225))
                ("saddlebrown", ColorT(139, 69, 19))
                ("salmon", ColorT(250, 128, 114))
                ("sandybrown", ColorT(244, 164, 96))
                ("seagreen", ColorT(46, 139, 87))
                ("seashell", ColorT(255, 245, 238))
                ("sienna", ColorT(160, 82, 45))
                ("silver", ColorT(192, 192, 192))
                ("skyblue", ColorT(135, 206, 235))
                ("slateblue", ColorT(106, 90, 205))
                ("slategray", ColorT(112, 128, 144))
                ("slategrey", ColorT(112, 128, 144))
                ("snow", ColorT(255, 250, 250))
                ("springgreen", ColorT(0, 255, 127))
                ("steelblue", ColorT(70, 130, 180))
                ("tan", ColorT(210, 180, 140))
                ("teal", ColorT(0, 128, 128))
                ("thistle", ColorT(216, 191, 216))
                ("tomato", ColorT(255, 99, 71))
                ("turquoise", ColorT(64, 224, 208))
                ("violet", ColorT(238, 130, 238))
                ("wheat", ColorT(245, 222, 179))
                ("white", ColorT(255, 255, 255))
                ("whitesmoke", ColorT(245, 245, 245))
                ("yellow", ColorT(255, 255, 0))
                ("yellowgreen", ColorT(154, 205, 50))
                ;
        }
    };
    
    template <typename ActionsT>
    struct css_color_grammar : public grammar<css_color_grammar<ActionsT> >
    {
        css_color_grammar(ActionsT& actions_)
            : actions(actions_) {}
    
        template <typename ScannerT>
        struct definition
        {
            definition(css_color_grammar const& self)
            {
                hex6 = ch_p('#') >> uint6x_p[self.actions.hex6_];
                hex3 = ch_p('#') >> uint3x_p[self.actions.hex3_];
                rgb = str_p("rgb") >> '(' >> uint3_p[self.actions.red_] 
                                   >> ',' >> uint3_p[self.actions.green_] 
                                   >> ',' >> uint3_p[self.actions.blue_] 
                                   >> ')';
                rgb_percent = str_p("rgb") >> '(' >> ureal_p[self.actions.red_p_] >> '%' <commit_msg>added 'transparent' named colour = Color(0,0,0,0) (from Luiz Vital) TODO: support transparency for any background colour.  <commit_after>/*****************************************************************************
 * 
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2006 <NAME>
 *
 * 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
 *
 *****************************************************************************/

//$Id$

#ifndef CSS_COLOR_PARSER_HPP
#define CSS_COLOR_PARSER_HPP

#include <boost/spirit/core.hpp>
#include <boost/spirit/symbols.hpp>

using namespace boost::spirit;

namespace mapnik {
    template <typename ColorT>
    struct named_colors : public symbols<ColorT>
    {
        named_colors()
        {
            symbols<ColorT>::add
                ("aliceblue", ColorT(240, 248, 255))
                ("antiquewhite", ColorT(250, 235, 215))
                ("aqua", ColorT(0, 255, 255))
                ("aquamarine", ColorT(127, 255, 212))
                ("azure", ColorT(240, 255, 255))
                ("beige", ColorT(245, 245, 220))
                ("bisque", ColorT(255, 228, 196))
                ("black", ColorT(0, 0, 0))
                ("blanchedalmond", ColorT(255,235,205))
                ("blue", ColorT(0, 0, 255))
                ("blueviolet", ColorT(138, 43, 226))
                ("brown", ColorT(165, 42, 42))
                ("burlywood", ColorT(222, 184, 135))
                ("cadetblue", ColorT(95, 158, 160))
                ("chartreuse", ColorT(127, 255, 0))
                ("chocolate", ColorT(210, 105, 30))
                ("coral", ColorT(255, 127, 80))
                ("cornflowerblue", ColorT(100, 149, 237))
                ("cornsilk", ColorT(255, 248, 220))
                ("crimson", ColorT(220, 20, 60))
                ("cyan", ColorT(0, 255, 255))
                ("darkblue", ColorT(0, 0, 139))
                ("darkcyan", ColorT(0, 139, 139))
                ("darkgoldenrod", ColorT(184, 134, 11))
                ("darkgray", ColorT(169, 169, 169))
                ("darkgreen", ColorT(0, 100, 0))
                ("darkgrey", ColorT(169, 169, 169))
                ("darkkhaki", ColorT(189, 183, 107))
                ("darkmagenta", ColorT(139, 0, 139))
                ("darkolivegreen", ColorT(85, 107, 47))
                ("darkorange", ColorT(255, 140, 0))
                ("darkorchid", ColorT(153, 50, 204))
                ("darkred", ColorT(139, 0, 0))
                ("darksalmon", ColorT(233, 150, 122))
                ("darkseagreen", ColorT(143, 188, 143))
                ("darkslateblue", ColorT(72, 61, 139))
                ("darkslategrey", ColorT(47, 79, 79))
                ("darkturquoise", ColorT(0, 206, 209))
                ("darkviolet", ColorT(148, 0, 211))
                ("deeppink", ColorT(255, 20, 147))
                ("deepskyblue", ColorT(0, 191, 255))
                ("dimgray", ColorT(105, 105, 105))
                ("dimgrey", ColorT(105, 105, 105))
                ("dodgerblue", ColorT(30, 144, 255))
                ("firebrick", ColorT(178, 34, 34))
                ("floralwhite", ColorT(255, 250, 240))
                ("forestgreen", ColorT(34, 139, 34))
                ("fuchsia", ColorT(255, 0, 255))
                ("gainsboro", ColorT(220, 220, 220))
                ("ghostwhite", ColorT(248, 248, 255))
                ("gold", ColorT(255, 215, 0))
                ("goldenrod", ColorT(218, 165, 32))
                ("gray", ColorT(128, 128, 128))
                ("grey", ColorT(128, 128, 128))
                ("green", ColorT(0, 128, 0))
                ("greenyellow", ColorT(173, 255, 47))
                ("honeydew", ColorT(240, 255, 240))
                ("hotpink", ColorT(255, 105, 180))
                ("indianred", ColorT(205, 92, 92))
                ("indigo", ColorT(75, 0, 130))
                ("ivory", ColorT(255, 255, 240))
                ("khaki", ColorT(240, 230, 140))
                ("lavender", ColorT(230, 230, 250))
                ("lavenderblush", ColorT(255, 240, 245))
                ("lawngreen", ColorT(124, 252, 0))
                ("lemonchiffon", ColorT(255, 250, 205))
                ("lightblue", ColorT(173, 216, 230))
                ("lightcoral", ColorT(240, 128, 128))
                ("lightcyan", ColorT(224, 255, 255))
                ("lightgoldenrodyellow", ColorT(250, 250, 210))
                ("lightgray", ColorT(211, 211, 211))
                ("lightgreen", ColorT(144, 238, 144))
                ("lightgrey", ColorT(211, 211, 211))
                ("lightpink", ColorT(255, 182, 193))
                ("lightsalmon", ColorT(255, 160, 122))
                ("lightseagreen", ColorT(32, 178, 170))
                ("lightskyblue", ColorT(135, 206, 250))
                ("lightslategray", ColorT(119, 136, 153))
                ("lightslategrey", ColorT(119, 136, 153))
                ("lightsteelblue", ColorT(176, 196, 222))
                ("lightyellow", ColorT(255, 255, 224))
                ("lime", ColorT(0, 255, 0))
                ("limegreen", ColorT(50, 205, 50))
                ("linen", ColorT(250, 240, 230))
                ("magenta", ColorT(255, 0, 255))
                ("maroon", ColorT(128, 0, 0))
                ("mediumaquamarine", ColorT(102, 205, 170))
                ("mediumblue", ColorT(0, 0, 205))
                ("mediumorchid", ColorT(186, 85, 211))
                ("mediumpurple", ColorT(147, 112, 219))
                ("mediumseagreen", ColorT(60, 179, 113))
                ("mediumslateblue", ColorT(123, 104, 238))
                ("mediumspringgreen", ColorT(0, 250, 154))
                ("mediumturquoise", ColorT(72, 209, 204))
                ("mediumvioletred", ColorT(199, 21, 133))
                ("midnightblue", ColorT(25, 25, 112))
                ("mintcream", ColorT(245, 255, 250))
                ("mistyrose", ColorT(255, 228, 225))
                ("moccasin", ColorT(255, 228, 181))
                ("navajowhite", ColorT(255, 222, 173))
                ("navy", ColorT(0, 0, 128))
                ("oldlace", ColorT(253, 245, 230))
                ("olive", ColorT(128, 128, 0))
                ("olivedrab", ColorT(107, 142, 35))
                ("orange", ColorT(255, 165, 0))
                ("orangered", ColorT(255, 69, 0))
                ("orchid", ColorT(218, 112, 214))
                ("palegoldenrod", ColorT(238, 232, 170))
                ("palegreen", ColorT(152, 251, 152))
                ("paleturquoise", ColorT(175, 238, 238))
                ("palevioletred", ColorT(219, 112, 147))
                ("papayawhip", ColorT(255, 239, 213))
                ("peachpuff", ColorT(255, 218, 185))
                ("peru", ColorT(205, 133, 63))
                ("pink", ColorT(255, 192, 203))
                ("plum", ColorT(221, 160, 221))
                ("powderblue", ColorT(176, 224, 230))
                ("purple", ColorT(128, 0, 128))
                ("red", ColorT(255, 0, 0))
                ("rosybrown", ColorT(188, 143, 143))
                ("royalblue", ColorT(65, 105, 225))
                ("saddlebrown", ColorT(139, 69, 19))
                ("salmon", ColorT(250, 128, 114))
                ("sandybrown", ColorT(244, 164, 96))
                ("seagreen", ColorT(46, 139, 87))
                ("seashell", ColorT(255, 245, 238))
                ("sienna", ColorT(160, 82, 45))
                ("silver", ColorT(192, 192, 192))
                ("skyblue", ColorT(135, 206, 235))
                ("slateblue", ColorT(106, 90, 205))
                ("slategray", ColorT(112, 128, 144))
                ("slategrey", ColorT(112, 128, 144))
                ("snow", ColorT(255, 250, 250))
                ("springgreen", ColorT(0, 255, 127))
                ("steelblue", ColorT(70, 130, 180))
                ("tan", ColorT(210, 180, 140))
                ("teal", ColorT(0, 128, 128))
                ("thistle", ColorT(216, 191, 216))
                ("tomato", ColorT(255, 99, 71))
                ("turquoise", ColorT(64, 224, 208))
                ("violet", ColorT(238, 130, 238))
                ("wheat", ColorT(245, 222, 179))
                ("white", ColorT(255, 255, 255))
                ("whitesmoke", ColorT(245, 245, 245))
                ("yellow", ColorT(255, 255, 0))
                ("yellowgreen", ColorT(154, 205, 50))
                ("transparent", ColorT(0, 0, 0, 0))
                ;
        }
    };
    
    template <typename ActionsT>
    struct css_color_grammar : public grammar<css_color_grammar<ActionsT> >
    {
        css_color_grammar(ActionsT& actions_)
            : actions(actions_) {}
    
        template <typename ScannerT>
        struct definition
        {
            definition(css_color_grammar const& self)
            {
                hex6 = ch_p('#') >> uint6x_p[self.actions.hex6_];
                hex3 = ch_p('#') >> uint3x_p[self.actions.hex3_];
                rgb = str_p("rgb") >> '(' >> uint3_p[self.actions.red_] 
                                   >> ',' >> uint3_p[self.actions.green_] 
                                   >> ',' >> uint3_p[self.actions.blue_] 
                                   >> ')';
                rgb_percent = str_p("rgb") >> '(' >> ureal_p[self.actions.red_p_] >> '%' 
{'fraction_non_alphanumeric': 0.17051204209674156, 'fraction_numerical': 0.12143290831815422, 'mean_word_length': 1.7705354639753295, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4314313', 'n_tokens_mistral': 8308, 'n_tokens_neox': 5828, 'n_words': 1554}