File: EnumParser.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 (249 lines) | stat: -rw-r--r-- 13,969 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#include "EnumParser.h"

#include "../universe/BuildingType.h"
#include "../universe/Condition.h"
#include "../universe/Enums.h"
#include "../universe/ShipHull.h"
#include "../universe/ShipPart.h"
#include "../universe/UnlockableItem.h"
#include "../Empire/ResourcePool.h"

#include <boost/phoenix/object/dynamic_cast.hpp>
#include <boost/phoenix/operator/self.hpp>

namespace qi = boost::spirit::qi;

#define DEBUG_PARSERS 0

namespace {
    qi::_val_type _val;
}

namespace parse {
    empire_affiliation_enum_grammar::empire_affiliation_enum_grammar(const parse::lexer& tok) :
        empire_affiliation_enum_grammar::base_type(rule, "empire_affiliation_enum_grammar")
    {
        rule
            =   tok.TheEmpire_  [ _val = EmpireAffiliationType::AFFIL_SELF ]
            |   tok.EnemyOf_    [ _val = EmpireAffiliationType::AFFIL_ENEMY ]
            |   tok.PeaceWith_  [ _val = EmpireAffiliationType::AFFIL_PEACE ]
            |   tok.AllyOf_     [ _val = EmpireAffiliationType::AFFIL_ALLY ]
            |   tok.AnyEmpire_  [ _val = EmpireAffiliationType::AFFIL_ANY ]
            |   tok.None_       [ _val = EmpireAffiliationType::AFFIL_NONE ]
            |   tok.CanSee_     [ _val = EmpireAffiliationType::AFFIL_CAN_SEE ]
            |   tok.Human_      [ _val = EmpireAffiliationType::AFFIL_HUMAN ]
        ;
    }

    unlockable_item_enum_grammar::unlockable_item_enum_grammar(const parse::lexer& tok) :
        unlockable_item_enum_grammar::base_type(rule, "unlockable_item_enum_grammar")
    {
        rule
            =   tok.Building_           [ _val = UnlockableItemType::UIT_BUILDING ]
            |   tok.ShipPart_           [ _val = UnlockableItemType::UIT_SHIP_PART ]
            |   tok.ShipHull_           [ _val = UnlockableItemType::UIT_SHIP_HULL ]
            |   tok.ShipDesign_         [ _val = UnlockableItemType::UIT_SHIP_DESIGN ]
            |   tok.Tech_               [ _val = UnlockableItemType::UIT_TECH ]
            |   tok.Policy_             [ _val = UnlockableItemType::UIT_POLICY ]
        ;
    }

    give_empire_unlockable_item_enum_grammar::give_empire_unlockable_item_enum_grammar(const parse::lexer& tok) :
        give_empire_unlockable_item_enum_grammar::base_type(rule, "give_empire_unlockable_item_enum_grammar")
    {
        rule
            =   tok.UnlockBuildingType_ [ _val = UnlockableItemType::UIT_BUILDING ]
            |   tok.UnlockShipPart_     [ _val = UnlockableItemType::UIT_SHIP_PART ]
            |   tok.UnlockShipHull_     [ _val = UnlockableItemType::UIT_SHIP_HULL ]
            |   tok.GiveEmpireTech_     [ _val = UnlockableItemType::UIT_TECH ]
            |   tok.UnlockPolicy_       [ _val = UnlockableItemType::UIT_POLICY ]
        ;
    }

    ship_slot_enum_grammar::ship_slot_enum_grammar(const parse::lexer& tok) :
        ship_slot_enum_grammar::base_type(rule, "ship_slot_enum_grammar")
    {
        rule
            =   tok.External_   [ _val = ShipSlotType::SL_EXTERNAL ]
            |   tok.Internal_   [ _val = ShipSlotType::SL_INTERNAL ]
            |   tok.Core_       [ _val = ShipSlotType::SL_CORE ]
        ;
    }

