Example #1
0
        public void DFAtest3()
        {
            DFA dfa = DFA_Builder.BuildDFA("a*(b|c)$");

            Assert.IsTrue(StartDFA(dfa, "aab"));
            Assert.IsTrue(StartDFA(dfa, "aac"));
        }
Example #2
0
        public bool LoadRules(string rulesFile)
        {
            dfas      = new List <DFA>();
            propertys = new List <string>();

            StreamReader sr      = new StreamReader(rulesFile, Encoding.Default);
            string       newline = null;

            try
            {
                while ((newline = sr.ReadLine()) != null)
                {
                    string[] rule = null;
                    rule = newline.Split(' ');
                    propertys.Add(rule[0]);
                    dfas.Add(DFA_Builder.BuildDFA(rule[1]));
                }
            }catch (Exception e)
            {
                Console.WriteLine("LoadRules Failed.");
                Console.WriteLine(e.Data);
            }
            sr.Close();
            return(true);
        }
Example #3
0
        public void DFAtest2()
        {
            DFA dfa = DFA_Builder.BuildDFA("a*b$");

            Assert.IsTrue(StartDFA(dfa, "aab"));
            Assert.IsFalse(StartDFA(dfa, "aa"));
        }
Example #4
0
        public void DFAtest1()
        {
            DFA dfa = DFA_Builder.BuildDFA("a*$");

            Assert.IsFalse(dfa.states.Count > 2);
            Assert.IsTrue(StartDFA(dfa, "aa"));
        }
Example #5
0
        public void DFAtest4()
        {
            DFA dfa = DFA_Builder.BuildDFA("(aa*(b|c))*$");

            Assert.IsFalse(StartDFA(dfa, "aabcb"));
            Assert.IsTrue(StartDFA(dfa, "aab"));
            Assert.IsTrue(StartDFA(dfa, ""));
        }
Example #6
0
 public Project(string Name)
 {
     CD          = new CompressData();
     ProjectName = Name;
     CurrentDFA  = new DFA_Builder();
     Parse       = new Parser();
     //InitilizeEngine();
 }
Example #7
0
 public Project()
 {
     CD         = new CompressData();
     CurrentDFA = new DFA_Builder();
     Parse      = new Parser();
     //InitilizeEngine();
     //GInterface = new Main();
 }
Example #8
0
 public void test1()
 {
     DFA dfa = DFA_Builder.BuildDFA("a*bc");
     //    dfa.closures.Add
 }
Example #9
0
        public void DFAtest5()
        {
            DFA dfa = DFA_Builder.BuildDFA("(ab*c|a)(ab)*$");

            Assert.IsTrue(StartDFA(dfa, "abbbcabab"));
        }