Example #1
0
        private GreenJsonBackgroundListSyntax CaptureBackground()
        {
            var background = GreenJsonBackgroundListSyntax.Create(BackgroundBuilder);

            BackgroundBuilder.Clear();
            return(background);
        }
Example #2
0
 private static RootJsonSyntax CreateParseTreeTooDeepRootSyntax(int startPosition, int length)
 => new RootJsonSyntax(
     new GreenJsonMultiValueSyntax(
         new[] { new GreenJsonValueWithBackgroundSyntax(
                     GreenJsonBackgroundListSyntax.Empty,
                     GreenJsonMissingValueSyntax.Value) },
         GreenJsonBackgroundListSyntax.Create(
             new GreenJsonBackgroundSyntax[] { GreenJsonWhitespaceSyntax.Create(length) })),
     new List <JsonErrorInfo> {
     new JsonErrorInfo(JsonErrorCode.ParseTreeTooDeep, startPosition, 1)
 });
Example #3
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="GreenJsonValueWithBackgroundSyntax"/>.
 /// </summary>
 /// <param name="backgroundBefore">
 /// The background symbols which directly precede the content value node.
 /// </param>
 /// <param name="contentNode">
 /// The content node containing the actual value.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="backgroundBefore"/> and/or <paramref name="contentNode"/> are null.
 /// </exception>
 public GreenJsonValueWithBackgroundSyntax(GreenJsonBackgroundListSyntax backgroundBefore, GreenJsonValueSyntax contentNode)
 {
     BackgroundBefore = backgroundBefore ?? throw new ArgumentNullException(nameof(backgroundBefore));
     ContentNode = contentNode ?? throw new ArgumentNullException(nameof(contentNode));
     Length = BackgroundBefore.Length + ContentNode.Length;
 }