    ship_part_class_enum_grammar::ship_part_class_enum_grammar(const parse::lexer& tok) :
        ship_part_class_enum_grammar::base_type(rule, "ship_part_class_enum_grammar")
    {
        rule
            =   tok.ShortRange_         [ _val = ShipPartClass::PC_DIRECT_WEAPON ]
            |   tok.FighterBay_         [ _val = ShipPartClass::PC_FIGHTER_BAY ]
            |   tok.FighterHangar_      [ _val = ShipPartClass::PC_FIGHTER_HANGAR ]
            |   tok.Shield_             [ _val = ShipPartClass::PC_SHIELD ]
            |   tok.Armour_             [ _val = ShipPartClass::PC_ARMOUR ]
            |   tok.Troops_             [ _val = ShipPartClass::PC_TROOPS ]
            |   tok.Detection_          [ _val = ShipPartClass::PC_DETECTION ]
            |   tok.Stealth_            [ _val = ShipPartClass::PC_STEALTH ]
            |   tok.Fuel_               [ _val = ShipPartClass::PC_FUEL ]
            |   tok.Colony_             [ _val = ShipPartClass::PC_COLONY ]
            |   tok.Speed_              [ _val = ShipPartClass::PC_SPEED ]
            |   tok.General_            [ _val = ShipPartClass::PC_GENERAL ]
            |   tok.Bombard_            [ _val = ShipPartClass::PC_BOMBARD ]
            |   tok.Research_           [ _val = ShipPartClass::PC_RESEARCH ]
            |   tok.Industry_           [ _val = ShipPartClass::PC_INDUSTRY ]
            |   tok.Influence_          [ _val = ShipPartClass::PC_INFLUENCE ]
            |   tok.ProductionLocation_ [ _val = ShipPartClass::PC_PRODUCTION_LOCATION ]
        ;
    }

    capture_result_enum_grammar::capture_result_enum_grammar(const parse::lexer& tok) :
        capture_result_enum_grammar::base_type(rule, "capture_result_enum_grammar")
    {
        rule
            =   tok.Capture_            [ _val = CaptureResult::CR_CAPTURE ]
            |   tok.Retain_             [ _val = CaptureResult::CR_RETAIN ]
            |   tok.Destroy_            [ _val = CaptureResult::CR_DESTROY ]
        ;
    }

    statistic_enum_grammar::statistic_enum_grammar(const parse::lexer& tok) :
        statistic_enum_grammar::base_type(rule, "statistic_enum_grammar")
    {
        rule
            =   tok.CountUnique_    [ _val = ValueRef::StatisticType::UNIQUE_COUNT ]
            |   tok.If_             [ _val = ValueRef::StatisticType::IF ]
            |   tok.Count_          [ _val = ValueRef::StatisticType::COUNT ]
            |   tok.HistogramMax_   [ _val = ValueRef::StatisticType::HISTO_MAX ]
            |   tok.HistogramMin_   [ _val = ValueRef::StatisticType::HISTO_MIN ]
            |   tok.HistogramSpread_[ _val = ValueRef::StatisticType::HISTO_SPREAD ]
            |   tok.Sum_            [ _val = ValueRef::StatisticType::SUM ]
            |   tok.Mean_           [ _val = ValueRef::StatisticType::MEAN ]
            |   tok.RMS_            [ _val = ValueRef::StatisticType::RMS ]
            |   tok.Mode_           [ _val = ValueRef::StatisticType::MODE ]
            |   tok.Max_            [ _val = ValueRef::StatisticType::MAX ]
            |   tok.Min_            [ _val = ValueRef::StatisticType::MIN ]
            |   tok.Spread_         [ _val = ValueRef::StatisticType::SPREAD ]
            |   tok.StDev_          [ _val = ValueRef::StatisticType::STDEV ]
            |   tok.Product_        [ _val = ValueRef::StatisticType::PRODUCT ]
        ;
    }

    resource_type_grammar::resource_type_grammar(const parse::lexer& tok) :
        resource_type_grammar::base_type(rule, "resource_type_enum_grammar")
    {
        rule
            =   tok.Research_       [ _val = ResourceType::RE_RESEARCH ]
            |   tok.Industry_       [ _val = ResourceType::RE_INDUSTRY ]
            |   tok.Influence_      [ _val = ResourceType::RE_INFLUENCE ]
        ;
    }

