예제 #1
0
 private ParserCharSet(ParserCharSet other)
 {
     Array.Copy(other._ascii, _ascii, _ascii.Length);
     _categories = other._categories;
     _ranges.AddRange(other._ranges);
     if (other._negative != null)
     {
         _negative = new ParserCharSet(other._negative);
     }
 }
예제 #2
0
 private void Remove(ParserCharSet set)
 {
     RemoveAsciiArray(set._ascii);
     RemoveUnicode(set);
 }
예제 #3
0
 private void RemoveUnicode(ParserCharSet set)
 {
     if (_categories < 0)
     {
         // Remove category bits, but make sure that we preserve sign bit
         _categories &= ~(set._categories & c_categoryNoSignMask);
         if (_categories == c_categorySignMask)
         {
             _categories = 0;
         }
     }
     //TODO: add m_negative
     if (_negative != null)
     {
         _negative.AddUnicode(set);
     }
     RemoveRanges(set._ranges);
 }
예제 #4
0
 private void Add(ParserCharSet set)
 {
     AddAsciiArray(set._ascii);
     AddUnicode(set);
 }
예제 #5
0
 private void AddUnicode(ParserCharSet set)
 {
     AddRanges(set._ranges);
     if (_negative != null)
     {
         _negative.RemoveUnicode(set);
     }
     _categories |= set._categories;
 }
예제 #6
0
 public static ParserCharSet FromUnicodeCategory(string name)
 {
     int categories = s_categories[name];
     if (categories == 0)
     {
         throw new ArgumentException("Unknown category");
     }
     ParserCharSet result = new ParserCharSet();
     // Set sign bit to indicate that categories are used.
     result._categories = categories | c_categorySignMask;
     result.AddAsciiCategories(categories);
     return result;
 }
예제 #7
0
 private static ParserCharSet CreateAnyCharSet()
 {
     // Any char is the one which has any character inside
     ParserCharSet anyChar = new ParserCharSet();
     for (int i = 0; i < c_asciiCount; i++)
     {
         anyChar._ascii[i] = true;
     }
     anyChar._categories = -1; // any category
     return anyChar;
 }
예제 #8
0
 public static ParserCharSet operator -(ParserCharSet set1, ParserCharSet set2)
 {
     ParserCharSet result = new ParserCharSet(set1);
     result.Remove(set2);
     return result;
 }
예제 #9
0
 public static ParserCharSet FromRange(char first, char last)
 {
     if (last < first)
     {
         throw new ArgumentException("last character must be greater or equal to start character");
     }
     ParserCharSet charSet = new ParserCharSet();
     if (last < c_asciiCount)
     {
         for (int i = first; i <= last; i++)
         {
             charSet._ascii[i] = true;
         }
     }
     else if (first < c_asciiCount)
     {
         for (int i = first; i < c_asciiCount; i++)
         {
             charSet._ascii[i] = true;
         }
         if (last > first)
         {
             charSet._ranges.Add(new CharRange((char)c_asciiCount, last));
         }
     }
     else
     {
         charSet._ranges.Add(new CharRange(first, last));
     }
     return charSet;
 }
예제 #10
0
 public static ParserCharSet operator +(ParserCharSet set1, ParserCharSet set2)
 {
     ParserCharSet result = new ParserCharSet(set1);
     result.Add(set2);
     return result;
 }
예제 #11
0
 private int AddCharSet(ParserCharSet value)
 {
     _charSets.Add(value);
     return _charSets.Count - 1;
 }
예제 #12
0
 private int ProcessSetUnion(WomElement element)
 {
     ParserCharSet set = new ParserCharSet();
     WomElementCollection list = element.ElementList;
     for (int i = 0; i < list.Count; i++)
     {
         set = set + _charSets[ProcessElement(list[i])];
     }
     _charSets.Add(set);
     return _charSets.Count - 1;
 }
예제 #13
0
 private int ProcessCharSetString(WomElement element)
 {
     char[] chars = element.Properties["Text"].ToCharArray();
     ParserCharSet charSet = new ParserCharSet(chars);
     return AddCharSet(charSet);
 }
예제 #14
0
 private int AddMatchSet(ParserCharSet value)
 {
     int charSetIndex = AddCharSet(value);
     int nextIndex = _instructions.Count + 1;
     _instructions.Add(new ParserInstruction(ParserInstructionCode.MatchCharSet, nextIndex, charSetIndex));
     return _instructions.Count - 1;
 }