예제 #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
        /// <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
        /// <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
        /// <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
        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
        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
        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
        /// <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;
            }
        }