Exemplo n.º 1
0
        protected Expression ParseTrigger(Expression parent)
        {
            Expression result = parent ?? new Expression();

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

                if (p3.Tag == Tag.Brace_Left)
                {
                    var c = new Expression()
                    {
                        Key = p1.Content, Operator = p2.Content, Value = p3.Content
                    };
                    result.Children.Add(ParseTrigger(c)); Skip(1);
                }
                else
                {
                    result.Children.Add(new Expression()
                    {
                        Key = p1.Content, Operator = p2.Content, Value = p3.Content
                    });
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        protected Variable ParseVariable()
        {
            Lexeme k = Lexical.Read();
            Lexeme e = Lexical.Read();
            Lexeme v = Lexical.Read();

            Variable variable = new Variable();

            variable.Key = k.Content;

            if (IsVariable(v))
            {
                variable.Reference = new Variable()
                {
                    Key = v.Content
                }
            }
            ;

            if (IsNumber(v))
            {
                variable.Value = v.Content;
            }

            variable.FileName = FileName;
            LogUtil.Log($"{k.Content} {e.Content} {v.Content}");
            return(variable);
        }
Exemplo n.º 3
0
        protected Lexical Skip(int step)
        {
            for (int i = 0; i < step; i++)
            {
                Lexical.Read();
            }

            return(Lexical);
        }
        private TechnologyCategory ParseTechnologyCategory()
        {
            TechnologyCategory technologyCategory = new TechnologyCategory();

            technologyCategory.FileName = FileName;

            technologyCategory.Key  = Lexical.Read().Content; Skip(2);
            technologyCategory.Icon = ParseValue();
            Skip(1);

            return(technologyCategory);
        }
Exemplo n.º 5
0
        protected ObservableCollection <String> ParseArray()
        {
            ObservableCollection <String> vs = new ObservableCollection <string>();

            Skip(3);

            while (Lexical.Peek.Tag != Tag.Brace_Right)
            {
                vs.Add(Lexical.Read().Content);
            }

            Skip(1);
            return(vs);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }