コード例 #1
0
        /// <summary>
        /// 4.4.8. At-keyword-rest state
        /// </summary>
        CssToken AtKeywordRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else
                {
                    Back();
                    return CssKeywordToken.At(FlushBuffer());
                }

                current = Next;
            }
        }
コード例 #2
0
        /// <summary>
        /// 4.4.5. Hash-rest state
        /// </summary>
        CssToken HashRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == Specification.ReverseSolidus)
                {
                    RaiseErrorOccurred(ErrorCode.InvalidCharacter);
                    Back();
                    return CssKeywordToken.Hash(FlushBuffer());
                }
                else
                {
                    Back();
                    return CssKeywordToken.Hash(FlushBuffer());
                }

                current = Next;
            }
        }
コード例 #3
0
        /// <summary>
        /// 4.4.10. Ident-rest state
        /// </summary>
        CssToken IdentRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == Specification.RoundBracketOpen)
                {
                    var fn = _stringBuffer.ToString().ToLower();

                    if (fn == FunctionNames.Url)
                    {
                        _stringBuffer.Clear();
                        return UrlStart(Next, CssTokenType.Url);
                    }
                    else if (fn == FunctionNames.Domain)
                    {
                        _stringBuffer.Clear();
                        return UrlStart(Next, CssTokenType.Domain);
                    }
                    else if (fn == FunctionNames.Url_Prefix)
                    {
                        _stringBuffer.Clear();
                        return UrlStart(Next, CssTokenType.UrlPrefix);
                    }

                    return CssKeywordToken.Function(FlushBuffer());

                }
                //false could be replaced with a transform whitespace flag, which is set to true if in SVG transform mode.
                //else if (false && Specification.IsSpaceCharacter(current))
                //    InstantSwitch(TransformFunctionWhitespace);
                else
                {
                    Back();
                    return CssKeywordToken.Ident(FlushBuffer());
                }

                current = Next;
            }
        }
コード例 #4
0
ファイル: CssTokenizer.cs プロジェクト: JBTech/AngleSharp
        /// <summary>
        /// 4.4.10. Ident-rest state
        /// </summary>
        CssToken IdentRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _stringBuffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = GetNext();
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == Symbols.RoundBracketOpen)
                {
                    var fn = FlushBuffer();
                    var type = fn.GetTypeFromName();

                    switch (type)
                    {
                        case CssTokenType.Function:
                            return NewFunction(fn);
                        default:
                            return UrlStart(type);
                    }
                }
                else
                {
                    Back();
                    return NewIdent(FlushBuffer());
                }

                current = GetNext();
            }
        }
コード例 #5
0
        /// <summary>
        /// 4.4.15. Dimension state
        /// </summary>
        CssToken Dimension(Char current, String number)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else
                {
                    Back();
                    return CssUnitToken.Dimension(number, FlushBuffer());
                }

                current = Next;
            }
        }
コード例 #6
0
ファイル: CssTokenizer.cs プロジェクト: rrsc/AngleSharp
        /// <summary>
        /// 4.4.10. Ident-rest state
        /// </summary>
        CssToken IdentRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = _src.Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == Specification.RBO)
                {
                    switch (_stringBuffer.ToString().ToLower())
                    {
                        case FunctionNames.URL:
                            _stringBuffer.Clear();
                            return UrlStart(_src.Next, CssTokenType.Url);

                        case FunctionNames.DOMAIN:
                            _stringBuffer.Clear();
                            return UrlStart(_src.Next, CssTokenType.Domain);

                        case FunctionNames.URL_PREFIX:
                            _stringBuffer.Clear();
                            return UrlStart(_src.Next, CssTokenType.UrlPrefix);

                        default:
                            return CssKeywordToken.Function(FlushBuffer());
                    }

                }
                //false could be replaced with a transform whitespace flag, which is set to true if in SVG transform mode.
                //else if (false && Specification.IsSpaceCharacter(current))
                //    InstantSwitch(TransformFunctionWhitespace);
                else
                {
                    _src.Back();
                    return CssKeywordToken.Ident(FlushBuffer());
                }

                current = _src.Next;
            }
        }
コード例 #7
0
ファイル: CssTokenizer.cs プロジェクト: JBTech/AngleSharp
        /// <summary>
        /// 4.4.8. At-keyword-rest state
        /// </summary>
        CssToken AtKeywordRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _stringBuffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = GetNext();
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else
                {
                    Back();
                    return NewAtKeyword(FlushBuffer());
                }

                current = GetNext();
            }
        }
