public HoconImmutableArrayBuilder AddRange(HoconArray array)
 {
     foreach (var element in array)
     {
         Add(element.ToHoconImmutable());
     }
     return(this);
 }
Exemplo n.º 2
0
        public HoconArray ParseArray(string currentPath)
        {
            var arr = new HoconArray();

            while (!_reader.EoF && !_reader.IsArrayEnd())
            {
                var v = new HoconValue();
                ParseValue(v, currentPath);
                arr.Add(v);
                _reader.PullWhitespaceAndComments();
            }
            _reader.PullArrayEnd();
            return(arr);
        }
Exemplo n.º 3
0
        public void ParseValue(HoconValue owner, string currentPath)
        {
            if (_reader.EoF)
            {
                throw new Exception("End of file reached while trying to read a value");
            }

            _reader.PullWhitespaceAndComments();
            while (_reader.IsValue())
            {
                Token t = _reader.PullValue();
                switch (t.Kind)
                {
                case TokenKind.EoF:
                    break;

                case TokenKind.LiteralValue:
                    if (owner.IsObject())
                    {
                        owner.Clear();
                    }

                    var lit = new HoconLiteral(t.Value);
                    owner.AppendValue(lit);
                    break;

                case TokenKind.ObjectStart:
                    ParseObject(owner, true, currentPath);
                    break;

                case TokenKind.ArrayStart:
                    HoconArray arr = ParseArray(currentPath);
                    owner.AppendValue(arr);
                    break;

                case TokenKind.Substitute:
                    HoconSubstitution sub = ParseSubstitution(t.Value);
                    substitutions.Add(sub);
                    owner.AppendValue(sub);
                    break;
                }
                if (_reader.IsSpaceOrTab())
                {
                    ParseTrailingWhitespace(owner);
                }
            }

            IgnoreComma();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieves the next array token from the tokenizer.
 /// </summary>
 /// <returns>An array of elements retrieved from the token.</returns>
 public HoconArray ParseArray(string currentPath)
 {
     var arr = new HoconArray();
     while (!_reader.EoF && !_reader.IsArrayEnd())
     {
         var v = new HoconValue();
         ParseValue(v,currentPath);
         arr.Add(v);
         _reader.PullWhitespaceAndComments();
     }
     _reader.PullArrayEnd();
     return arr;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Parses the array.
 /// </summary>
 /// <returns>HoconArray.</returns>
 public HoconArray ParseArray()
 {
     var arr = new HoconArray();
     while (!reader.EoF && !reader.IsArrayEnd())
     {
         var v = new HoconValue();
         ParseValue(v);
         arr.Add(v);
         reader.PullWhitespaceAndComments();
     }
     reader.PullArrayEnd();
     return arr;
 }
Exemplo n.º 6
0
 public static HoconImmutableArray ToHoconImmutable(this HoconArray array)
 {
     return(new HoconImmutableArrayBuilder()
            .AddRange(array)
            .Build());
 }