Example #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);
     }
 }
Example #2
0
 private void Remove(ParserCharSet set)
 {
     RemoveAsciiArray(set._ascii);
     RemoveUnicode(set);
 }
Example #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);
 }
Example #4
0
 private void Add(ParserCharSet set)
 {
     AddAsciiArray(set._ascii);
     AddUnicode(set);
 }
Example #5
0
 private void AddUnicode(ParserCharSet set)
 {
     AddRanges(set._ranges);
     if (_negative != null)
     {
         _negative.RemoveUnicode(set);
     }
     _categories |= set._categories;
 }
Example #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;
 }
Example #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;
 }
Example #8
0
 public static ParserCharSet operator -(ParserCharSet set1, ParserCharSet set2)
 {
     ParserCharSet result = new ParserCharSet(set1);
     result.Remove(set2);
     return result;
 }
Example #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;
 }
Example #10
0
 public static ParserCharSet operator +(ParserCharSet set1, ParserCharSet set2)
 {
     ParserCharSet result = new ParserCharSet(set1);
     result.Add(set2);
     return result;
 }
 private int AddCharSet(ParserCharSet value)
 {
     _charSets.Add(value);
     return _charSets.Count - 1;
 }
 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;
 }
 private int ProcessCharSetString(WomElement element)
 {
     char[] chars = element.Properties["Text"].ToCharArray();
     ParserCharSet charSet = new ParserCharSet(chars);
     return AddCharSet(charSet);
 }
 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;
 }