bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
{
    using qi::double_;
    using qi::phrase_parse;
    using qi::_1;
    using qi::lit;
    using qi::char_;
#if BOOST_VERSION > 104200
    using qi::no_skip;
#else
    using qi::lexeme;
#endif
    using phoenix::push_back;
    // SVG
    // dasharray ::= (length | percentage) (comma-wsp dasharray)?
    // no support for 'percentage' as viewport is unknown at load_map
    //
    bool r = phrase_parse(first, last,
                          (double_[push_back(phoenix::ref(dasharray), _1)] %
#if BOOST_VERSION > 104200
                          no_skip[char_(", ")]
#else
                          lexeme[char_(", ")]
#endif
                          | lit("none")),
                          qi::ascii::space);
    if (first != last)
    {
        return false;
    }
    return r;
}
Exemple #2
0
        effects_group_rules() {
            const parse::lexer& tok = parse::lexer::instance();

            qi::_1_type _1;
            qi::_a_type _a;
            qi::_b_type _b;
            qi::_c_type _c;
            qi::_d_type _d;
            qi::_e_type _e;
            qi::_f_type _f;
            qi::_g_type _g;
            qi::_val_type _val;
            qi::lit_type lit;
            qi::eps_type eps;
            using phoenix::construct;
            using phoenix::new_;
            using phoenix::push_back;

            effects_group
                =   tok.EffectsGroup_
                > -(parse::label(Description_token)      > tok.string [ _g = _1 ])
                >   parse::label(Scope_token)            > parse::detail::condition_parser [ _a = _1 ]
                > -(parse::label(Activation_token)       > parse::detail::condition_parser [ _b = _1 ])
                > -(parse::label(StackingGroup_token)    > tok.string [ _c = _1 ])
                > -(parse::label(AccountingLabel_token)  > tok.string [ _e = _1 ])
                > ((parse::label(Priority_token)         > tok.int_ [ _f = _1 ]) | eps [ _f = 100 ])
                >   parse::label(Effects_token)
                >   (
                            ('[' > +parse::effect_parser() [ push_back(_d, _1) ] > ']')
                        |    parse::effect_parser() [ push_back(_d, _1) ]
                    )
                    [ _val = new_<Effect::EffectsGroup>(_a, _b, _d, _e, _c, _f, _g) ]
                ;

            start
                =    ('[' > +effects_group [ push_back(_val, construct<std::shared_ptr<Effect::EffectsGroup>>(_1)) ] > ']')
                |     effects_group [ push_back(_val, construct<std::shared_ptr<Effect::EffectsGroup>>(_1)) ]
                ;

            effects_group.name("EffectsGroup");
            start.name("EffectsGroups");

#if DEBUG_PARSERS
            debug(effects_group);
            debug(start);
#endif
        }
Exemple #3
0
    bool parse_numbers( Iterator first, Iterator last, vector<double> &v )
    {
      using qi::double_;
      using qi::phrase_parse;
      using qi::_1;
      using ascii::space;
      using phoenix::push_back;

      bool r( phrase_parse( first, last,
              (
               double_[ push_back( phoenix::ref( v ), _1 ) ] % ','
              ),
                            space ) );
      return ( first == last ? r : false );
    }
Exemple #4
0
    bool parse_numbers(Iterator first, Iterator last, std::vector<double>& v)
    {
        using qi::double_;
        using qi::phrase_parse;
        using qi::_1;
        using ascii::space;
        using phoenix::push_back;
        using phoenix::ref;

        bool r = phrase_parse(first, last,

            //  Begin grammar
            (
                double_[push_back(ref(v), _1)] % ','
            )
            ,
            //  End grammar

            space);

        if (first != last) // fail if we did not get a full match
            return false;
        return r;
    }
Exemple #5
0
bool Translator::analysisLine(QString& line,int numLine)
{
    using qi::double_;
    using boost::spirit::standard_wide::char_;
    using boost::spirit::standard_wide::space;
    using boost::spirit::standard_wide::string;

    using qi::int_;
    using qi::phrase_parse;
    using qi::lit;
    using qi::double_;
    using qi::_1;
    using qi::lexeme;


    using phoenix::push_back;
    using phoenix::ref;

    //! обнуление всех параметров
    clear();

    //! очистка внутренних структур
    std::wstring tempString=line.toStdWString();

    //quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];


//    bool r = phrase_parse(tempString.begin(),tempString.end(),
//    //  Begin grammar
//    (
//        lit("delay")>>'('>>int_[ref(sec_)=_1]>>')'>>';' |
//        lit("iMsg")>>'('>>*(char_[push_back(ref(vShowMessage),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("cMsg")>>'('>>*(char_[push_back(ref(vConsoleMessage),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("qMsg")>>'('>>*(char_[push_back(ref(vQuestionMessage),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("specialCommand")>>'('>>*(char_[push_back(ref(vSpecialCommand),_1)]-';'-')'-'('-',')>>','>>*(char_[push_back(ref(vSpecialParam),_1)]-'='-')'-'('-';'-',')>>')'>>';'|
//        lit("set")>>'('>>*(char_[push_back(ref(vSpecialCommand),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("get")>>'('>>*(char_[push_back(ref(vSpecialParam),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("loadVariant")>>'('>>*(char_[push_back(ref(vLoadVariant),_1)]-';'-')'-'(')>>')'>>';'|
//        lit("setNumSubVariant")>>'('>>int_[ref(numSubVar_)=_1]>>')'>>';' |
//        *(char_[push_back(ref(vValue1),_1)]-'='-';')>>'='>>*(char_[push_back(ref(vValue2),_1)]-'='-';')>>';' |
//        lit("/*")>>*(char_-'*'-'/')>>lit("*/")
//    ),
//    space
//    );

    bool r = phrase_parse(tempString.begin(),tempString.end(),
    //  Begin grammar
    (
        lit("var")>>*(char_[push_back(ref(vVariable),_1)]-'='-';')>>';' |
        lit("delay")>>'('>>int_[ref(sec_)=_1]>>')'>>';' |
        lit("iMsg")>>'('>>lexeme['"' >> +(char_[push_back(ref(vShowMessage),_1)] - '"') >> '"']>>')'>>';'|
        lit("cMsg")>>'('>>lexeme['"' >> +(char_[push_back(ref(vConsoleMessage),_1)] - '"') >> '"']>>')'>>';'|
        lit("qMsg")>>'('>>lexeme['"' >> +(char_[push_back(ref(vQuestionMessage),_1)] - '"') >> '"']>>')'>>';'|
        lit("specialCommand")>>'('>>*(char_[push_back(ref(vSpecialCommand),_1)]-';'-')'-'('-',')>>','>>*(char_[push_back(ref(vSpecialParam),_1)]-'='-')'-'('-';'-',')>>')'>>';'|
        lit("set")>>'('>>*(char_[push_back(ref(vSpecialCommand),_1)]-';'-')'-'(')>>')'>>';'|
        lit("get")>>'('>>*(char_[push_back(ref(vSpecialParam),_1)]-';'-')'-'(')>>')'>>';'|
        lit("loadVariant")>>'('>>*(char_[push_back(ref(vLoadVariant),_1)]-';'-')'-'(')>>')'>>';'|
        lit("setNumSubVariant")>>'('>>int_[ref(numSubVar_)=_1]>>')'>>';' |
        *(char_[push_back(ref(vValue1),_1)]-'='-';')>>'='>>*(char_[push_back(ref(vValue2),_1)]-'='-';')>>';' |
        lit("/*")>>*(char_-'*'-'/')>>lit("*/")
    ),
    space
    );

    createNodes(numLine);
    //! проверка какие узлы нужно создать
    return r;
}
geometry_grammar<Iterator, ErrorHandler>::geometry_grammar()
    : geometry_grammar::base_type(start,"geometry"),
      coordinates(error_handler)
{
    qi::lit_type lit;
    qi::int_type int_;
    qi::double_type double_;
    qi::_val_type _val;
    qi::_1_type _1;
    qi::_2_type _2;
    qi::_3_type _3;
    qi::_4_type _4;
    qi::_a_type _a;
    qi::_b_type _b;
    qi::eps_type eps;
    qi::omit_type omit;
    using qi::fail;
    using qi::on_error;
    using phoenix::push_back;

    start = geometry.alias() | lit("null");

    // generic json types
    json_.value =  json_.object | json_.array | json_.string_ | json_.number
        ;

    json_.pairs = json_.key_value % lit(',')
        ;

    json_.key_value = (json_.string_ > lit(':') > json_.value)
        ;

    json_.object = lit('{')
        > *json_.pairs
        > lit('}')
        ;
    json_.array = lit('[')
        > json_.value > *(lit(',') > json_.value)
        > lit(']')
        ;
    json_.number = json_.strict_double
        | json_.int__
        | lit("true")
        | lit ("false")
        | lit("null")
        ;
    geometry = lit('{')[_a = 0]
        > (((lit("\"type\"") > lit(':') > geometry_type_dispatch[_a = _1])
            |
            (lit("\"coordinates\"") > lit(':') > coordinates[_b = _1])
            |
            (lit("\"geometries\"") > lit(':') > lit('[') > geometry_collection[_val = _1] > lit(']'))
            |
            omit[json_.key_value]) % lit(',')) [create_geometry(_val,_a,_b)]
        > lit('}')
        ;

    geometry_collection = geometry[push_back(_val, _1)] % lit(',')
        ;
    geometry_type_dispatch.add
        ("\"Point\"",1)
        ("\"LineString\"",2)
        ("\"Polygon\"",3)
        ("\"MultiPoint\"",4)
        ("\"MultiLineString\"",5)
        ("\"MultiPolygon\"",6)
        ("\"GeometryCollection\"",7)
        ;

    // give some rules names
    geometry.name("Geometry");
    geometry_collection.name("GeometryCollection");
    geometry_type_dispatch.name("type: (Point|LineString|Polygon|MultiPoint|MultiLineString|MultiPolygon|GeometryCollection)");
    coordinates.name("coordinates");
    // error handler
    auto error_handler_function = boost::phoenix::function<ErrorHandler>(error_handler);
    on_error<fail>(start, error_handler_function(_1, _2, _3, _4));
}