HtmlLexicalAnalyzer.GetNextTagToken C# (CSharp) Method

GetNextTagToken() private method

Unconditionally returns a token which is one of: TagEnd, EmptyTagEnd, Name, Atom or EndOfStream Does not guarantee token reader advancing.
private GetNextTagToken ( ) : void
return void
    internal void GetNextTagToken()
    {
        _nextToken.Length = 0;
        if (this.IsAtEndOfStream)
        {
            _nextTokenType = HtmlTokenType.EOF;
            return;
        }

        this.SkipWhiteSpace();

        if (this.NextCharacter == '>' && !this.IsNextCharacterEntity)
        {
            // > should not end a tag, so make sure it's not an entity
            _nextTokenType = HtmlTokenType.TagEnd;
            _nextToken.Append('>');
            this.GetNextCharacter();
            // Note: _ignoreNextWhitespace must be set appropriately on tag start processing
        }
        else if (this.NextCharacter == '/' && _lookAheadCharacter == '>')
        {
            // could be start of closing of empty tag
            _nextTokenType = HtmlTokenType.EmptyTagEnd;
            _nextToken.Append("/>");
            this.GetNextCharacter();
            this.GetNextCharacter();
            _ignoreNextWhitespace = false; // Whitespace after no-scope tags are sifnificant
        }
        else if (IsGoodForNameStart(this.NextCharacter))
        {
            _nextTokenType = HtmlTokenType.Name;

            // starts a name
            // we allow character entities here
            // we do not throw exceptions here if end of stream is encountered
            // just stop and return whatever is in the token
            // if the parser is not expecting end of file after this it will call
            // the get next token function and throw an exception
            while (IsGoodForName(this.NextCharacter) && !this.IsAtEndOfStream)
            {
                _nextToken.Append(this.NextCharacter);
                this.GetNextCharacter();
            }
        }
        else
        {
            // Unexpected type of token for a tag. Reprot one character as Atom, expecting that HtmlParser will ignore it.
            _nextTokenType = HtmlTokenType.Atom;
            _nextToken.Append(this.NextCharacter);
            this.GetNextCharacter();
        }
    }