当前位置: 首页>>代码示例>>C#>>正文


C# CharSetSolver.MkCharSetFromRegexCharClass方法代码示例

本文整理汇总了C#中CharSetSolver.MkCharSetFromRegexCharClass方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.MkCharSetFromRegexCharClass方法的具体用法?C# CharSetSolver.MkCharSetFromRegexCharClass怎么用?C# CharSetSolver.MkCharSetFromRegexCharClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CharSetSolver的用法示例。


在下文中一共展示了CharSetSolver.MkCharSetFromRegexCharClass方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRanges3

        public void TestRanges3()
        {
            CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
            BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
            int cnt = cond.CountNodes();
            Pair<uint, uint>[] ranges = solver.ToRanges(cond);
            BDD set = solver.MkCharSetFromRanges(ranges);
            int nodes = set.CountNodes();
            var ranges2 = new List<Pair<uint, uint>>(ranges);
            ranges2.Reverse();
            BDD set2 = solver.MkCharSetFromRanges(ranges2);
            int nodes2 = set.CountNodes();
            var ranges3 = solver.ToRanges(set2);
            BDD set3 = solver.MkCharSetFromRanges(ranges3);

            int cnt2 = set2.CountNodes();
            int cnt3 = set3.CountNodes();
            Assert.IsTrue(set2 == set3);

            Assert.AreEqual<int>(nodes, nodes2);
            Assert.AreSame(set,set2);

            set.ToDot("digits.dot");

            //check equivalence
            bool equiv = solver.MkOr(solver.MkAnd(cond, solver.MkNot(set)), solver.MkAnd(set, solver.MkNot(cond))) == solver.False;

            Assert.AreEqual<int>(31, ranges.Length);
        }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:29,代码来源:CharSetTests.cs

示例2: TestSurrogateRange

 public void TestSurrogateRange()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     //high and low surrogate pair elements
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\p{Cs}");
     cond.ToDot("surr.dot");
     int elems = (int)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(7, nodes); //highly compact BDD representation
     var ranges = solver.ToRanges(cond);
     Assert.AreEqual<int>(1, ranges.Length);
     Assert.AreEqual<uint>(ranges[0].First, 0xd800);
     Assert.AreEqual<uint>(ranges[0].Second, 0xdFFF);
     //the total number of surrogates (there are 1024 low surrogates and 1024 high surrogates)
     Assert.AreEqual<int>(2048, elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:16,代码来源:CharSetTests.cs

示例3: TestRanges2

 public void TestRanges2()
 {
     BitWidth enc = BitWidth.BV7;
     CharSetSolver solver = new CharSetSolver(enc);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\w");
     int nodes = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD cond2 = solver.MkCharSetFromRanges(ranges);
     Assert.AreSame(cond, cond2);
     int nodes2 = cond2.CountNodes();
     Assert.AreEqual<uint>((uint)'0', ranges[0].First);
     Assert.AreEqual<uint>((uint)'9', ranges[0].Second);
     Assert.AreEqual<uint>((uint)'A', ranges[1].First);
     Assert.AreEqual<uint>((uint)'Z', ranges[1].Second);
     Assert.AreEqual<uint>((uint)'_', ranges[2].First);
     Assert.AreEqual<uint>((uint)'_', ranges[2].Second);
     Assert.AreEqual<uint>((uint)'a', ranges[3].First);
     Assert.AreEqual<uint>((uint)'z', ranges[3].Second);
     Assert.AreEqual<int>(4, ranges.Length);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:20,代码来源:CharSetTests.cs

示例4: TestRanges2b

 public void TestRanges2b()
 {
     BitWidth enc = BitWidth.BV16;
     CharSetSolver solver = new CharSetSolver(enc);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\w");
     var ranges1 = solver.ToRanges(cond);
     var cond1 = solver.MkCharSetFromRanges(ranges1);
     Pair<uint, uint>[] ranges = solver.ToRanges(cond1);
     var cond2 = solver.MkCharSetFromRanges(ranges);
     Assert.AreSame(cond1, cond2);
     Assert.AreSame(cond, cond1);
     //cond.ToDot("cond.dot");
     Assert.AreEqual<uint>((uint)'0', ranges[0].First);
     Assert.AreEqual<uint>((uint)'9', ranges[0].Second);
     Assert.AreEqual<uint>((uint)'A', ranges[1].First);
     Assert.AreEqual<uint>((uint)'Z', ranges[1].Second);
     Assert.AreEqual<uint>((uint)'_', ranges[2].First);
     Assert.AreEqual<uint>((uint)'_', ranges[2].Second);
     Assert.AreEqual<uint>((uint)'a', ranges[3].First);
     Assert.AreEqual<uint>((uint)'z', ranges[3].Second);
     Assert.AreEqual<int>(426, ranges.Length);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:22,代码来源:CharSetTests.cs

示例5: TestNodeCount

 public void TestNodeCount()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\x00-\u7FFF]");
     int cnt = cond.CountNodes();
     Assert.AreEqual<int>(3, cnt);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:7,代码来源:CharSetTests.cs

示例6: TestLargeRange2

 public void TestLargeRange2()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF\uA000-\uA00F]");
     uint elems = (uint)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(14, nodes);
     var ranges = solver.ToRanges(cond);
     Assert.AreEqual<int>(2, ranges.Length);
     Assert.AreEqual<uint>(ranges[0].First, 0);
     Assert.AreEqual<uint>(ranges[0].Second, 0x7FFF);
     Assert.AreEqual<uint>(ranges[1].First, 0xA000);
     Assert.AreEqual<uint>(ranges[1].Second, 0xA00F);
     Assert.AreEqual<uint>(((uint)1 << 15) + ((uint)1 << 4), elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:15,代码来源:CharSetTests.cs

示例7: TestLargeRange

 public void TestLargeRange()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\u0000-\u7FFF]");
     int elems = (int)solver.ComputeDomainSize(cond);
     int nodes = cond.CountNodes();
     Assert.AreEqual<int>(3, nodes);
     Assert.AreEqual<int>((1 << 15), elems);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:9,代码来源:CharSetTests.cs

示例8: TestCardinality3

 public void TestCardinality3()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"[\w-[\d]]");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int wCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         int cat = (int)char.GetUnicodeCategory((char)i);
         if (cat == 0 || cat == 1 || cat == 2 || cat == 3 || cat == 4 || cat == 5 ||
              cat == 8 || cat == 18) //same as \w in regex
             if (!char.IsDigit((char)i))
                 wCnt += 1;
     }
     Assert.AreEqual<int>(wCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:24,代码来源:CharSetTests.cs

示例9: TestCardinality

 public void TestCardinality()
 {
     CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
     BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
     int cnt = cond.CountNodes();
     Pair<uint, uint>[] ranges = solver.ToRanges(cond);
     BDD set = solver.MkCharSetFromRanges(ranges);
     int nodes = set.CountNodes();
     int size = (int)solver.ComputeDomainSize(set);
     int expected = 0;
     foreach (var range in ranges)
         expected += ((int)(range.Second - range.First) + 1);
     Assert.AreEqual<int>(expected, size);
     int digitCnt = 0;
     for (int i = 0; i <= 0xFFFF; i++)
     {
         if (char.IsDigit(((char)i)))
             digitCnt += 1;
     }
     Assert.AreEqual<int>(digitCnt, size);
 }
开发者ID:AutomataDotNet,项目名称:Automata,代码行数:21,代码来源:CharSetTests.cs


注:本文中的CharSetSolver.MkCharSetFromRegexCharClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。