コード例 #8
0
ファイル: DtdTokenizer.cs プロジェクト: Rajbandi/AngleSharp
        DtdToken EntityDeclarationAfter(Char c, DtdEntityToken decl)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            if (c == Specification.EOF)
                throw new ArgumentException("The document ended unexpectedly.");
            else if (c == Specification.GT)
                return decl;
            else if (decl.IsExtern && String.IsNullOrEmpty(decl.ExternNotation))
            {
                if (_src.ContinuesWith("NDATA"))
                {
                    _src.Advance(4);
                    c = _src.Next;

                    while (c.IsSpaceCharacter())
                        c = _src.Next;

                    if (c.IsNameStart())
                    {
                        _stringBuffer.Clear();

                        do
                        {
                            _stringBuffer.Append(c);
                            c = _src.Next;
                        }
                        while (c.IsName());

                        decl.ExternNotation = _stringBuffer.ToString();
                        return EntityDeclarationAfter(c, decl);
                    }
                }
            }

            throw new ArgumentException("Declaration invalid.");
        }
コード例 #9
0
ファイル: DtdTokenizer.cs プロジェクト: Rajbandi/AngleSharp
        void AttributeDeclarationTypeEnumeration(Char c, AttributeEnumeratedType parent)
        {
            while (true)
            {
                while (c.IsSpaceCharacter())
                    c = _src.Next;

                if (c == Specification.EOF)
                    throw new ArgumentException("The document ended unexpectedly.");

                if (!c.IsName())
                    throw new ArgumentException("Declaration invalid.");

                do
                {
                    _stringBuffer.Append(c);
                    c = _src.Next;
                }
                while (c.IsName());

                while (c.IsSpaceCharacter())
                    c = _src.Next;

                parent.Names.Add(_stringBuffer.ToString());
                _stringBuffer.Clear();

                if (c == Specification.RBC)
                    break;
                else if (c == Specification.PIPE)
                    c = _src.Next;
                else
                    throw new ArgumentException("Declaration invalid.");
            }
        }
コード例 #10
0
ファイル: XmlTokenizer.cs プロジェクト: Rajbandi/AngleSharp
        XmlEntityToken CharacterReference(Char c)
        {
            _stringBuffer.Clear();

            if (c == Specification.NUM)
            {
                c = _src.Next;

                while (c.IsHex())
                {
                    _stringBuffer.Append(c);
                    c = _src.Next;
                }

                if (_stringBuffer.Length > 0 && c == Specification.SC)
                    return new XmlEntityToken { Value = _stringBuffer.ToString(), IsNumeric = true };
            }
            else if (c.IsNameStart())
            {
                do
                {
                    _stringBuffer.Append(c);
                    c = _src.Next;
                }
                while (c.IsName());

                if (c == Specification.SC)
                    return new XmlEntityToken { Value = _stringBuffer.ToString() };
            }

            throw new ArgumentException("Invalid entity reference.");
        }
コード例 #11
0
        /// <summary>
        /// 4.4.10. Ident-rest state
        /// </summary>
        CssToken IdentRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                {
                    _stringBuffer.Append(current);
                }
                else if (IsValidEscape(current))
                {
                    current = GetNext();
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == Symbols.RoundBracketOpen)
                {
                    var name = FlushBuffer();
                    var type = name.GetTypeFromName();
                    return type == CssTokenType.Function ? NewFunction(name) : UrlStart(name);
                }
                else
                {
                    Back();
                    return NewIdent(FlushBuffer());
                }

                current = GetNext();
            }
        }
コード例 #12
0
ファイル: CssTokenizer.cs プロジェクト: Rajbandi/AngleSharp
        /// <summary>
        /// 4.4.10. Ident-rest state
        /// </summary>
        CssToken IdentRest(Char current)
        {
            while (true)
            {
                if (current.IsName())
                    _stringBuffer.Append(current);
                else if (IsValidEscape(current))
                {
                    current = _src.Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                }
                else if (current == '(')
                {
                    if (_stringBuffer.ToString().Equals("url", StringComparison.OrdinalIgnoreCase))
                    {
                        _stringBuffer.Clear();
                        return UrlStart(_src.Next);
                    }

                    return CssKeywordToken.Function(FlushBuffer());
                }
                //false could be replaced with a transform whitespace flag, which is set to true if in SVG transform mode.
                //else if (false && Specification.IsSpaceCharacter(current))
                //    InstantSwitch(TransformFunctionWhitespace);
                else
                {
                    _src.Back();
                    return CssKeywordToken.Ident(FlushBuffer());
                }

                current = _src.Next;
            }
        }