예제 #1
0
        public void TestMethod3()
        {
            Re_Resolver re = new Re_Resolver();

            re.Resolve("(a)$");
            Assert.AreEqual(new Symbol("a"), re.parseTree.root.value);
        }
예제 #2
0
        public void TestMethod14()
        {
            Re_Resolver re     = new Re_Resolver();
            bool        result = re.Resolve("(a+|b))$");

            Assert.AreEqual(false, result);
        }
예제 #3
0
        public void TestMethod17()
        {
            Re_Resolver re = new Re_Resolver();

            Assert.IsTrue(re.Resolve("import$"));
            Assert.AreEqual(Operation.And, re.parseTree.root.operation);
        }
예제 #4
0
        public void TestMethod5()
        {
            Re_Resolver re = new Re_Resolver();

            re.Resolve("ab$");
            Assert.AreEqual(new Symbol("b"), re.parseTree.root.sons[1].value);
            Assert.AreEqual(Operation.And, re.parseTree.root.operation);
        }
예제 #5
0
        public void TestMethod9()
        {
            Re_Resolver re = new Re_Resolver();

            re.Resolve("(a|[b,1-9])*$");
            Assert.AreEqual(new Symbol("b,1-9"), re.parseTree.root.sons[0].sons[1].value);
            Assert.AreEqual(Operation.Star, re.parseTree.root.operation);
            Assert.AreEqual(Operation.Or, re.parseTree.root.sons[0].operation);
        }
예제 #6
0
        public void TestMethod8()
        {
            Re_Resolver re = new Re_Resolver();

            Assert.IsTrue(re.Resolve("(a|b)*$"));
            Assert.AreEqual(new Symbol("b"), re.parseTree.root.sons[0].sons[1].value);
            Assert.AreEqual(Operation.Star, re.parseTree.root.operation);
            Assert.AreEqual(Operation.Or, re.parseTree.root.sons[0].operation);
        }
예제 #7
0
        public void TestMethod16()
        {
            Re_Resolver re = new Re_Resolver();

            Assert.IsTrue(re.Resolve("(ab*c|a)(ab)*$"));
            Assert.AreEqual(Operation.And, re.parseTree.root.operation);
            Assert.AreEqual(Operation.Or, re.parseTree.root.sons[0].operation);
            Assert.AreEqual(Operation.Star, re.parseTree.root.sons[1].operation);
        }
예제 #8
0
        public void test1()
        {
            String      re          = "a*$";
            Re_Resolver re_resolver = new Re_Resolver();

            if (!re_resolver.Resolve(re))
            {
                Console.WriteLine("Incorrect Format of RE");
                return;
            }
            State.count = 0;
            NFA_ParseTree nfa = new NFA_ParseTree(re_resolver.parseTree);

            Assert.IsTrue(StartNFA(nfa.automata, "aa"));
        }