static private SetDescription ( String set ) : String | ||
set | String | |
리턴 | String |
internal static String SetDescription(String set) {
int mySetLength = set[SETLENGTH];
int myCategoryLength = set[CATEGORYLENGTH];
int myEndPosition = SETSTART + mySetLength + myCategoryLength;
StringBuilder desc = new StringBuilder("[");
int index = SETSTART;
char ch1;
char ch2;
if (IsNegated(set))
desc.Append('^');
while (index < SETSTART + set[SETLENGTH]) {
ch1 = set[index];
if (index + 1 < set.Length)
ch2 = (char)(set[index + 1] - 1);
else
ch2 = Lastchar;
desc.Append(CharDescription(ch1));
if (ch2 != ch1) {
if (ch1 + 1 != ch2)
desc.Append('-');
desc.Append(CharDescription(ch2));
}
index += 2;
}
while (index < SETSTART + set[SETLENGTH] + set[CATEGORYLENGTH]) {
ch1 = set[index];
if (ch1 == 0) {
bool found = false;
int lastindex = set.IndexOf(GroupChar, index+1);
string group = set.Substring(index,lastindex-index + 1);
IDictionaryEnumerator en = _definedCategories.GetEnumerator();
while(en.MoveNext()) {
if (group.Equals(en.Value)) {
if ((short) set[index+1] > 0)
desc.Append("\\p{" + en.Key + "}");
else
desc.Append("\\P{" + en.Key + "}");
found = true;
break;
}
}
if (!found) {
if (group.Equals(Word))
desc.Append("\\w");
else if (group.Equals(NotWord))
desc.Append("\\W");
else
Debug.Assert(false, "Couldn't find a goup to match '" + group + "'");
}
index = lastindex;
}
else {
desc.Append(CategoryDescription(ch1));
}
index++;
}
if (set.Length > myEndPosition) {
desc.Append('-');
desc.Append(SetDescription(set.Substring(myEndPosition)));
}
desc.Append(']');
return desc.ToString();
}
internal void Dump() { int i; Debug.WriteLine("Direction: " + (_rightToLeft ? "right-to-left" : "left-to-right")); Debug.WriteLine("Firstchars: " + (_fcPrefix == null ? "n/a" : RegexCharClass.SetDescription(_fcPrefix.Prefix))); Debug.WriteLine("Prefix: " + (_bmPrefix == null ? "n/a" : Regex.Escape(_bmPrefix.ToString()))); Debug.WriteLine("Anchors: " + RegexFCD.AnchorDescription(_anchors)); Debug.WriteLine("Scanchars: " + (_scPrefix == null ? "n/a" : RegexCharClass.SetDescription(_scPrefix.Prefix))); Debug.WriteLine(""); /* * if (_bmPrefix != null) { * Debug.WriteLine("BoyerMoore:"); * Debug.WriteLine(_bmPrefix.Dump(" ")); * } */ for (i = 0; i < _codes.Length;) { Debug.WriteLine(OpcodeDescription(i)); i += OpcodeSize(_codes[i]); } Debug.WriteLine(""); }