Example #1
0
        /// <summary>
        /// 4.4.13. Number-rest state
        /// </summary>
        CssToken NumberRest()
        {
            var current = Next;

            while (true)
            {
                if (current.IsDigit())
                {
                    _stringBuffer.Append(current);
                }
                else if (current.IsNameStart())
                {
                    var number = FlushBuffer();
                    _stringBuffer.Append(current);
                    return(Dimension(number));
                }
                else if (IsValidEscape(current))
                {
                    current = Next;
                    var number = FlushBuffer();
                    _stringBuffer.Append(ConsumeEscape(current));
                    return(Dimension(number));
                }
                else
                {
                    break;
                }

                current = Next;
            }

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

                if (current.IsDigit())
                {
                    _stringBuffer.Append(Specification.Dot).Append(current);
                    return(NumberFraction());
                }

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

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

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

            case Specification.Minus:
                return(NumberDash());

            default:
                Back();
                return(CssToken.Number(FlushBuffer()));
            }
        }
Example #2
0
        /// <summary>
        /// 4.4.16. SciNotation state
        /// </summary>
        CssToken SciNotation()
        {
            while (true)
            {
                var current = Next;

                if (current.IsDigit())
                {
                    _stringBuffer.Append(current);
                }
                else
                {
                    Back();
                    return(CssToken.Number(FlushBuffer()));
                }
            }
        }
Example #3
0
        /// <summary>
        /// 4.4.16. SciNotation state
        /// </summary>
        CssToken SciNotation(Char current)
        {
            while (true)
            {
                if (current.IsDigit())
                {
                    _stringBuffer.Append(current);
                }
                else
                {
                    _src.Back();
                    return(CssToken.Number(FlushBuffer()));
                }

                current = _src.Next;
            }
        }
Example #4
0
        /// <summary>
        /// Substate of several Number states.
        /// </summary>
        CssToken NumberDash()
        {
            var current = Next;

            if (current.IsNameStart())
            {
                var number = FlushBuffer();
                _stringBuffer.Append(Specification.Minus).Append(current);
                return(Dimension(number));
            }
            else if (IsValidEscape(current))
            {
                current = Next;
                var number = FlushBuffer();
                _stringBuffer.Append(Specification.Minus).Append(ConsumeEscape(current));
                return(Dimension(number));
            }
            else
            {
                Back(2);
                return(CssToken.Number(FlushBuffer()));
            }
        }