Beispiel #1
0
        public void InsertSequence(ParserSequence sequence, T command)
        {
            if (sequence == null)
            {
                if (_command != null)
                {
                    throw new SequenceAlreadyPresentException();
                }

                _command = command;
            }
            else
            {
                if (!_childrenDic.ContainsKey(sequence.InnerToken))
                {
                    _childrenDic.Add(sequence.InnerToken, new ParserTreeNode <T>(Rank + 1)
                    {
                        SequenceItem = sequence
                    });
                }
                try
                {
                    _childrenDic[sequence.InnerToken].InsertSequence(sequence.Next, command);
                }
                catch (SequenceAlreadyPresentException)
                {
                    throw new SequenceAlreadyPresentException(sequence.First);
                }
            }
        }
 public SequenceAlreadyPresentException(ParserSequence sequence)
     : base("Sequence '" + sequence.ToString() + "' already exists!")
 {
     Sequence = sequence;
 }