private Element ParseCharSet() { CharacterSetElement charset; bool repeat = true; if (PeekChar(0) == '^') { ReadChar('^'); charset = new CharacterSetElement(true); } else { charset = new CharacterSetElement(false); } while (PeekChar(0) > 0 && repeat) { var start = (char)PeekChar(0); switch (start) { case ']': repeat = false; break; case '\\': var elem = ParseEscapeChar(); if (elem is StringElement) { charset.AddCharacters((StringElement)elem); } else { charset.AddCharacterSet((CharacterSetElement)elem); } break; default: ReadChar(start); if (PeekChar(0) == '-' && PeekChar(1) > 0 && PeekChar(1) != ']') { ReadChar('-'); var end = ReadChar(); charset.AddRange(FixChar(start), FixChar(end)); } else { charset.AddCharacter(FixChar(start)); } break; } } return(charset); }
public void AddCharacterSet(CharacterSetElement elem) { _contents.Add(elem); }