    non_ship_part_meter_enum_grammar::non_ship_part_meter_enum_grammar(const parse::lexer& tok) :
        non_ship_part_meter_enum_grammar::base_type(rule, "non_ship_part_meter_enum_grammar")
    {
        rule
            =   tok.TargetConstruction_     [ _val = MeterType::METER_TARGET_CONSTRUCTION ]
            |   tok.TargetIndustry_         [ _val = MeterType::METER_TARGET_INDUSTRY ]
            |   tok.TargetPopulation_       [ _val = MeterType::METER_TARGET_POPULATION ]
            |   tok.TargetResearch_         [ _val = MeterType::METER_TARGET_RESEARCH ]
            |   tok.TargetInfluence_        [ _val = MeterType::METER_TARGET_INFLUENCE ]
            |   tok.TargetHappiness_        [ _val = MeterType::METER_TARGET_HAPPINESS ]
            |   tok.MaxDefense_             [ _val = MeterType::METER_MAX_DEFENSE ]
            |   tok.MaxFuel_                [ _val = MeterType::METER_MAX_FUEL ]
            |   tok.MaxShield_              [ _val = MeterType::METER_MAX_SHIELD ]
            |   tok.MaxStructure_           [ _val = MeterType::METER_MAX_STRUCTURE ]
            |   tok.MaxTroops_              [ _val = MeterType::METER_MAX_TROOPS ]
            |   tok.MaxSupply_              [ _val = MeterType::METER_MAX_SUPPLY ]
            |   tok.MaxStockpile_           [ _val = MeterType::METER_MAX_STOCKPILE ]

            |   tok.Construction_           [ _val = MeterType::METER_CONSTRUCTION ]
            |   tok.Industry_               [ _val = MeterType::METER_INDUSTRY ]
            |   tok.Population_             [ _val = MeterType::METER_POPULATION ]
            |   tok.Research_               [ _val = MeterType::METER_RESEARCH ]
            |   tok.Influence_              [ _val = MeterType::METER_INFLUENCE ]
            |   tok.Happiness_              [ _val = MeterType::METER_HAPPINESS ]

            |   tok.Defense_                [ _val = MeterType::METER_DEFENSE ]
            |   tok.Fuel_                   [ _val = MeterType::METER_FUEL ]
            |   tok.Shield_                 [ _val = MeterType::METER_SHIELD ]
            |   tok.Structure_              [ _val = MeterType::METER_STRUCTURE ]
            |   tok.Troops_                 [ _val = MeterType::METER_TROOPS ]
            |   tok.Supply_                 [ _val = MeterType::METER_SUPPLY ]
            |   tok.Stockpile_              [ _val = MeterType::METER_STOCKPILE ]

            |   tok.RebelTroops_            [ _val = MeterType::METER_REBEL_TROOPS ]
            |   tok.Stealth_                [ _val = MeterType::METER_STEALTH ]
            |   tok.Detection_              [ _val = MeterType::METER_DETECTION ]
            |   tok.Speed_                  [ _val = MeterType::METER_SPEED ]

            |   tok.Size_                   [ _val = MeterType::METER_SIZE ]
        ;
    }

    ship_part_meter_enum_grammar::ship_part_meter_enum_grammar(const parse::lexer& tok) :
        ship_part_meter_enum_grammar::base_type(rule, "ship_part_meter_enum_grammar")
    {
        rule
            =   tok.MaxCapacity_            [ _val = MeterType::METER_MAX_CAPACITY ]
            |   tok.MaxDamage_              [ _val = MeterType::METER_MAX_CAPACITY ]
            |   tok.Capacity_               [ _val = MeterType::METER_CAPACITY ]
            |   tok.Damage_                 [ _val = MeterType::METER_CAPACITY ]
            |   tok.SecondaryStat_          [ _val = MeterType::METER_SECONDARY_STAT ]
            |   tok.MaxSecondaryStat_       [ _val = MeterType::METER_MAX_SECONDARY_STAT ]
        ;
    }

