Esempio n. 1
0
        private DescriptorToken Supply()
        {
            if (Current == '\0')
            {
                var span  = new TextSpan(_position, _position);
                var token = new DescriptorToken(span, DescriptorTokenKind.EndOfFile, ReadOnlyMemory <char> .Empty);

                return(token);
            }

            if (Special.Contains(Current))
            {
                return(SingleCharacter());
            }

            int start = _position;

            while (!Special.Contains(Current) && _position < _text.Length)
            {
                Next();
            }

            return(CreateIdentifierToken(start));
        }
Esempio n. 2
0
 /// <summary>
 /// Throws a <see cref="DescriptorParserException"/> with an unexpected token message.
 /// </summary>
 /// <param name="token">The <see cref="DescriptorToken"/> that wasn't expected.</param>
 /// <param name="expected">The token that was expected.</param>
 public static void ThrowUnexpectedToken(DescriptorToken token, DescriptorTokenKind expected) =>
 throw new DescriptorParserException($"Unexpected token <{token.Kind}>, expected <{expected}>.");