internal GreenWithPlyFloatItemsSyntax(IEnumerable <GreenWithTriviaSyntax> leadingFloatItems)
 {
     if (leadingFloatItems == null)
     {
         throw new ArgumentNullException(nameof(leadingFloatItems));
     }
     LeadingFloatItems = ReadOnlySpanList <GreenWithTriviaSyntax> .Create(leadingFloatItems);
 }
        internal PgnBackgroundListSyntax(Union <PgnTriviaElementSyntax, PgnTriviaSyntax> parent, ReadOnlySpanList <GreenPgnBackgroundSyntax> green)
        {
            Parent = parent;
            Green  = green;

            BackgroundNodes = new SafeLazyObjectCollection <PgnBackgroundSyntax>(
                green.Count,
                index => Green[index].CreateRedNode(this, index));
        }
        internal PgnPlyFloatItemListSyntax(Union <WithPlyFloatItemsSyntax, PgnPlyListSyntax> parent, ReadOnlySpanList <GreenWithTriviaSyntax> green)
        {
            Parent = parent;
            Green  = green;

            FloatItems = new SafeLazyObjectCollection <PgnPlyFloatItemWithTriviaSyntax>(
                green.Count,
                index => new PgnPlyFloatItemWithTriviaSyntax(this, index, Green[index]));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnGameListSyntax"/>.
        /// </summary>
        /// <param name="games">
        /// The list of games.
        /// </param>
        /// <param name="trailingTrivia">
        /// The trailing trivia of the syntax node.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="games"/> and/or <paramref name="trailingTrivia"/> is null.
        /// </exception>
        public GreenPgnGameListSyntax(IEnumerable <GreenPgnGameSyntax> games, GreenPgnTriviaSyntax trailingTrivia)
        {
            if (games == null)
            {
                throw new ArgumentNullException(nameof(games));
            }
            Games = ReadOnlySpanList <GreenPgnGameSyntax> .Create(games);

            TrailingTrivia = trailingTrivia ?? throw new ArgumentNullException(nameof(trailingTrivia));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="GreenJsonBackgroundListSyntax"/>.
        /// </summary>
        /// <param name="source">
        /// The source enumeration of <see cref="GreenJsonBackgroundSyntax"/>.
        /// </param>
        /// <returns>
        /// The new <see cref="GreenJsonBackgroundListSyntax"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source"/> is null.
        /// </exception>
        public static GreenJsonBackgroundListSyntax Create(IEnumerable <GreenJsonBackgroundSyntax> source)
        {
            var readOnlyBackground = ReadOnlySpanList <GreenJsonBackgroundSyntax> .Create(source);

            if (readOnlyBackground.Count == 0)
            {
                return(Empty);
            }
            return(new GreenJsonBackgroundListSyntax(readOnlyBackground));
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of <see cref="GreenJsonMultiValueSyntax"/>.
        /// </summary>
        /// <param name="valueNodes">
        /// The non-empty enumeration of value nodes.
        /// </param>
        /// <param name="backgroundAfter">
        /// The background symbols which directly trail the value nodes.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="valueNodes"/> and/or <paramref name="backgroundAfter"/> are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="valueNodes"/> is an empty enumeration.
        /// </exception>
        public GreenJsonMultiValueSyntax(IEnumerable <GreenJsonValueWithBackgroundSyntax> valueNodes, GreenJsonBackgroundListSyntax backgroundAfter)
        {
            ValueNodes = ReadOnlySpanList <GreenJsonValueWithBackgroundSyntax> .Create(valueNodes);

            if (ValueNodes.Count == 0)
            {
                throw new ArgumentException($"{nameof(valueNodes)} cannot be empty", nameof(valueNodes));
            }

            BackgroundAfter = backgroundAfter ?? throw new ArgumentNullException(nameof(backgroundAfter));
        }
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnTriviaElementSyntax"/>.
        /// </summary>
        /// <param name="backgroundBefore">
        /// The background symbols which directly precede the comment foreground node.
        /// </param>
        /// <param name="commentNode">
        /// The foreground node which contains the comment.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="backgroundBefore"/> and/or <paramref name="commentNode"/> are null.
        /// </exception>
        public GreenPgnTriviaElementSyntax(IEnumerable <GreenPgnBackgroundSyntax> backgroundBefore, GreenPgnCommentSyntax commentNode)
        {
            if (backgroundBefore == null)
            {
                throw new ArgumentNullException(nameof(backgroundBefore));
            }

            BackgroundBefore = ReadOnlySpanList <GreenPgnBackgroundSyntax> .Create(backgroundBefore);

            CommentNode = commentNode ?? throw new ArgumentNullException(nameof(commentNode));
            Length      = BackgroundBefore.Length + CommentNode.Length;
        }
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnTagPairSyntax"/>.
        /// </summary>
        /// <param name="tagElementNodes">
        /// The tag element nodes.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="tagElementNodes"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="tagElementNodes"/> is empty.
        /// </exception>
        public GreenPgnTagPairSyntax(IEnumerable <GreenWithTriviaSyntax> tagElementNodes)
        {
            if (tagElementNodes == null)
            {
                throw new ArgumentNullException(nameof(tagElementNodes));
            }
            TagElementNodes = ReadOnlySpanList <GreenWithTriviaSyntax> .Create(tagElementNodes);

            if (TagElementNodes.Count == 0)
            {
                throw new ArgumentException($"{nameof(tagElementNodes)} is empty", nameof(tagElementNodes));
            }
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnTagSectionSyntax"/>.
        /// </summary>
        /// <param name="tagPairNodes">
        /// The tag pair nodes.
        /// </param>
        /// <returns>
        /// The new <see cref="GreenPgnTagSectionSyntax"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="tagPairNodes"/> is null.
        /// </exception>
        public static GreenPgnTagSectionSyntax Create(IEnumerable <GreenPgnTagPairSyntax> tagPairNodes)
        {
            if (tagPairNodes == null)
            {
                throw new ArgumentNullException(nameof(tagPairNodes));
            }

            var tagPairNodeSpanList = ReadOnlySpanList <GreenPgnTagPairSyntax> .Create(tagPairNodes);

            return(tagPairNodeSpanList.Count == 0
                ? Empty
                : new GreenPgnTagSectionSyntax(tagPairNodeSpanList));
        }
Example #10
0
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnPlyListSyntax"/>.
        /// </summary>
        /// <param name="plies">
        /// The ply nodes.
        /// </param>
        /// <param name="trailingFloatItems">
        /// The nodes containing the trailing floating items that are not part of a ply.
        /// </param>
        /// <returns>
        /// The new <see cref="GreenPgnPlyListSyntax"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="plies"/> and/or <paramref name="trailingFloatItems"/> is null.
        /// </exception>
        public static GreenPgnPlyListSyntax Create(IEnumerable <GreenPgnPlySyntax> plies, IEnumerable <GreenWithTriviaSyntax> trailingFloatItems)
        {
            if (plies == null)
            {
                throw new ArgumentNullException(nameof(plies));
            }
            if (trailingFloatItems == null)
            {
                throw new ArgumentNullException(nameof(trailingFloatItems));
            }

            var plyList = ReadOnlySpanList <GreenPgnPlySyntax> .Create(plies);

            var trailingFloatItemList = ReadOnlySpanList <GreenWithTriviaSyntax> .Create(trailingFloatItems);

            return(plyList.Count == 0 && trailingFloatItemList.Count == 0
                ? Empty
                : new GreenPgnPlyListSyntax(plyList, trailingFloatItemList));
        }
Example #11
0
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnTriviaSyntax"/>.
        /// </summary>
        /// <param name="commentNodes">
        /// The comment nodes.
        /// </param>
        /// <param name="backgroundAfter">
        /// The background after the comment nodes.
        /// </param>
        /// <returns>
        /// The new <see cref="GreenPgnTriviaSyntax"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="commentNodes"/> and/or <paramref name="backgroundAfter"/> are null.
        /// </exception>
        public static GreenPgnTriviaSyntax Create(IEnumerable <GreenPgnTriviaElementSyntax> commentNodes, IEnumerable <GreenPgnBackgroundSyntax> backgroundAfter)
        {
            if (commentNodes == null)
            {
                throw new ArgumentNullException(nameof(commentNodes));
            }
            if (backgroundAfter == null)
            {
                throw new ArgumentNullException(nameof(backgroundAfter));
            }

            var commentNodeSpanList = ReadOnlySpanList <GreenPgnTriviaElementSyntax> .Create(commentNodes);

            var backgroundAfterSpanList = ReadOnlySpanList <GreenPgnBackgroundSyntax> .Create(backgroundAfter);

            return(commentNodeSpanList.Count == 0 && backgroundAfterSpanList.Count == 0
                ? Empty
                : new GreenPgnTriviaSyntax(commentNodeSpanList, backgroundAfterSpanList));
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of <see cref="GreenPgnPlySyntax"/>.
        /// </summary>
        /// <param name="moveNumber">
        /// The move number. This is an optional parameter.
        /// </param>
        /// <param name="move">
        /// The move. This is an optional parameter.
        /// </param>
        /// <param name="nags">
        /// The NAG (Numeric Annotation Glyph) nodes.
        /// </param>
        /// <param name="variations">
        /// The variation nodes.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="nags"/> and/or <paramref name="variations"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="moveNumber"/> is null, <paramref name="move"/> is null, and both <paramref name="nags"/> and <paramref name="variations"/> are empty.
        /// </exception>
        public GreenPgnPlySyntax(
            GreenWithPlyFloatItemsSyntax <GreenWithTriviaSyntax> moveNumber,
            GreenWithPlyFloatItemsSyntax <GreenWithTriviaSyntax> move,
            IEnumerable <GreenWithPlyFloatItemsSyntax <GreenWithTriviaSyntax> > nags,
            IEnumerable <GreenWithPlyFloatItemsSyntax <GreenPgnVariationSyntax> > variations)
        {
            if (nags == null)
            {
                throw new ArgumentNullException(nameof(nags));
            }
            if (variations == null)
            {
                throw new ArgumentNullException(nameof(variations));
            }

            MoveNumber = moveNumber;
            Move       = move;
            Nags       = ReadOnlySpanList <GreenWithPlyFloatItemsSyntax <GreenWithTriviaSyntax> > .Create(nags);

            Variations = ReadOnlySpanList <GreenWithPlyFloatItemsSyntax <GreenPgnVariationSyntax> > .Create(variations);

            int length = Nags.Length + Variations.Length;

            if (moveNumber != null)
            {
                length += moveNumber.Length;
            }
            if (move != null)
            {
                length += move.Length;
            }

            if (length == 0)
            {
                throw new ArgumentException($"{nameof(GreenPgnPlySyntax)} cannot be empty.");
            }

            Length = length;
        }
Example #13
0
 private GreenPgnTriviaSyntax(ReadOnlySpanList <GreenPgnTriviaElementSyntax> commentNodes, ReadOnlySpanList <GreenPgnBackgroundSyntax> backgroundAfter)
 {
     CommentNodes    = commentNodes;
     BackgroundAfter = backgroundAfter;
 }
 private GreenJsonBackgroundListSyntax(ReadOnlySpanList <GreenJsonBackgroundSyntax> backgroundNodes) => BackgroundNodes = backgroundNodes;
Example #15
0
 private GreenPgnTagSectionSyntax(ReadOnlySpanList <GreenPgnTagPairSyntax> tagPairNodes) => TagPairNodes = tagPairNodes;
 internal WithPlyFloatItemsSyntax(ReadOnlySpanList <GreenWithTriviaSyntax> greenLeadingFloatItems)
 {
     leadingFloatItems = new SafeLazyObject <PgnPlyFloatItemListSyntax>(() => new PgnPlyFloatItemListSyntax(this, greenLeadingFloatItems));
 }
Example #17
0
 private GreenPgnPlyListSyntax(ReadOnlySpanList <GreenPgnPlySyntax> plies, ReadOnlySpanList <GreenWithTriviaSyntax> trailingFloatItems)
 {
     Plies = plies;
     TrailingFloatItems = trailingFloatItems;
 }