    set_non_ship_part_meter_enum_grammar::set_non_ship_part_meter_enum_grammar(const parse::lexer& tok) :
        set_non_ship_part_meter_enum_grammar::base_type(rule, "set_non_ship_part_meter_enum_grammar")
    {
        rule
            =   tok.SetTargetConstruction_  [ _val = MeterType::METER_TARGET_CONSTRUCTION ]
            |   tok.SetTargetIndustry_      [ _val = MeterType::METER_TARGET_INDUSTRY ]
            |   tok.SetTargetPopulation_    [ _val = MeterType::METER_TARGET_POPULATION ]
            |   tok.SetTargetResearch_      [ _val = MeterType::METER_TARGET_RESEARCH ]
            |   tok.SetTargetInfluence_     [ _val = MeterType::METER_TARGET_INFLUENCE ]
            |   tok.SetTargetHappiness_     [ _val = MeterType::METER_TARGET_HAPPINESS ]

            |   tok.SetMaxDefense_          [ _val = MeterType::METER_MAX_DEFENSE ]
            |   tok.SetMaxFuel_             [ _val = MeterType::METER_MAX_FUEL ]
            |   tok.SetMaxShield_           [ _val = MeterType::METER_MAX_SHIELD ]
            |   tok.SetMaxStructure_        [ _val = MeterType::METER_MAX_STRUCTURE ]
            |   tok.SetMaxTroops_           [ _val = MeterType::METER_MAX_TROOPS ]
            |   tok.SetMaxSupply_           [ _val = MeterType::METER_MAX_SUPPLY ]
            |   tok.SetMaxStockpile_        [ _val = MeterType::METER_MAX_STOCKPILE ]

            |   tok.SetConstruction_        [ _val = MeterType::METER_CONSTRUCTION ]
            |   tok.SetIndustry_            [ _val = MeterType::METER_INDUSTRY ]
            |   tok.SetPopulation_          [ _val = MeterType::METER_POPULATION ]
            |   tok.SetResearch_            [ _val = MeterType::METER_RESEARCH ]
            |   tok.SetInfluence_           [ _val = MeterType::METER_INFLUENCE ]
            |   tok.SetHappiness_           [ _val = MeterType::METER_HAPPINESS ]

            |   tok.SetDefense_             [ _val = MeterType::METER_DEFENSE ]
            |   tok.SetFuel_                [ _val = MeterType::METER_FUEL ]
            |   tok.SetShield_              [ _val = MeterType::METER_SHIELD ]
            |   tok.SetStructure_           [ _val = MeterType::METER_STRUCTURE ]
            |   tok.SetTroops_              [ _val = MeterType::METER_TROOPS ]
            |   tok.SetSupply_              [ _val = MeterType::METER_SUPPLY ]
            |   tok.SetStockpile_           [ _val = MeterType::METER_STOCKPILE ]

            |   tok.SetRebelTroops_         [ _val = MeterType::METER_REBEL_TROOPS ]
            |   tok.SetStealth_             [ _val = MeterType::METER_STEALTH ]
            |   tok.SetDetection_           [ _val = MeterType::METER_DETECTION ]
            |   tok.SetSpeed_               [ _val = MeterType::METER_SPEED ]

            |   tok.SetSize_                [ _val = MeterType::METER_SIZE ]
        ;
    }

    set_ship_part_meter_enum_grammar::set_ship_part_meter_enum_grammar(const parse::lexer& tok) :
        set_ship_part_meter_enum_grammar::base_type(rule, "set_ship_part_meter_enum_grammar")
    {
        rule
            =   tok.SetMaxCapacity_         [ _val = MeterType::METER_MAX_CAPACITY ]
            |   tok.SetMaxDamage_           [ _val = MeterType::METER_MAX_CAPACITY ]
            |   tok.SetMaxSecondaryStat_    [ _val = MeterType::METER_MAX_SECONDARY_STAT ]
            |   tok.SetCapacity_            [ _val = MeterType::METER_CAPACITY ]
            |   tok.SetDamage_              [ _val = MeterType::METER_CAPACITY ]
            |   tok.SetSecondaryStat_       [ _val = MeterType::METER_SECONDARY_STAT ]
        ;
    }
}