Esempio n. 1
0
        /// <summary>
        /// 4.4.13. Number-rest state
        /// </summary>
        CssToken NumberRest(Char current)
        {
            while (true)
            {
                if (current.IsDigit())
                {
                    stringBuffer.Append(current);
                }
                else if (current.IsNameStart())
                {
                    var number = FlushBuffer();
                    stringBuffer.Append(current);
                    return(Dimension(src.Next, number));
                }
                else if (IsValidEscape(current))
                {
                    current = src.Next;
                    var number = FlushBuffer();
                    stringBuffer.Append(ConsumeEscape(current));
                    return(Dimension(src.Next, number));
                }
                else
                {
                    break;
                }

                current = src.Next;
            }

            switch (current)
            {
            case Specification.DOT:
                current = src.Next;

                if (current.IsDigit())
                {
                    stringBuffer.Append(Specification.DOT).Append(current);
                    return(NumberFraction(src.Next));
                }

                src.Back();
                return(CssToken.Number(FlushBuffer()));

            case '%':
                return(CssUnitToken.Percentage(FlushBuffer()));

            case 'e':
            case 'E':
                return(NumberExponential(current));

            case Specification.MINUS:
                return(NumberDash(current));

            default:
                src.Back();
                return(CssToken.Number(FlushBuffer()));
            }
        }
Esempio n. 2
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 = src.Next;
                    stringBuffer.Append(ConsumeEscape(current));
                }
                else
                {
                    src.Back();
                    return(CssUnitToken.Dimension(number, FlushBuffer()));
                }

                current = src.Next;
            }
        }