Exemple #1
0
 private void Reset()
 {
     this.current     = string.Empty;
     this.position    = 0;
     this.length      = this.text.Length;
     this.currentType = CSSParser.tokenTypes.Unknown;
     this.groups.Clear();
 }
Exemple #2
0
        private bool MoveNext()
        {
            if (this.position >= this.length)
            {
                return(false);
            }
            while (this.position < this.length && char.IsWhiteSpace(this.text[this.position]))
            {
                ++this.position;
            }
            int position = this.position;

            if (this.position < this.length && ",;:{}()".IndexOf(this.text[this.position]) >= 0)
            {
                this.current     = this.text.Substring(this.position, 1);
                this.currentType = CSSParser.tokenTypes.SpecialOperator;
                ++this.position;
                return(true);
            }
            if (this.position < this.length - 2)
            {
                string str = this.text.Substring(this.position, 2);
                if (str == "//")
                {
                    while (this.position < this.length && this.text[this.position] != '\n')
                    {
                        ++this.position;
                    }
                    return(this.MoveNext());
                }
                if (str == "/*")
                {
                    for (; this.position < this.length; ++this.position)
                    {
                        if (this.position < this.length - 2 && this.text[this.position] == '*' && this.text[this.position + 1] == '/')
                        {
                            this.position += 2;
                            break;
                        }
                    }
                    return(this.MoveNext());
                }
            }
            if (this.position < this.length && this.text[this.position] == '"')
            {
                ++this.position;
                while (this.position < this.length && this.text[this.position] != '"')
                {
                    ++this.position;
                }
                this.current     = this.text.Substring(position + 1, this.position - position - 1);
                this.currentType = CSSParser.tokenTypes.String;
                ++this.position;
                return(true);
            }
            while (this.position < this.length && !char.IsWhiteSpace(this.text[this.position]) && ",;:{}()".IndexOf(this.text[this.position]) < 0)
            {
                ++this.position;
            }
            if (this.position - position <= 0)
            {
                return(false);
            }
            this.current     = this.text.Substring(position, this.position - position);
            this.currentType = CSSParser.tokenTypes.Identifier;
            return(true);
        }