Exemple #1
0
        private Element ParseCharSet()
        {
            var repeat = true;
            var flag   = this.PeekChar(0) == Convert.ToInt32('^');
            CharacterSetElement charset;

            if (flag)
            {
                this.ReadChar('^');
                charset = new CharacterSetElement(true);
            }
            else
            {
                charset = new CharacterSetElement(false);
            }
            while (this.PeekChar(0) > 0 && repeat)
            {
                var start = Convert.ToChar(this.PeekChar(0));
                if (start != '\\')
                {
                    if (start != ']')
                    {
                        this.ReadChar(start);
                        var flag2 = this.PeekChar(0) == Convert.ToInt32('-') && this.PeekChar(1) > 0 &&
                                    this.PeekChar(1) != Convert.ToInt32(']');
                        if (flag2)
                        {
                            this.ReadChar('-');
                            var end = this.ReadChar();
                            charset.AddRange(this.FixChar(start), this.FixChar(end));
                        }
                        else
                        {
                            charset.AddCharacter(this.FixChar(start));
                        }
                    }
                    else
                    {
                        repeat = false;
                    }
                }
                else
                {
                    var elem  = this.ParseEscapeChar();
                    var flag3 = elem is StringElement;
                    if (flag3)
                    {
                        charset.AddCharacters((StringElement)elem);
                    }
                    else
                    {
                        charset.AddCharacterSet((CharacterSetElement)elem);
                    }
                }
            }
            return(charset);
        }
Exemple #2
0
 public void AddCharacterSet(CharacterSetElement elem)
 {
     this.contents.Add(elem);
 }