public bool MoveNext()
        {
            if (_currentIndex < 0)
            {
                while (_innerParser.MoveNext())
                {
                    _allEvents.Add(_innerParser.Current);
                }

                for (int i = _allEvents.Count - 2; i >= 0; --i)
                {
                    var merge = _allEvents[i] as Scalar;
                    if (merge != null && merge.Value == "<<")
                    {
                        var anchorAlias = _allEvents[i + 1] as AnchorAlias;
                        if (anchorAlias != null)
                        {
                            var mergedEvents = GetMappingEvents(anchorAlias.Value);
                            _allEvents.RemoveRange(i, 2);
                            _allEvents.InsertRange(i, mergedEvents);
                            continue;
                        }

                        var sequence = _allEvents[i + 1] as SequenceStart;
                        if (sequence != null)
                        {
                            var mergedEvents = new List<IEnumerable<ParsingEvent>>();
                            var sequenceEndFound = false;
                            for (var itemIndex = i + 2; itemIndex < _allEvents.Count; ++itemIndex)
                            {
                                anchorAlias = _allEvents[itemIndex] as AnchorAlias;
                                if (anchorAlias != null)
                                {
                                    mergedEvents.Add(GetMappingEvents(anchorAlias.Value));
                                    continue;
                                }

                                if (_allEvents[itemIndex] is SequenceEnd)
                                {
                                    _allEvents.RemoveRange(i, itemIndex - i + 1);
                                    _allEvents.InsertRange(i, mergedEvents.SelectMany(e => e));
                                    sequenceEndFound = true;
                                    break;
                                }
                            }

                            if (sequenceEndFound)
                            {
                                continue;
                            }
                        }

                        throw new SemanticErrorException(merge.Start, merge.End, "Unrecognized merge key pattern");
                    }
                }
            }

            var nextIndex = _currentIndex + 1;
            if (nextIndex < _allEvents.Count)
            {
                Current = _allEvents[nextIndex];
                _currentIndex = nextIndex;
                return true;
            }
            return false;
        }
 void IParsingEventVisitor.Visit(MappingStart e)
 {
     clonedEvent = new MappingStart(null, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
 }
 void IParsingEventVisitor.Visit(MappingEnd e)
 {
     clonedEvent = new MappingEnd(e.Start, e.End);
 }
 void IParsingEventVisitor.Visit(SequenceEnd e)
 {
     clonedEvent = new SequenceEnd(e.Start, e.End);
 }
 void IParsingEventVisitor.Visit(SequenceStart e)
 {
     clonedEvent = new SequenceStart(null, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
 }
 void IParsingEventVisitor.Visit(Scalar e)
 {
     clonedEvent = new Scalar(null, e.Tag, e.Value, e.Style, e.IsPlainImplicit, e.IsQuotedImplicit, e.Start, e.End);
 }
 void IParsingEventVisitor.Visit(AnchorAlias e)
 {
     clonedEvent = new AnchorAlias(e.Value, e.Start, e.End);
 }
 public ParsingEvent Clone(ParsingEvent e)
 {
     e.Accept(this);
     return clonedEvent;
 }