From: <tz...@us...> - 2011-11-07 04:22:17
|
Revision: 4477 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4477&view=rev Author: tzlaine Date: 2011-11-07 04:22:10 +0000 (Mon, 07 Nov 2011) Log Message: ----------- Broke up most of the file parsers into smaller rules to prevent bumping up against MSVC compiler limits. Modified Paths: -------------- trunk/FreeOrion/parse/BuildingsParser.cpp trunk/FreeOrion/parse/ShipDesignsParser.cpp trunk/FreeOrion/parse/ShipHullsParser.cpp trunk/FreeOrion/parse/ShipPartsParser.cpp trunk/FreeOrion/parse/SpecialsParser.cpp trunk/FreeOrion/parse/SpeciesParser.cpp trunk/FreeOrion/parse/TechsParser.cpp Modified: trunk/FreeOrion/parse/BuildingsParser.cpp =================================================================== --- trunk/FreeOrion/parse/BuildingsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/BuildingsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,5 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 - #include "Double.h" #include "Int.h" #include "Label.h" @@ -54,21 +52,32 @@ qi::_g_type _g; qi::_h_type _h; qi::_r1_type _r1; + qi::_r2_type _r2; qi::_val_type _val; qi::eps_type eps; using phoenix::new_; + building_prefix + = tok.BuildingType_ + > parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] + ; + + cost + = parse::label(BuildCost_name) > parse::double_ [ _r1 = _1 ] + > parse::label(BuildTime_name) > parse::int_ [ _r2 = _1 ] + ; + + producible + = tok.Unproducible_ [ _val = false ] + | tok.Producible_ [ _val = true ] + | eps [ _val = true ] + ; + building_type - = tok.BuildingType_ - > parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] - > parse::label(BuildCost_name) > parse::double_ [ _c = _1 ] - > parse::label(BuildTime_name) > parse::int_ [ _d = _1 ] - > ( - tok.Unproducible_ [ _e = false ] - | tok.Producible_ [ _e = true ] - | eps [ _e = true ] - ) + = building_prefix(_a, _b) + > cost(_c, _d) + > producible [ _e = _1 ] > parse::label(Location_name) > parse::detail::condition_parser [ _f = _1 ] > ( parse::label(CaptureResult_name) >> parse::enum_parser<CaptureResult>() [ _g = _1 ] @@ -82,9 +91,15 @@ = +building_type(_r1) ; + building_prefix.name("BuildingType"); + cost.name("cost"); + producible.name("Producible or Unproducible"); building_type.name("BuildingType"); #if DEBUG_PARSERS + debug(building_prefix); + debug(cost); + debug(producible); debug(building_type); #endif @@ -93,6 +108,24 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::string&, std::string&), + parse::skipper_type + > building_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (double&, int&), + parse::skipper_type + > cost_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + bool (), + parse::skipper_type + > producible_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, BuildingType*>&), qi::locals< std::string, @@ -113,6 +146,9 @@ parse::skipper_type > start_rule; + building_prefix_rule building_prefix; + cost_rule cost; + producible_rule producible; building_type_rule building_type; start_rule start; }; Modified: trunk/FreeOrion/parse/ShipDesignsParser.cpp =================================================================== --- trunk/FreeOrion/parse/ShipDesignsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/ShipDesignsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,5 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 - #include "ParseImpl.h" #include "Label.h" @@ -48,14 +46,20 @@ qi::_d_type _d; qi::_e_type _e; qi::_r1_type _r1; + qi::_r2_type _r2; + qi::_r3_type _r3; using phoenix::new_; using phoenix::push_back; + design_prefix + = tok.ShipDesign_ + > parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] + > parse::label(Hull_name) > tok.string [ _r3 = _1 ] + ; + design - = tok.ShipDesign_ - > parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] - > parse::label(Hull_name) > tok.string [ _c = _1 ] + = design_prefix(_a, _b, _c) > parse::label(Parts_name) > ( '[' > +tok.string [ push_back(_d, _1) ] > ']' @@ -69,9 +73,11 @@ = +design(_r1) ; + design_prefix.name("ShipDesign"); design.name("ShipDesign"); #if DEBUG_PARSERS + debug(design_prefix); debug(design); #endif @@ -80,6 +86,12 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::string&, std::string&, std::string&), + parse::skipper_type + > design_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, ShipDesign*>&), qi::locals< std::string, @@ -97,6 +109,7 @@ parse::skipper_type > start_rule; + design_prefix_rule design_prefix; design_rule design; start_rule start; }; Modified: trunk/FreeOrion/parse/ShipHullsParser.cpp =================================================================== --- trunk/FreeOrion/parse/ShipHullsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/ShipHullsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,4 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 #define PHOENIX_LIMIT 11 #include "Double.h" @@ -60,6 +59,7 @@ qi::_h_type _h; qi::_i_type _i; qi::_r1_type _r1; + qi::_r2_type _r2; qi::_val_type _val; qi::eps_type eps; qi::lit_type lit; @@ -67,17 +67,17 @@ using phoenix::new_; using phoenix::push_back; - slot - = tok.Slot_ - > parse::label(Type_name) > parse::enum_parser<ShipSlotType>() [ _a = _1 ] - > parse::label(Position_name) - > '(' - > parse::double_ [ _b = _1 ] - > ',' - > parse::double_ [ _c = _1 ] - > lit(')') [ _val = construct<HullType::Slot>(_a, _b, _c) ] + hull_prefix + = tok.Hull_ + > parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] ; + cost + = parse::label(BuildCost_name) > parse::double_ [ _r1 = _1 ] + > parse::label(BuildTime_name) > parse::int_ [ _r2 = _1 ] + ; + hull_stats = parse::label(Speed_name) > parse::double_ [ _a = _1 ] > parse::label(StarlaneSpeed_name) > parse::double_ [ _b = _1 ] @@ -86,30 +86,41 @@ > parse::label(Structure_name) > parse::double_ [ _val = construct<HullTypeStats>(_a, _b, _c, _d, _1) ] ; + producible + = tok.Unproducible_ [ _val = false ] + | tok.Producible_ [ _val = true ] + | eps [ _val = true ] + ; + + slot + = tok.Slot_ + > parse::label(Type_name) > parse::enum_parser<ShipSlotType>() [ _a = _1 ] + > parse::label(Position_name) + > '(' > parse::double_ [ _b = _1 ] > ',' > parse::double_ [ _c = _1 ] > lit(')') + [ _val = construct<HullType::Slot>(_a, _b, _c) ] + ; + + slots + = parse::label(Slots_name) + >> ( + '[' > +slot [ push_back(_r1, _1) ] > ']' + | slot [ push_back(_r1, _1) ] + ) + ; + + location + = parse::label(Location_name) >> parse::detail::condition_parser [ _r1 = _1 ] + | eps [ _r1 = new_<Condition::All>() ] + ; + hull - = tok.Hull_ - > parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] + = hull_prefix(_a, _b) > hull_stats [ _c = _1 ] - > parse::label(BuildCost_name) > parse::double_ [ _d = _1 ] - > parse::label(BuildTime_name) > parse::int_ [ _e = _1 ] - > ( - tok.Unproducible_ [ _f = false ] - | tok.Producible_ [ _f = true ] - | eps [ _f = true ] - ) + > cost(_d, _e) + > producible [ _f = _1 ] + > -slots(_g) + > location(_h) > -( - parse::label(Slots_name) - >> ( - '[' > +slot [ push_back(_g, _1) ] > ']' - | slot [ push_back(_g, _1) ] - ) - ) - > ( - parse::label(Location_name) >> parse::detail::condition_parser [ _h = _1 ] - | eps [ _h = new_<Condition::All>() ] - ) - > -( parse::label(EffectsGroups_name) >> parse::detail::effects_group_parser() [ _i = _1 ] ) > parse::label(Graphic_name) > tok.string [ insert(_r1, new_<HullType>(_a, _b, _c, _d, _e, _f, _g, _h, _i, _1)) ] @@ -119,13 +130,23 @@ = +hull(_r1) ; + hull_prefix.name("Hull"); + cost.name("build cost"); + hull_stats.name("Hull stats"); + producible.name("Producible or Unproducible"); slot.name("Slot"); - hull_stats.name("Hull stats"); + slots.name("Slots"); + location.name("Location"); hull.name("Hull"); #if DEBUG_PARSERS + debug(hull_prefix); + debug(cost); + debug(hull_stats); + debug(producible); debug(slot); - debug(hull_stats); + debug(slots); + debug(location); debug(hull); #endif @@ -134,17 +155,18 @@ typedef boost::spirit::qi::rule< parse::token_iterator, - HullType::Slot (), - qi::locals< - ShipSlotType, - double, - double - >, + void (std::string&, std::string&), parse::skipper_type - > slot_rule; + > hull_prefix_rule; typedef boost::spirit::qi::rule< parse::token_iterator, + void (double&, int&), + parse::skipper_type + > cost_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, HullTypeStats (), qi::locals< double, @@ -157,6 +179,35 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + bool (), + parse::skipper_type + > producible_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + HullType::Slot (), + qi::locals< + ShipSlotType, + double, + double + >, + parse::skipper_type + > slot_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (std::vector<HullType::Slot>&), + parse::skipper_type + > slots_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (Condition::ConditionBase*&), + parse::skipper_type + > location_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, HullType*>&), qi::locals< std::string, @@ -178,8 +229,13 @@ parse::skipper_type > start_rule; + hull_prefix_rule hull_prefix; + cost_rule cost; + hull_stats_rule hull_stats; + producible_rule producible; slot_rule slot; - hull_stats_rule hull_stats; + slots_rule slots; + location_rule location; hull_rule hull; start_rule start; }; Modified: trunk/FreeOrion/parse/ShipPartsParser.cpp =================================================================== --- trunk/FreeOrion/parse/ShipPartsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/ShipPartsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,4 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 #define PHOENIX_LIMIT 11 #include "Double.h" @@ -59,58 +58,88 @@ qi::_i_type _i; qi::_j_type _j; qi::_r1_type _r1; + qi::_r2_type _r2; + qi::_r3_type _r3; + qi::_r4_type _r4; + qi::_r5_type _r5; qi::_val_type _val; qi::eps_type eps; using phoenix::construct; using phoenix::new_; using phoenix::push_back; + fighter_stats_prefix + = parse::label(Type_name) >> parse::enum_parser<CombatFighterType>() [ _r1 = _1 ] + > parse::label(AntiShipDamage_name) > parse::double_ [ _r2 = _1 ] + > parse::label(AntiFighterDamage_name) > parse::double_ [ _r3 = _1 ] + > parse::label(LaunchRate_name) > parse::double_ [ _r4 = _1 ] + > parse::label(FighterWeaponRange_name) > parse::double_ [ _r5 = _1 ] + ; + + fighter_stats + = fighter_stats_prefix(_a, _b, _c, _d, _e) + > parse::label(Speed_name) > parse::double_ [ _f = _1 ] + > parse::label(Stealth_name) > parse::double_ [ _g = _1 ] + > parse::label(Structure_name) > parse::double_ [ _h = _1 ] + > parse::label(Detection_name) > parse::double_ [ _i = _1 ] + > parse::label(Capacity_name) > parse::int_ [ _val = construct<FighterStats>(_a, _b, _c, _d, _e, _f, _g, _h, _i, _1) ] + ; + + lr_df_stats_prefix + = parse::label(Damage_name) >> parse::double_ [ _r1 = _1 ] + > parse::label(ROF_name) > parse::double_ [ _r2 = _1 ] + > parse::label(Range_name) > parse::double_ [ _r3 = _1 ] + ; + + lr_df_stats + = lr_df_stats_prefix(_b, _c, _d) + >> ( + parse::label(Speed_name) >> parse::double_ [ _e = _1 ] + > parse::label(Stealth_name) > parse::double_ [ _f = _1 ] + > parse::label(Structure_name) > parse::double_ [ _g = _1 ] + > parse::label(Capacity_name) > parse::int_ [ _val = construct<LRStats>(_b, _c, _d, _e, _f, _g, _1) ] + | eps [ _val = construct<DirectFireStats>(_b, _c, _d) ] + ) + ; + part_stats - = ( - parse::label(Type_name) >> parse::enum_parser<CombatFighterType>() [ _a = _1 ] - > parse::label(AntiShipDamage_name) > parse::double_ [ _b = _1 ] - > parse::label(AntiFighterDamage_name) > parse::double_ [ _c = _1 ] - > parse::label(LaunchRate_name) > parse::double_ [ _d = _1 ] - > parse::label(FighterWeaponRange_name) > parse::double_ [ _e = _1 ] - > parse::label(Speed_name) > parse::double_ [ _f = _1 ] - > parse::label(Stealth_name) > parse::double_ [ _g = _1 ] - > parse::label(Structure_name) > parse::double_ [ _h = _1 ] - > parse::label(Detection_name) > parse::double_ [ _i = _1 ] - > parse::label(Capacity_name) > parse::int_ [ _val = construct<FighterStats>(_a, _b, _c, _d, _e, _f, _g, _h, _i, _1) ] - ) - | ( - parse::label(Damage_name) >> parse::double_ [ _b = _1 ] - > parse::label(ROF_name) > parse::double_ [ _c = _1 ] - > parse::label(Range_name) > parse::double_ [ _d = _1 ] - >> ( - parse::label(Speed_name) >> parse::double_ [ _e = _1 ] - > parse::label(Stealth_name) > parse::double_ [ _f = _1 ] - > parse::label(Structure_name) > parse::double_ [ _g = _1 ] - > parse::label(Capacity_name) > parse::int_ [ _val = construct<LRStats>(_b, _c, _d, _e, _f, _g, _1) ] - | eps [ _val = construct<DirectFireStats>(_b, _c, _d) ] - ) - ) + = fighter_stats [ _val = _1 ] + | lr_df_stats [ _val = _1 ] | parse::label(Capacity_name) > parse::double_ [ _val = _1 ] ; - part_type + part_type_prefix = tok.Part_ - > parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] - > parse::label(Class_name) > parse::enum_parser<ShipPartClass>() [ _c = _1 ] - >> part_stats [ _d = _1 ] - > parse::label(BuildCost_name) > parse::double_ [ _e = _1 ] - > parse::label(BuildTime_name) > parse::int_ [ _f = _1 ] + > parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] + > parse::label(Class_name) > parse::enum_parser<ShipPartClass>() [ _r3 = _1 ] + ; + + cost + = parse::label(BuildCost_name) > parse::double_ [ _r1 = _1 ] + > parse::label(BuildTime_name) > parse::int_ [ _r2 = _1 ] + ; + + producible + = tok.Unproducible_ [ _val = false ] + | tok.Producible_ [ _val = true ] + | eps [ _val = true ] + ; + + slots + = parse::label(MountableSlotTypes_name) >> ( - tok.Unproducible_ [ _g = false ] - | tok.Producible_ [ _g = true ] - | eps [ _g = true ] + '[' > +parse::enum_parser<ShipSlotType>() [ push_back(_r1, _1) ] > ']' + | parse::enum_parser<ShipSlotType>() [ push_back(_r1, _1) ] ) - > parse::label(MountableSlotTypes_name) - >> ( - '[' > +parse::enum_parser<ShipSlotType>() [ push_back(_h, _1) ] > ']' - | parse::enum_parser<ShipSlotType>() [ push_back(_h, _1) ] - ) + ; + + part_type + = part_type_prefix(_a, _b, _c) + >> part_stats [ _d = _1 ] + > cost(_e, _f) + >> producible [ _g = _1 ] + > slots(_h) > parse::label(Location_name) > parse::detail::condition_parser [ _i = _1 ] >> -( parse::label(EffectsGroups_name) @@ -123,11 +152,27 @@ = +part_type(_r1) ; + fighter_stats_prefix.name("fighter stats"); + fighter_stats.name("fighter stats"); + lr_df_stats_prefix.name("LR or DF stats"); + lr_df_stats.name("LR or DF stats"); part_stats.name("Part stats"); + part_type_prefix.name("Part"); + cost.name("cost"); + producible.name("Producible or Unproducible"); + slots.name("mountable slot types"); part_type.name("Part"); #if DEBUG_PARSERS + debug(fighter_stats_prefix); + debug(fighter_stats); + debug(lr_df_stats_prefix); + debug(lr_df_stats); debug(part_stats); + debug(part_type_prefix); + debug(cost); + debug(producible); + debug(slots); debug(part_type); #endif @@ -136,6 +181,18 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (CombatFighterType&, double&, double&, double&, double&), + parse::skipper_type + > fighter_stats_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (double&, double&, double&), + parse::skipper_type + > lr_df_stats_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, PartTypeStats (), qi::locals< CombatFighterType, @@ -153,6 +210,30 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::string&, std::string&, ShipPartClass&), + parse::skipper_type + > part_type_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (double&, int&), + parse::skipper_type + > cost_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + bool (), + parse::skipper_type + > producible_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (std::vector<ShipSlotType>&), + parse::skipper_type + > slots_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, PartType*>&), qi::locals< std::string, @@ -175,7 +256,15 @@ parse::skipper_type > start_rule; + fighter_stats_prefix_rule fighter_stats_prefix; + part_stats_rule fighter_stats; + lr_df_stats_prefix_rule lr_df_stats_prefix; + part_stats_rule lr_df_stats; part_stats_rule part_stats; + part_type_prefix_rule part_type_prefix; + cost_rule cost; + producible_rule producible; + slots_rule slots; part_type_rule part_type; start_rule start; }; Modified: trunk/FreeOrion/parse/SpecialsParser.cpp =================================================================== --- trunk/FreeOrion/parse/SpecialsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/SpecialsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,5 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 - #include "Double.h" #include "Int.h" #include "Label.h" @@ -53,22 +51,31 @@ qi::_f_type _f; qi::_g_type _g; qi::_r1_type _r1; + qi::_r2_type _r2; qi::_val_type _val; qi::eps_type eps; using phoenix::new_; - special + special_prefix = tok.Special_ - > parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] - > ( - parse::label(SpawnRate_name) >> parse::double_ [ _c = _1 ] - | eps [ _c = 1.0 ] + > parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] + ; + + spawn + = ( + parse::label(SpawnRate_name) >> parse::double_ [ _r1 = _1 ] + | eps [ _r1 = 1.0 ] ) > ( - parse::label(SpawnLimit_name) >> parse::int_ [ _d = _1 ] - | eps [ _d = 9999 ] + parse::label(SpawnLimit_name) >> parse::int_ [ _r2 = _1 ] + | eps [ _r2 = 9999 ] ) + ; + + special + = special_prefix(_a, _b) + > spawn(_c, _d) > -( parse::label(Location_name) >> parse::detail::condition_parser [ _e = _1 ] ) @@ -82,9 +89,13 @@ = +special(_r1) ; + special_prefix.name("Special"); special.name("Special"); + spawn.name("SpawnRate and SpawnLimit"); #if DEBUG_PARSERS + debug(special_prefix); + debug(spawn); debug(special); #endif @@ -93,6 +104,18 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::string&, std::string&), + parse::skipper_type + > special_prefix_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (double&, int&), + parse::skipper_type + > spawn_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, Special*>&), qi::locals< std::string, @@ -111,6 +134,9 @@ parse::skipper_type > start_rule; + + special_prefix_rule special_prefix; + spawn_rule spawn; special_rule special; start_rule start; }; Modified: trunk/FreeOrion/parse/SpeciesParser.cpp =================================================================== --- trunk/FreeOrion/parse/SpeciesParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/SpeciesParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,5 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 - #include "ParseImpl.h" #include "Label.h" #include "../universe/Species.h" @@ -71,6 +69,18 @@ > parse::label(Graphic_name) > tok.string [ _val = construct<FocusType>(_a, _b, _c, _1) ] ; + foci + = parse::label(Foci_name) + >> ( + '[' > +focus_type [ push_back(_r1, _1) ] > ']' + | focus_type [ push_back(_r1, _1) ] + ) + ; + + effects + = parse::label(EffectsGroups_name) >> parse::detail::effects_group_parser() [ _r1 = _1 ] + ; + environment_map_element = parse::label(Type_name) >> parse::enum_parser<PlanetType>() [ _a = _1 ] > parse::label(Environment_name) > parse::enum_parser<PlanetEnvironment>() @@ -82,6 +92,10 @@ | environment_map_element [ insert(_val, _1) ] ; + environments + = parse::label(Environments_name) >> environment_map [ _r1 = _1 ] + ; + species = tok.Species_ > parse::label(Name_name) > tok.string [ _a = _1 ] @@ -89,21 +103,9 @@ > -tok.Playable_ [ _c = true ] > -tok.CanProduceShips_ [ _d = true ] > -tok.CanColonize_ [ _e = true ] - > -( - parse::label(Foci_name) - >> ( - '[' > +focus_type [ push_back(_f, _1) ] > ']' - | focus_type [ push_back(_f, _1) ] - ) - ) - > -( - parse::label(EffectsGroups_name) - >> parse::detail::effects_group_parser() [ _g = _1 ] - ) - > -( - parse::label(Environments_name) - >> environment_map [ _h = _1 ] - ) + > -foci(_f) + > -effects(_g) + > -environments(_h) > parse::label(Graphic_name) > tok.string [ insert_species(_r1, new_<Species>(_a, _b, _f, _h, _g, _c, _d, _e, _1)) ] ; @@ -112,15 +114,21 @@ ; focus_type.name("Focus"); + foci.name("Foci"); + effects.name("EffectsGroups"); environment_map_element.name("Type = <type> Environment = <env>"); environment_map.name("Environments"); + environments.name("Environments"); species.name("Species"); start.name("start"); #if DEBUG_PARSERS debug(focus_type); + debug(foci); + debug(effects); debug(environment_map_element); debug(environment_map); + debug(environments); debug(species); debug(start); #endif @@ -141,6 +149,18 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::vector<FocusType>&), + parse::skipper_type + > foci_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + void (std::vector<boost::shared_ptr<const Effect::EffectsGroup> >&), + parse::skipper_type + > effects_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, std::pair<PlanetType, PlanetEnvironment> (), qi::locals<PlanetType>, parse::skipper_type @@ -154,6 +174,12 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + void (std::map<PlanetType, PlanetEnvironment>&), + parse::skipper_type + > environments_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (std::map<std::string, Species*>&), qi::locals< std::string, @@ -174,9 +200,12 @@ parse::skipper_type > start_rule; + foci_rule foci; focus_type_rule focus_type; + effects_rule effects; environment_map_element_rule environment_map_element; environment_map_rule environment_map; + environments_rule environments; species_rule species; start_rule start; }; Modified: trunk/FreeOrion/parse/TechsParser.cpp =================================================================== --- trunk/FreeOrion/parse/TechsParser.cpp 2011-11-07 01:39:45 UTC (rev 4476) +++ trunk/FreeOrion/parse/TechsParser.cpp 2011-11-07 04:22:10 UTC (rev 4477) @@ -1,5 +1,3 @@ -#define FUSION_MAX_VECTOR_SIZE 20 - #include "Double.h" #include "Int.h" #include "Label.h" @@ -81,7 +79,8 @@ qi::_g_type _g; qi::_h_type _h; qi::_r1_type _r1; - qi::_r1_type _r2; + qi::_r2_type _r2; + qi::_r3_type _r3; qi::_val_type _val; qi::eps_type eps; using phoenix::construct; @@ -89,10 +88,14 @@ using phoenix::new_; using phoenix::push_back; + tech_info_name_desc + = parse::label(Name_name) > tok.string [ _r1 = _1 ] + > parse::label(Description_name) > tok.string [ _r2 = _1 ] + > parse::label(Short_Description_name) > tok.string [ _r3 = _1 ] // TODO: Get rid of underscore. + ; + tech_info - = parse::label(Name_name) > tok.string [ _a = _1 ] - > parse::label(Description_name) > tok.string [ _b = _1 ] - > parse::label(Short_Description_name) > tok.string [ _c = _1 ] // TODO: Get rid of underscore. + = tech_info_name_desc(_a, _b, _c) >> -( parse::label(TechType_name) >> parse::enum_parser<TechType>() [ _d = _1 ] | eps [ _d = TT_THEORY ] @@ -114,28 +117,32 @@ [ _val = construct<Tech::TechInfo>(_a, _b, _c, _e, _d, _f, _g, _h) ] ; + prerequisites + = parse::label(Prerequisites_name) + >> ( + '[' > +tok.string [ insert(_r1, _1) ] > ']' + | tok.string [ insert(_r1, _1) ] + ) + ; + + unlocks + = parse::label(Unlock_name) + >> ( + '[' > +parse::detail::item_spec_parser() [ push_back(_r1, _1) ] > ']' + | parse::detail::item_spec_parser() [ push_back(_r1, _1) ] + ) + ; + tech = ( tok.Tech_ - > tech_info [ _a = _1 ] - > -( - parse::label(Prerequisites_name) - >> ( - '[' > +tok.string [ insert(_b, _1) ] > ']' - | tok.string [ insert(_b, _1) ] - ) - ) - > -( - parse::label(Unlock_name) - >> ( - '[' > +parse::detail::item_spec_parser() [ push_back(_c, _1) ] > ']' - | parse::detail::item_spec_parser() [ push_back(_c, _1) ] - ) - ) - > -( + > tech_info [ _a = _1 ] + > -prerequisites(_b) + > -unlocks(_c) + > -( parse::label(EffectsGroups_name) >> parse::detail::effects_group_parser() [ _d = _1 ] ) - > -( + > -( parse::label(Graphic_name) >> tok.string [ _e = _1 ] ) ) @@ -156,16 +163,21 @@ ) ; + tech_info_name_desc.name("tech name"); tech_info.name("Tech info"); + prerequisites.name("Prerequisites"); + unlocks.name("Unlock"); tech.name("Tech"); category.name("Category"); start.name("start"); #if DEBUG_PARSERS + debug(tech_info_name_desc); debug(tech_info); + debug(prerequisites); + debug(unlocks); debug(tech); debug(category); - debug(start); #endif qi::on_error<qi::fail>(start, parse::report_error(_1, _2, _3, _4)); @@ -173,6 +185,12 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + Tech::TechInfo (std::string&, std::string&, std::string&), + parse::skipper_type + > tech_info_name_desc_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, Tech::TechInfo (), qi::locals< std::string, @@ -189,6 +207,18 @@ typedef boost::spirit::qi::rule< parse::token_iterator, + Tech::TechInfo (std::set<std::string>&), + parse::skipper_type + > prerequisites_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, + Tech::TechInfo (std::vector<ItemSpec>&), + parse::skipper_type + > unlocks_rule; + + typedef boost::spirit::qi::rule< + parse::token_iterator, void (TechManager::TechContainer&), qi::locals< Tech::TechInfo, @@ -216,7 +246,10 @@ parse::skipper_type > start_rule; + tech_info_name_desc_rule tech_info_name_desc; tech_info_rule tech_info; + prerequisites_rule prerequisites; + unlocks_rule unlocks; tech_rule tech; category_rule category; start_rule start; |