/// <summary>
        /// See 8.2.4.40 Attribute value (unquoted) state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken AttributeUnquotedValue(Char c, HtmlTagToken tag)
        {
            while (true)
            {
                if (c.IsSpaceCharacter())
                {
                    tag.SetAttributeValue(_stringBuffer.ToString());
                    return AttributeBeforeName(Next, tag);
                }
                else if (c == Specification.Ampersand)
                {
                    var value = CharacterReference(Next, Specification.GreaterThan);

                    if (value == null)
                        _stringBuffer.Append(Specification.Ampersand);
                    else
                        _stringBuffer.Append(value);
                }
                else if (c == Specification.GreaterThan)
                {
                    tag.SetAttributeValue(_stringBuffer.ToString());
                    return EmitTag(tag);
                }
                else if (c == Specification.Null)
                {
                    RaiseErrorOccurred(ErrorCode.Null);
                    _stringBuffer.Append(Specification.Replacement);
                }
                else if (c == Specification.DoubleQuote || c == Specification.SingleQuote || c == Specification.LessThan || c == Specification.Equality || c == Specification.CurvedQuote)
                {
                    RaiseErrorOccurred(ErrorCode.AttributeValueInvalid);
                    _stringBuffer.Append(c);
                }
                else if (c == Specification.EndOfFile)
                    return HtmlToken.EOF;
                else
                    _stringBuffer.Append(c);

                c = Next;
            }
        }
        /// <summary>
        /// See 8.2.4.39 Attribute value (single-quoted) state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken AttributeSingleQuotedValue(Char c, HtmlTagToken tag)
        {
            while (true)
            {
                if (c == Specification.SingleQuote)
                {
                    tag.SetAttributeValue(_stringBuffer.ToString());
                    return AttributeAfterValue(Next, tag);
                }
                else if (c == Specification.Ampersand)
                {
                    var value = CharacterReference(Next, Specification.SingleQuote);

                    if (value == null)
                        _stringBuffer.Append(Specification.Ampersand);
                    else
                        _stringBuffer.Append(value);
                }
                else if (c == Specification.Null)
                {
                    RaiseErrorOccurred(ErrorCode.Null);
                    _stringBuffer.Append(Specification.Replacement);
                }
                else if (c == Specification.EndOfFile)
                    return HtmlToken.EOF;
                else
                    _stringBuffer.Append(c);

                c = Next;
            }
        }