Esempio n. 1
0
        public void TestNoRepeatsVisit() /*throws Exception*/
        {
            TreeWizard wiz      = new TreeWizard(adaptor, tokens);
            CommonTree t        = (CommonTree)wiz.Create("(A B C D)");
            IList      elements = new List <object>();

            wiz.Visit(t, wiz.GetTokenType("B"), new testNoRepeatsVisit_TreeWizard_Visitor(elements));
            string found     = elements.ToElementString();
            string expecting = "[B]";

            Assert.AreEqual(expecting, found);
        }
Esempio n. 2
0
        public void TestVisitPatternMultipleWithLabels() /*throws Exception*/
        {
            TreeWizard wiz      = new TreeWizard(adaptor, tokens);
            CommonTree t        = (CommonTree)wiz.Create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))");
            IList      elements = new List <object>();

            wiz.Visit(t, "(%a:A %b:B)",
                      new testVisitPatternMultipleWithLabels_TreeWizard_Visitor(elements));
            string found     = elements.ToElementString();
            string expecting = "[foo@A[2]foo&bar, big@D[0]big&dog]";

            Assert.AreEqual(expecting, found);
        }
Esempio n. 3
0
        public void TestVisitPatternMultiple() /*throws Exception*/
        {
            TreeWizard wiz      = new TreeWizard(adaptor, tokens);
            CommonTree t        = (CommonTree)wiz.Create("(A B C (A B) (D (A B)))");
            IList      elements = new List <object>();

            wiz.Visit(t, "(A B)",
                      new testRepeatsVisitWithContext_TreeWizard_Visitor(elements));
            string found     = elements.ToElementString();
            string expecting = "[A@A[2], A@D[0]]"; // shouldn't match overall root, just (A B)

            Assert.AreEqual(expecting, found);
        }
Esempio n. 4
0
        public void TestRepeatsVisitWithNullParentAndContext() /*throws Exception*/
        {
            TreeWizard wiz      = new TreeWizard(adaptor, tokens);
            CommonTree t        = (CommonTree)wiz.Create("(A B (A C B) B D D)");
            IList      elements = new List <object>();

            wiz.Visit(t, wiz.GetTokenType("A"),
                      new testRepeatsVisitWithContext_TreeWizard_Visitor(elements));
            string found     = elements.ToElementString();
            string expecting = "[A@nil[0], A@A[1]]";

            Assert.AreEqual(expecting, found);
        }
Esempio n. 5
0
        public void TestVisitPattern() /*throws Exception*/
        {
            TreeWizard wiz      = new TreeWizard(adaptor, tokens);
            CommonTree t        = (CommonTree)wiz.Create("(A B C (A B) D)");
            IList      elements = new List <object>();

            wiz.Visit(t, "(A B)",
                      new testNoRepeatsVisit_TreeWizard_Visitor(elements));
            string found     = elements.ToElementString();
            string expecting = "[A]"; // shouldn't match overall root, just (A B)

            assertEquals(expecting, found);
        }