Example #1
0
        /// <summary>
        /// 4.4.23. Unicode-range State
        /// </summary>
        CssToken UnicodeRange(Char current)
        {
            for (int i = 0; i < 6; i++)
            {
                if (!current.IsHex())
                {
                    break;
                }

                _stringBuffer.Append(current);
                current = Next;
            }

            if (_stringBuffer.Length != 6)
            {
                for (int i = 0; i < 6 - _stringBuffer.Length; i++)
                {
                    if (current != Specification.QuestionMark)
                    {
                        current = Previous;
                        break;
                    }

                    _stringBuffer.Append(current);
                    current = Next;
                }

                var range = FlushBuffer();
                var start = range.Replace(Specification.QuestionMark, '0');
                var end   = range.Replace(Specification.QuestionMark, 'F');
                return(CssToken.Range(start, end));
            }
            else if (current == Specification.Minus)
            {
                current = Next;

                if (current.IsHex())
                {
                    var start = _stringBuffer.ToString();
                    _stringBuffer.Clear();

                    for (int i = 0; i < 6; i++)
                    {
                        if (!current.IsHex())
                        {
                            current = Previous;
                            break;
                        }

                        _stringBuffer.Append(current);
                        current = Next;
                    }

                    var end = FlushBuffer();
                    return(CssToken.Range(start, end));
                }
                else
                {
                    Back(2);
                    return(CssToken.Range(FlushBuffer(), null));
                }
            }
            else
            {
                Back();
                return(CssToken.Range(FlushBuffer(), null));
            }
        }