Exemplo n.º 1
0
        /// <summary>
        /// 4.4.3. Single quoted string state
        /// </summary>
        private CssToken StringSQ()
        {
            while (true)
            {
                var current = GetNext();

                switch (current)
                {
                case Symbols.SingleQuote:
                    return(NewString(FlushBuffer()));

                case Symbols.EndOfFile:
                    return(NewString(FlushBuffer(), bad: true));

                case Symbols.FormFeed:
                case Symbols.LineFeed:
                    RaiseErrorOccurred(CssParseError.LineBreakUnexpected);
                    Back();
                    return(NewString(FlushBuffer(), bad: true));

                case Symbols.ReverseSolidus:
                    current = GetNext();

                    if (current.IsLineBreak())
                    {
                        StringBuffer.AppendLine();
                    }
                    else if (current != Symbols.EndOfFile)
                    {
                        StringBuffer.Append(ConsumeEscape(current));
                    }
                    else
                    {
                        RaiseErrorOccurred(CssParseError.EOF);
                        Back();
                        return(NewString(FlushBuffer(), bad: true));
                    }

                    break;

                default:
                    StringBuffer.Append(current);
                    break;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 4.4.18. URL-double-quoted state
        /// </summary>
        CssToken UrlDQ(String functionName)
        {
            while (true)
            {
                var current = GetNext();

                if (current.IsLineBreak())
                {
                    RaiseErrorOccurred(CssParseError.LineBreakUnexpected);
                    return(UrlBad(functionName));
                }
                else if (Symbols.EndOfFile == current)
                {
                    return(NewUrl(functionName, FlushBuffer()));
                }
                else if (current == Symbols.DoubleQuote)
                {
                    return(UrlEnd(functionName));
                }
                else if (current != Symbols.ReverseSolidus)
                {
                    StringBuffer.Append(current);
                }
                else
                {
                    current = GetNext();

                    if (current == Symbols.EndOfFile)
                    {
                        Back(2);
                        RaiseErrorOccurred(CssParseError.EOF);
                        return(NewUrl(functionName, FlushBuffer(), bad: true));
                    }
                    else if (current.IsLineBreak())
                    {
                        StringBuffer.AppendLine();
                    }
                    else
                    {
                        StringBuffer.Append(ConsumeEscape(current));
                    }
                }
            }
        }
Exemplo n.º 3
0
        private Token UrlSingleQuote(string functionName)
        {
            while (true)
            {
                var current = GetNext();
                if (current.IsLineBreak())
                {
                    RaiseErrorOccurred(ParseError.LineBreakUnexpected);
                    return(UrlBad(functionName));
                }
                switch (current)
                {
                case Symbols.EndOfFile:
                    return(NewUrl(functionName, FlushBuffer()));

                case Symbols.SingleQuote:
                    return(UrlEnd(functionName));
                }
                if (current != Symbols.ReverseSolidus)
                {
                    StringBuffer.Append(current);
                }
                else
                {
                    current = GetNext();
                    if (current == Symbols.EndOfFile)
                    {
                        Back(2);
                        RaiseErrorOccurred(ParseError.EOF);
                        return(NewUrl(functionName, FlushBuffer(), true));
                    }
                    if (current.IsLineBreak())
                    {
                        StringBuffer.AppendLine();
                    }
                    else
                    {
                        StringBuffer.Append(ConsumeEscape(current));
                    }
                }
            }
        }