private ObservableCollection <WeightGroupPicked> ParseModWeightIfGroupPicked()
        {
            ObservableCollection <WeightGroupPicked> weightGroupPickeds = new ObservableCollection <WeightGroupPicked>();

            Skip(3);

            while (CheckBlock())
            {
                weightGroupPickeds.Add(new WeightGroupPicked()
                {
                    Group = Lexical.Read().Content, Operator = Lexical.Read().Content, Value = Lexical.Read().Content
                });
            }

            Skip(1);
            return(weightGroupPickeds);
        }
        private ObservableCollection <Modifier> ParseStaticModifier()
        {
            ObservableCollection <Modifier> modifiers = new ObservableCollection <Modifier>();

            Skip(3);

            while (CheckBlock())
            {
                Lexeme p1 = Lexical.Read();
                Lexeme p2 = Lexical.Read();
                Lexeme p3 = Lexical.Read();

                modifiers.Add(new Modifier()
                {
                    Key = p1.Content, Operator = p2.Content, Value = p3.Content
                });
            }

            Skip(1);

            return(modifiers);
        }
        private PrereqforDescCetegory ParsePrereqforDescCetegory()
        {
            PrereqforDescCetegory prereqforDescCetegory = new PrereqforDescCetegory();

            prereqforDescCetegory.Key = Lexical.Read().Content;
            Skip(2);

            for (int i = 0; i < 2; i++)
            {
                if (Lexical.Peek.Content == "title")
                {
                    prereqforDescCetegory.Title = ParseValue();
                }
                else if (Lexical.Peek.Content == "desc")
                {
                    prereqforDescCetegory.Desc = ParseValue();
                }
            }

            Skip(1);
            return(prereqforDescCetegory);
        }
 /// <summary>
 /// 根据指定得词法分析器创建解析器
 /// </summary>
 /// <param name="lex"></param>
 public TechnologyCategoryParser(FileInfo file)
 {
     Lexical  = new Lexical(File.ReadAllText(file.FullName));
     FileName = file.Name;
 }
        private Technology ParseTechnology()
        {
            Technology technology = new Technology();

            technology.FileName = FileName;

            // 科技名称
            technology.Key = Lexical.Read().Content;
            Lexical.Read();
            Lexical.Read();

            while (Lexical.Peek.Tag != Tag.Brace_Right)
            {
                Lexeme peek = Lexical.Peek;
                if (peek.Content == "cost")
                {
                    technology.Cost = ParseValue();
                }
                else if (peek.Content == "area")
                {
                    technology.Area = ParseValue();
                }
                else if (peek.Content == "tier")
                {
                    technology.Tier = ParseValue();
                }
                else if (peek.Content == "category")
                {
                    technology.Category = ParseArray();
                }
                else if (peek.Content == "levels")
                {
                    technology.Levels = ParseValue();
                }
                else if (peek.Content == "cost_per_level")
                {
                    technology.CostPerLevel = ParseValue();
                }
                else if (peek.Content == "prerequisites")
                {
                    technology.Prerequisites = ParseArray();
                }
                else if (peek.Content == "weight")
                {
                    technology.Weight = ParseValue();
                }
                else if (peek.Content == "gateway")
                {
                    technology.Gateway = ParseValue();
                }
                else if (peek.Content == "ai_update_type")
                {
                    technology.AiUpdateType = ParseValue();
                }
                else if (peek.Content == "start_tech")
                {
                    technology.StartTech = ParseValue();
                }
                else if (peek.Content == "feature_flags")
                {
                    technology.FeatureFlags = ParseArray();
                }
                else if (peek.Content == "is_rare")
                {
                    technology.IsRare = ParseValue();
                }
                else if (peek.Content == "is_dangerous")
                {
                    technology.IsDangerous = ParseValue();
                }
                else if (peek.Content == "is_reverse_engineerable")
                {
                    technology.IsReverseEngineerable = ParseValue();
                }
                else if (peek.Content == "weight_modifier")
                {
                    technology.WeightModifier = ParseWeightModifier();
                }
                else if (peek.Content == "ai_weight")
                {
                    technology.AiWeight = ParseWeightModifier();
                }
                else if (peek.Content == "modifier")
                {
                    technology.Modifier = ParseTriggers();
                }
                else if (peek.Content == "potential")
                {
                    technology.Potential = ParseTriggers();
                }
                else if (peek.Content == "prereqfor_desc")
                {
                    technology.PrereqforDesc = ParsePrereqforDesc();
                }
                else if (peek.Content == "weight_groups")
                {
                    technology.WeightGroups = ParseArray();
                }
                else if (peek.Content == "mod_weight_if_group_picked")
                {
                    technology.ModWeightIfGroupPicked = ParseModWeightIfGroupPicked();
                }
                else if (peek.Content == "icon")
                {
                    technology.Icon = ParseValue();
                }
                else if (peek.Tag == Tag.None)
                {
                    break;
                }
                else
                {
                    throw new ArgumentException($"TechnologyParser 无法识别该脚本语句:{FileName} {Lexical.Peek.Pragma.Row} {Lexical.Peek.Pragma.Col} {Lexical.Peek.Content}");
                }
            }

            Skip(1);
            return(technology);
        }