コード例 #1
0
ファイル: Program.cs プロジェクト: sh1nu11bi/Regex
        static void _RunStress2()
        {
            CharFA <string> fa  = null;
            var             min = 255;
            var             max = 511;

            Console.Write("Building NFA matching integer values {0}-{1} ", min, max);
            for (var i = min; i <= max; ++i)
            {
                // for perf reasons we reduce every 12 times
                if (null == fa)
                {
                    fa = CharFA <string> .Literal(i.ToString());
                }
                else
                {
                    fa = CharFA <string> .Or(new CharFA <string>[] { fa, CharFA <string> .Literal(i.ToString()) });
                }
                if (0 == (i % 12))
                {
                    Console.Write('.');
                }
                // replace the above "Console.Write('.');" line with below is MUCH faster
                //	fa=fa.Reduce(new _ConsoleProgress());
            }
            Console.WriteLine();
            Console.WriteLine("C# integer NFA has {0} states.", fa.FillClosure().Count);
            fa = fa.Reduce(new _ConsoleProgress());
            Console.WriteLine();
            Console.WriteLine("C# integer DFA has {0} states.", fa.FillClosure().Count);
            Console.WriteLine("Rendering stress2.jpg");
            fa.RenderToFile(@"..\..\..\stress2.jpg");
        }
コード例 #2
0
        static void _RunStress2()
        {
            CharFA <string> fa  = null;
            var             min = 599;
            var             max = 639;

            Console.Write("Building NFA matching integer values {0}-{1} ", min, max);
            for (var i = min; i <= max; ++i)
            {
                if (null == fa)
                {
                    fa = CharFA <string> .Literal(i.ToString());
                }
                else
                {
                    fa = CharFA <string> .Or(new CharFA <string>[] { fa, CharFA <string> .Literal(i.ToString()) });
                }
                // for perf reasons we can reduce every 12 times
                if (0 == (i % 12))
                {
                    Console.Write('.');
                }
                // replace the above "Console.Write('.');" line with below is MUCH faster
                //	fa=fa.Reduce(new _ConsoleProgress());
            }
            Console.WriteLine();
            fa.TrimNeutrals();
            //fa.TrimDuplicates();
            Console.WriteLine("C# integer NFA has {0} states.", fa.FillClosure().Count);
            fa.RenderToFile(@"..\..\..\stress2_nfa.jpg");
            fa = fa.Reduce(new _ConsoleProgress());
            Console.WriteLine();
            Console.WriteLine("C# integer DFA has {0} states.", fa.FillClosure().Count);
            //var expr = RegexExpression.FromFA(fa);
            //Console.WriteLine("Final Expression: {0}", expr);
            Console.WriteLine("Rendering stress2.jpg");
            fa.RenderToFile(@"..\..\..\stress2.jpg");
        }