public CharacterClass(CharacterBuffer buffer)
 {
     //this.Image = ImageType.CharacterClass;
     this.Start = buffer.IndexInOriginalBuffer;
     if (buffer.IsAtEnd)
     {
         Utility.ParseError("CharacterClass: Reached end of buffer looking for a character!", buffer);
         this.IsValid = false;
     }
     int currentIndex = buffer.CurrentIndex;
     ParsedCharacterClass parsedCharacterClass = buffer.GetParsedCharacterClass();
     if (parsedCharacterClass.Count == 0)
     {
         this.Description = parsedCharacterClass.ErrorMessage;
         buffer.MoveTo(currentIndex + 1);
         this.End = buffer.IndexInOriginalBuffer;
         this.Literal = "[";
         this.IsValid = false;
         return;
     }
     int num = buffer.CurrentIndex - currentIndex;
     Match match = CharacterClass.ClassRegex.Match(buffer.Substring(currentIndex, num));
     if (!match.Success)
     {
         this.Description = "Invalid Character Class";
         this.IsValid = false;
         this.Literal = "[";
     }
     else
     {
         if (match.Groups["Negate"].Value != "^")
         {
             this.Negate = false;
             this.MatchIfAbsent = false;
         }
         else
         {
             this.Negate = true;
             this.MatchIfAbsent = true;
         }
         if (match.Groups["Contents"].Value.Length == 0)
         {
             this.Description = "Character class is empty";
             this.IsValid = false;
         }
         else
         {
             this.Content = match.Groups["Contents"].Value;
         }
         this.Literal = match.Value;
     }
     if (this.IsValid)
     {
         if (!this.Negate)
         {
             this.Description = string.Concat("Any character in this class: ", this.Literal);
         }
         else
         {
             this.Description = string.Concat("Any character that is NOT in this class: ", this.Literal.Remove(1, 1));
         }
     }
     base.ParseRepetitions(buffer);
 }
 public void ParseRepetitions(CharacterBuffer buffer)
 {
     int currentIndex = buffer.CurrentIndex;
     buffer.SkipWhiteSpace();
     if (buffer.IsAtEnd)
     {
         RepeatType = Repeat.Once;
         buffer.MoveTo(currentIndex);
         End = buffer.IndexInOriginalBuffer;
         return;
     }
     char current = buffer.CurrentCharacter;
     switch (current)
     {
         case '*':
             {
                 this.RepeatType = Repeat.Any;
                 Element element = this;
                 element.Literal = string.Concat(element.Literal, buffer.CurrentCharacter);
                 buffer.MoveNext();
                 break;
             }
         case '+':
             {
                 this.RepeatType = Repeat.OneOrMore;
                 Element element1 = this;
                 element1.Literal = string.Concat(element1.Literal, buffer.CurrentCharacter);
                 buffer.MoveNext();
                 break;
             }
         default:
             {
                 if (current == '?')
                 {
                     this.RepeatType = Repeat.ZeroOrOne;
                     Element element2 = this;
                     element2.Literal = string.Concat(element2.Literal, buffer.CurrentCharacter);
                     buffer.MoveNext();
                     break;
                 }
                 else
                 {
                     if (current != '{')
                     {
                         this.RepeatType = Repeat.Once;
                         buffer.MoveTo(currentIndex);
                         this.End = buffer.IndexInOriginalBuffer;
                         return;
                     }
                     this.ParseBrackets(buffer);
                     break;
                 }
             }
     }
     currentIndex = buffer.CurrentIndex;
     buffer.SkipWhiteSpace();
     if (buffer.IsAtEnd || buffer.CurrentCharacter != '?')
     {
         buffer.MoveTo(currentIndex);
     }
     else
     {
         this.AsFewAsPossible = true;
         Element element3 = this;
         element3.Literal = string.Concat(element3.Literal, buffer.CurrentCharacter);
         buffer.MoveNext();
     }
     this.End = buffer.IndexInOriginalBuffer;
 }