Exemplo n.º 1
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            double position = 0;
            bool found = false;
            ProjectV2.Token posToken = serializer.ReadNumericToken(this, ref position, out found);
            if (posToken != null)
            {
                _Position = (int)position;

                if (serializer.ReadTextToken(this) != null)
                {
                    serializer.Warn("The capitalize command requires zero or one argument.", this);
                }
            }
            else if (found)
            {
                serializer.Warn("The capitalize command requires the first argument to be an integer.", this);
            }
            else
            {
                _Position = -1;
            }
        }
Exemplo n.º 2
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            bool found = false;
            double amount = 0.0;
            ProjectV2.Token amountToken = serializer.ReadNumericToken(this, ref amount, out found);

            if (amountToken != null)
            {
                _Amount = (int)amount;
                if (serializer.ReadTextToken(this) != null)
                {
                    serializer.Warn("The leave command requires zero or one argument.", this);
                }
            }
            else if (found)
            {
                serializer.Warn("The leave command requires the first argument to be a positive integer.", this);
            }
            else
            {
                _Amount = 1;
            }
        }
Exemplo n.º 3
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            bool found = false;
            double amount = 0.0;
            ProjectV2.Token amountToken = serializer.ReadNumericToken(this, ref amount, out found);

            if (amountToken != null)
            {
                _StartIndex = (int)amount;

                amountToken = serializer.ReadNumericToken(this, ref amount, out found);

                if (amountToken != null)
                {
                    _EndIndex = (int)amount;
                    if (serializer.ReadTextToken(this) != null)
                    {
                        serializer.Warn("The substring command requires one or two arguments.", this);
                    }
                }
                else if (found)
                {
                    serializer.Warn("The substring command requires its arguments to be positive integers.", this);
                }
            }
            else if (found)
            {
                serializer.Warn("The substring command requires its arguments to be positive integers.", this);
            }
            else
            {
                serializer.Warn("The substring command requires one or two arguments.", this);
            }
        }
Exemplo n.º 4
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            double num = 0;
            bool found = true;

            Token amount = null;
            while (found)
            {
                amount = serializer.ReadNumericToken(this, ref num, out found);
                if (amount != null)
                {
                    _Repetitions.Add((int)num);
                }

                if (amount == null && found)
                {
                    int reps = 0;
                    string data;
                    amount = serializer.ReadRepeatingToken(this, out reps, out data);

                    if (amount != null)
                    {
                        List<int> numbers = new List<int>();
                        foreach (string numstring in data.Split(' '))
                        {
                            int number = 0;
                            if (int.TryParse(numstring, out number))
                            {
                                numbers.Add(number);
                            }
                            else
                            {
                                serializer.Warn("Expected numbers only", this);
                            }
                        }

                        for (int i = 0; i < reps; i++)
                        {
                            _Repetitions.AddRange(numbers);
                        }
                    }
                    else
                    {
                        found = false;
                    }
                }
            }

            CommandBlockNode cbn = new CommandBlockNode(serializer);

            Children.Add(cbn);

            foreach (CommandBase cmd in cbn.Commands)
            {
                Commands.Add(cmd);
            }
        }