File: ConditionParser4.cpp

package info (click to toggle)
freeorion 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 194,940 kB
  • sloc: cpp: 186,508; python: 40,969; ansic: 1,164; xml: 719; makefile: 32; sh: 7
file content (116 lines) | stat: -rw-r--r-- 4,006 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include "ConditionParser4.h"

#include "../universe/Conditions.h"
#include "../universe/ValueRef.h"

#include <boost/phoenix.hpp>

namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;

#if DEBUG_CONDITION_PARSERS
namespace std {
    inline ostream& operator<<(ostream& os, const std::vector<condition_payload>&) { return os; }
}
#endif

namespace parse { namespace detail {
    condition_parser_rules_4::condition_parser_rules_4(
        const parse::lexer& tok,
        Labeller& label,
        const condition_parser_grammar& condition_parser,
        const value_ref_grammar<std::string>& string_grammar
    ) :
        condition_parser_rules_4::base_type(start, "condition_parser_rules_4"),
        int_rules(tok, label, condition_parser, string_grammar),
        double_rules(tok, label, condition_parser, string_grammar),
        non_ship_part_meter_type_enum(tok),
        ship_part_meter_type_enum(tok)
    {
        qi::_1_type _1;
        qi::_2_type _2;
        qi::_3_type _3;
        qi::_4_type _4;
        qi::_val_type _val;
        qi::eps_type eps;
        qi::_pass_type _pass;
        qi::omit_type omit_;
        const boost::phoenix::function<construct_movable> construct_movable_;
        const boost::phoenix::function<deconstruct_movable> deconstruct_movable_;
        using phoenix::new_;
        using phoenix::construct;

        meter_value
            =   (
                non_ship_part_meter_type_enum
                >  -(label(tok.low_)  > double_rules.expr)
                >  -(label(tok.high_) > double_rules.expr)
            ) [ _val = construct_movable_(new_<Condition::MeterValue>(
                _1,
                deconstruct_movable_(_2, _pass),
                deconstruct_movable_(_3, _pass))) ]
            ;

        ship_part_meter_value
            =   (
                omit_[tok.ShipPartMeter_]
                >   label(tok.part_)    >   string_grammar
                >   label(tok.meter_)   >   ship_part_meter_type_enum
                >  -(label(tok.low_)    >   double_rules.expr)
                >  -(label(tok.high_)   >   double_rules.expr)
            ) [ _val = construct_movable_(new_<Condition::ShipPartMeterValue>(
                deconstruct_movable_(_1, _pass),
                _2,
                deconstruct_movable_(_3, _pass),
                deconstruct_movable_(_4, _pass))) ]
            ;

        empire_meter_value1
            =   (
                (omit_[tok.EmpireMeter_]
                >>  label(tok.empire_))  >   int_rules.expr
                >   label(tok.meter_)    >   tok.string
                >  -(label(tok.low_)     >   double_rules.expr)
                >  -(label(tok.high_)    >   double_rules.expr)
            ) [ _val = construct_movable_(new_<Condition::EmpireMeterValue>(
                deconstruct_movable_(_1, _pass),
                _2,
                deconstruct_movable_(_3, _pass),
                deconstruct_movable_(_4, _pass))) ]
            ;

        empire_meter_value2
            =   (
                (omit_[tok.EmpireMeter_]
                >>   label(tok.meter_))  >   tok.string
                >  -(label(tok.low_)     >   double_rules.expr)
                >  -(label(tok.high_)    >   double_rules.expr)
            ) [ _val = construct_movable_(new_<Condition::EmpireMeterValue>(
                _1,
                deconstruct_movable_(_2, _pass),
                deconstruct_movable_(_3, _pass))) ]
            ;

        empire_meter_value
            %=  empire_meter_value1
            |   empire_meter_value2
            ;

        start
            %=  meter_value
            |   ship_part_meter_value
            |   empire_meter_value
            ;

        meter_value.name("MeterValue");
        ship_part_meter_value.name("ShipPartMeterValue");
        empire_meter_value.name("EmpireMeterValue");

#if DEBUG_CONDITION_PARSERS
        debug(meter_value);
        debug(ship_part_meter_value);
        debug(empire_meter_value);
#endif
    }

} }