コード例 #1
0
ファイル: Token.cs プロジェクト: augustoproiete-bot/PdfParser
        public ArrayToken(Tokeniser tokeniser, ObjectId?objectId) : base(tokeniser, objectId)
        {
            //[/someName false -0 (string)]
            this.tokeniser = tokeniser;
            tokens         = new List <Token>();
            var b = tokeniser.SkipWhiteSpace();

            if (b != '[')
            {
                throw tokeniser.Exception($"illegal array format, leading character '[' expected but was {(char)b}.");
            }

            b = tokeniser.GetNextByte();
            while (b != ']')
            {
                var token = tokeniser.GetNextToken(isThrowExceptionWhenError: false);
                if (token != null)
                {
                    tokens.Add(token);
                    b = tokeniser.SkipWhiteSpace();
                }
                else
                {
                    b = tokeniser.GetByte();
                    if (b != ']')
                    {
                        throw tokeniser.Exception($"NextToken(): unexpected character '{(char)b}'.");
                    }
                    //we come here when array is empty but has some whitespace
                }
            }
            tokeniser.GetNextByte();
        }