Beispiel #1
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;
            }
        }
Beispiel #2
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            ProjectV2.Token name = serializer.ReadTextToken(this);
            if (name != null)
            {
                Name = name.Text;
                name.Type = Whee.WordBuilder.ProjectV2.TokenType.Name;

                ProjectV2.Token value = serializer.ReadTextToken(this);
                if (value != null)
                {
                    Value = value.Text;

                    if (serializer.ReadTextToken(this) != null)
                    {
                        serializer.Warn("The mark command requires 2 arguments.", this);
                    }
                }
                else
                {
                    serializer.Warn("The mark command requires 2 arguments.", this);
                }
            }
            else
            {
                serializer.Warn("The mark command requires 2 arguments.", this);
            }
        }
Beispiel #3
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     if (_Amount < 0)
     {
         serializer.Warn("Leave command requires a positive integer or zero as its second argument.", this);
     }
 }
Beispiel #4
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     foreach (CommandBase cmd in Commands)
     {
         cmd.CheckSanity(project, serializer);
     }
 }
Beispiel #5
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     if (_Position == 0)
     {
         serializer.Warn("The capitalize command requires the first argument to be a non-zero integer.", this);
     }
 }
Beispiel #6
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;
            }
        }
Beispiel #7
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     m_project = project;
     if (project.Rules.GetRuleByName(Rule) == null)
     {
         serializer.Warn(string.Format("The rule '{0}' does not exist.", Rule), this);
     }
 }
Beispiel #8
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     if (_StartIndex > 0 && _EndIndex > 0 && _EndIndex < _StartIndex)
     {
         serializer.Warn("You want to start after the end?", this);
     }
     if (_StartIndex < 0 && _EndIndex < 0 && _EndIndex < _StartIndex)
     {
         serializer.Warn("You want to start after the end?", this);
     }
 }
Beispiel #9
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
     int count = project.TokenSets.CountByName(TokenSet);
     if (count == 0)
     {
         serializer.Warn(string.Format("The token set '{0}' does not exist.", TokenSet), this);
     }
     else if (count > 1)
     {
         serializer.Warn(string.Format("Multiple token sets with the name '{0}' exist.", TokenSet), this);
     }
 }
Beispiel #10
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            ProjectV2.TranslationBlockNode tbn = new ProjectV2.TranslationBlockNode(serializer);

            Children.Add(tbn);

            foreach (ProjectV2.TranslationNode item in tbn.Children)
            {
                _stringmapping.Add(item.Source.ToArray(), item.Destination.ToArray());
            }
        }
Beispiel #11
0
        public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_project = project;
            if (_stringmapping.Count == 0)
            {
                serializer.Warn("The Translate command requires at least one translation directive.", this);
            }

            foreach (string[] key in _stringmapping.Keys)
            {
                Regex reg = MakeRegex(key);
                _mapping.Add(reg, _stringmapping[key]);
            }
        }
Beispiel #12
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            ProjectV2.WeightedCommandBlockNode wcbn = new ProjectV2.WeightedCommandBlockNode(serializer);

            Children.Add(wcbn);

            foreach (ProjectV2.WeightedCommandNode wcn in wcbn.Children)
            {
                WeightedCommand wc = new WeightedCommand();
                wc.Weight = wcn.Weight;
                wc.Command = wcn.Command;
                Commands.Add(wc);
            }
        }
Beispiel #13
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;
            ProjectV2.Token literal = serializer.ReadTextToken(this);
            if (literal != null)
            {
                Literal = literal.Text;

                if (serializer.ReadTextToken(this) != null)
                {
                    serializer.Warn("The prelit command requires 1 argument.", this);
                }
            }
            else
            {
                serializer.Warn("The prelit command requires 1 argument.", this);
            }
        }
Beispiel #14
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            ProjectV2.Token tokenSet = serializer.ReadTextToken(this);

            if (tokenSet != null)
            {
                _TokenSet = tokenSet.Text;

                if (serializer.ReadTextToken(this) != null)
                {
                    serializer.Warn("The prefix command requires one argument.", this);
                }
            }
            else
            {
                serializer.Warn("The prefix command requires one argument.", this);
            }
        }
Beispiel #15
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            m_lineNumber = serializer.LineNumber;

            ProjectV2.CommandBlockNode cbn = new ProjectV2.CommandBlockNode(serializer);

            if (cbn.Commands.Count > 0)
            {
                Children.Add(cbn);

                foreach (CommandBase cmd in cbn.Commands)
                {
                    Commands.Add(cmd);
                }
            }
            else
            {
                serializer.Warn("The apply command expects a command block.", this);
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
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);
            }
        }
 public void AddWarning(Whee.WordBuilder.ProjectV2.IProjectNode node, string message)
 {
     _warnings.Add(new Warning(node, message));
     m_warningsBrowser.LoadColumnZero();
     m_drawer.Open();
 }
Beispiel #19
0
 public abstract void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer);
Beispiel #20
0
 public Warning(Whee.WordBuilder.ProjectV2.IProjectNode node, string message)
 {
     Node = node;
     Message = message;
 }
Beispiel #21
0
 public override void CheckSanity(Project project, Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
 {
 }